00001 00005 /* Copyright, 2001 Nevrax Ltd. 00006 * 00007 * This file is part of NEVRAX NEL. 00008 * NEVRAX NEL is free software; you can redistribute it and/or modify 00009 * it under the terms of the GNU General Public License as published by 00010 * the Free Software Foundation; either version 2, or (at your option) 00011 * any later version. 00012 00013 * NEVRAX NEL is distributed in the hope that it will be useful, but 00014 * WITHOUT ANY WARRANTY; without even the implied warranty of 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00016 * General Public License for more details. 00017 00018 * You should have received a copy of the GNU General Public License 00019 * along with NEVRAX NEL; see the file COPYING. If not, write to the 00020 * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, 00021 * MA 02111-1307, USA. 00022 */ 00023 00024 #include "stdpacs.h" 00025 00026 #include "move_cell.h" 00027 #include "move_element.h" 00028 #include "move_primitive.h" 00029 00030 namespace NLPACS 00031 { 00032 00033 // *************************************************************************** 00034 00035 CMoveCell::CMoveCell() 00036 { 00037 _FirstX=NULL; 00038 _LastX=NULL; 00039 /*_FirstY=NULL; 00040 _LastY=NULL;*/ 00041 } 00042 00043 // *************************************************************************** 00044 00045 void CMoveCell::unlinkX (CMoveElement *element) 00046 { 00047 // Check first last 00048 if (_FirstX==element) 00049 _FirstX=element->NextX; 00050 if (_LastX==element) 00051 _LastX=element->PreviousX; 00052 00053 // Relink to others 00054 if (element->NextX) 00055 element->NextX->PreviousX=element->PreviousX; 00056 if (element->PreviousX) 00057 element->PreviousX->NextX=element->NextX; 00058 } 00059 00060 // *************************************************************************** 00061 00062 /*void CMoveCell::unlinkY (CMoveElement *element) 00063 { 00064 // Linked in list ? 00065 // Check first / last 00066 if (_FirstY==element) 00067 _FirstY=element->NextY; 00068 if (_LastY==element) 00069 _LastY=element->PreviousY; 00070 00071 // Relink to others 00072 if (element->NextY) 00073 element->NextY->PreviousY=element->PreviousY; 00074 if (element->PreviousY) 00075 element->PreviousY->NextY=element->NextY; 00076 }*/ 00077 00078 // *************************************************************************** 00079 00080 void CMoveCell::linkX (CMoveElement *previous, CMoveElement *element, CMoveElement *next) 00081 { 00082 // Link the element 00083 element->NextX=next; 00084 element->PreviousX=previous; 00085 00086 // Link to others 00087 if (previous) 00088 previous->NextX=element; 00089 if (next) 00090 next->PreviousX=element; 00091 00092 // Check first / last 00093 if (previous==NULL) 00094 _FirstX=element; 00095 if (next==NULL) 00096 _LastX=element; 00097 } 00098 00099 // *************************************************************************** 00100 00101 /*void CMoveCell::linkY (CMoveElement *previous, CMoveElement *element, CMoveElement *next) 00102 { 00103 // Link the element 00104 element->NextY=next; 00105 element->PreviousY=previous; 00106 00107 // Link to others 00108 if (previous) 00109 previous->NextY=element; 00110 if (next) 00111 next->PreviousY=element; 00112 00113 // Check first / last 00114 if (previous==NULL) 00115 _FirstY=element; 00116 if (next==NULL) 00117 _LastY=element; 00118 }*/ 00119 00120 // *************************************************************************** 00121 00122 void CMoveCell::updateSortedLists (CMoveElement *element, uint8 worldImage) 00123 { 00124 // ** Update sorted list on X 00125 00126 // Primitive pointer 00127 CMovePrimitive *primitive=element->Primitive; 00128 00129 // Get the world image 00130 CPrimitiveWorldImage *wI=primitive->getWorldImage (worldImage); 00131 00132 // Test if we will go to the right 00133 CMoveElement *ptr=element->NextX; 00134 if (ptr && (wI->getBBXMin() > ptr->Primitive->getWorldImage (worldImage)->getBBXMin()) ) 00135 { 00136 // Unlink 00137 unlinkX (element); 00138 00139 // Adjust the list localisation 00140 while (ptr->NextX && (wI->getBBXMin() > ptr->NextX->Primitive->getWorldImage (worldImage)->getBBXMin()) ) 00141 { 00142 // Next ptr 00143 ptr=ptr->NextX; 00144 } 00145 00146 // Here we go 00147 linkX (ptr, element, ptr->NextX); 00148 } 00149 else 00150 { 00151 // Test if we will go to the left 00152 ptr=element->PreviousX; 00153 if (ptr && (ptr->Primitive->getWorldImage (worldImage)->getBBXMin() > wI->getBBXMin()) ) 00154 { 00155 // Unlink 00156 unlinkX (element); 00157 00158 // Adjust the list localisation 00159 while (ptr->PreviousX && (ptr->PreviousX->Primitive->getWorldImage (worldImage)->getBBXMin() > wI->getBBXMin()) ) 00160 { 00161 // Next ptr 00162 ptr=ptr->PreviousX; 00163 } 00164 00165 // Here we go 00166 linkX (ptr->PreviousX, element, ptr); 00167 } 00168 } 00169 00170 /* // ** Update sorted list on Y 00171 00172 // Test if we will go to the right 00173 ptr=element->NextY; 00174 if (ptr && (primitive->getBBYMin() > ptr->Primitive->getBBYMin()) ) 00175 { 00176 // Unlink 00177 unlinkY (element); 00178 00179 // Adjust the list localisation 00180 while (ptr->NextY && (primitive->getBBYMin() > ptr->NextY->Primitive->getBBYMin()) ) 00181 { 00182 // Next ptr 00183 ptr=ptr->NextY; 00184 } 00185 00186 // Here we go 00187 linkY (ptr, element, ptr->NextY); 00188 } 00189 else 00190 { 00191 // Test if we will go to the left 00192 ptr=element->PreviousY; 00193 if (ptr && (ptr->Primitive->getBBYMin() > primitive->getBBYMin()) ) 00194 { 00195 // Unlink 00196 unlinkY (element); 00197 00198 // Adjust the list localisation 00199 while (ptr->PreviousY && (ptr->PreviousY->Primitive->getBBYMin() > primitive->getBBYMin()) ) 00200 { 00201 // Next ptr 00202 ptr=ptr->PreviousY; 00203 } 00204 00205 // Here we go 00206 linkY (ptr->PreviousY, element, ptr); 00207 } 00208 }*/ 00209 } 00210 00211 // *************************************************************************** 00212 00213 } // NLPACS
1.6.1