1 // NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
2 // Copyright (C) 2010 Winch Gate Property Limited
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU Affero General Public License as
6 // published by the Free Software Foundation, either version 3 of the
7 // License, or (at your option) any later version.
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU Affero General Public License for more details.
14 // You should have received a copy of the GNU Affero General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
19 #include "nel/pacs/move_cell.h"
20 #include "nel/pacs/move_element.h"
21 #include "nel/pacs/move_primitive.h"
26 // ***************************************************************************
28 CMoveCell::CMoveCell()
36 // ***************************************************************************
38 void CMoveCell::unlinkX (CMoveElement
*element
)
42 _FirstX
=element
->NextX
;
44 _LastX
=element
->PreviousX
;
48 element
->NextX
->PreviousX
=element
->PreviousX
;
49 if (element
->PreviousX
)
50 element
->PreviousX
->NextX
=element
->NextX
;
53 // ***************************************************************************
55 /*void CMoveCell::unlinkY (CMoveElement *element)
60 _FirstY=element->NextY;
62 _LastY=element->PreviousY;
66 element->NextY->PreviousY=element->PreviousY;
67 if (element->PreviousY)
68 element->PreviousY->NextY=element->NextY;
71 // ***************************************************************************
73 void CMoveCell::linkX (CMoveElement
*previous
, CMoveElement
*element
, CMoveElement
*next
)
77 element
->PreviousX
=previous
;
81 previous
->NextX
=element
;
83 next
->PreviousX
=element
;
92 // ***************************************************************************
94 /*void CMoveCell::linkY (CMoveElement *previous, CMoveElement *element, CMoveElement *next)
98 element->PreviousY=previous;
102 previous->NextY=element;
104 next->PreviousY=element;
106 // Check first / last
113 // ***************************************************************************
115 void CMoveCell::updateSortedLists (CMoveElement
*element
, uint8 worldImage
)
117 // ** Update sorted list on X
120 CMovePrimitive
*primitive
=element
->Primitive
;
122 // Get the world image
123 CPrimitiveWorldImage
*wI
=primitive
->getWorldImage (worldImage
);
125 // Test if we will go to the right
126 CMoveElement
*ptr
=element
->NextX
;
127 if (ptr
&& (wI
->getBBXMin() > ptr
->Primitive
->getWorldImage (worldImage
)->getBBXMin()) )
132 // Adjust the list localisation
133 while (ptr
->NextX
&& (wI
->getBBXMin() > ptr
->NextX
->Primitive
->getWorldImage (worldImage
)->getBBXMin()) )
140 linkX (ptr
, element
, ptr
->NextX
);
144 // Test if we will go to the left
145 ptr
=element
->PreviousX
;
146 if (ptr
&& (ptr
->Primitive
->getWorldImage (worldImage
)->getBBXMin() > wI
->getBBXMin()) )
151 // Adjust the list localisation
152 while (ptr
->PreviousX
&& (ptr
->PreviousX
->Primitive
->getWorldImage (worldImage
)->getBBXMin() > wI
->getBBXMin()) )
159 linkX (ptr
->PreviousX
, element
, ptr
);
163 /* // ** Update sorted list on Y
165 // Test if we will go to the right
167 if (ptr && (primitive->getBBYMin() > ptr->Primitive->getBBYMin()) )
172 // Adjust the list localisation
173 while (ptr->NextY && (primitive->getBBYMin() > ptr->NextY->Primitive->getBBYMin()) )
180 linkY (ptr, element, ptr->NextY);
184 // Test if we will go to the left
185 ptr=element->PreviousY;
186 if (ptr && (ptr->Primitive->getBBYMin() > primitive->getBBYMin()) )
191 // Adjust the list localisation
192 while (ptr->PreviousY && (ptr->PreviousY->Primitive->getBBYMin() > primitive->getBBYMin()) )
199 linkY (ptr->PreviousY, element, ptr);
204 // ***************************************************************************