Changeset 5704 in orxonox.OLD for branches/collision_detection
- Timestamp:
- Nov 22, 2005, 2:07:49 PM (19 years ago)
- Location:
- branches/collision_detection/src/lib/collision_detection
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/collision_detection/src/lib/collision_detection/bounding_volume.cc
r5702 r5704 29 29 this->setClassID(CL_BOUNDING_VOLUME, "BoundingVolume"); 30 30 this->center = new Vector(); 31 this->bOrigVertices = true;32 31 this->vertices = NULL; 33 32 } … … 42 41 // delete what has to be deleted here 43 42 delete this->center; 44 45 if( this->vertices && !this->bOrigVertices)46 delete[] this->vertices;47 43 48 44 if( this->triangleIndexes) -
branches/collision_detection/src/lib/collision_detection/bounding_volume.h
r5702 r5704 36 36 const sVec3D* vertices; //!< if CD_STORE_VERTICES enabled, this is the place, where the vert. will be sotred 37 37 int numOfVertices; //!< number of vertices in the vertices buffer 38 bool bOrigVertices; //!< is true if the vertices pointer points to the original model data - only important for deleting39 38 const modelInfo* modelInf; //!< Reference to the model's ModelInfo 40 39 const int* triangleIndexes; //!< Array with the triangle indexes in modelInfo -
branches/collision_detection/src/lib/collision_detection/obb_tree_node.cc
r5703 r5704 116 116 sVec3D* verticesList; 117 117 118 PRINT(3)("\n");119 118 PRINTF(3)("OBB Depth: %i, tree index: %i, numVertices: %i\n", depth, treeIndex, length); 120 119 this->depth = depth; 121 120 122 123 this->bvElement = new OBB(); 124 121 this->bvElement = new OBB(); 125 122 this->bvElement->modelInf = &modelInf; 126 123 this->bvElement->triangleIndexes = triangleIndexes; 127 124 this->bvElement->numTriangles = length; 128 125 129 PRINTF(3)("Created OBBox\n");130 126 this->calculateBoxCovariance(this->bvElement, modelInf, triangleIndexes, length); 131 PRINTF(3)("Calculated attributes1\n");132 127 this->calculateBoxEigenvectors(this->bvElement, modelInf, triangleIndexes, length); 133 PRINTF(3)("Calculated attributes2\n");134 128 this->calculateBoxAxis(this->bvElement, modelInf, triangleIndexes, length); 135 PRINTF(3)("Calculated attributes3\n"); 136 137 /* if this is the first node, the vertices data are the original ones of the model itself, so dont delete them in cleanup */ 138 if( this->treeIndex == 1) 139 this->bvElement->bOrigVertices = true; 140 129 130 /* if this is the first node, the vertices data are the original ones of the model itself, 131 so dont delete them in cleanup */ 141 132 if( likely( this->depth > 0)) 142 133 { … … 179 170 void OBBTreeNode::spawnBVTree(const int depth, const sVec3D *verticesList, unsigned int length) 180 171 { 181 PRINT(3)("\n"); 182 PRINTF(3)("OBB Depth: %i, tree index: %i, numVertices: %i\n", depth, treeIndex, length); 183 this->depth = depth; 184 185 186 this->bvElement = new OBB(); 187 this->bvElement->vertices = verticesList; 188 this->bvElement->numOfVertices = length; 189 PRINTF(3)("Created OBBox\n"); 190 this->calculateBoxCovariance(this->bvElement, verticesList, length); 191 PRINTF(3)("Calculated attributes1\n"); 192 this->calculateBoxEigenvectors(this->bvElement, verticesList, length); 193 PRINTF(3)("Calculated attributes2\n"); 194 this->calculateBoxAxis(this->bvElement, verticesList, length); 195 PRINTF(3)("Calculated attributes3\n"); 196 197 /* if this is the first node, the vertices data are the original ones of the model itself, so dont delete them in cleanup */ 198 if( this->treeIndex == 1) 199 this->bvElement->bOrigVertices = true; 200 201 if( likely( this->depth > 0)) 202 { 203 this->forkBox(this->bvElement); 204 205 206 if(this->tmpLen1 > 2) 207 { 208 OBBTreeNode* node1 = new OBBTreeNode(this->obbTree); 209 this->nodeLeft = node1; 210 this->nodeLeft->spawnBVTree(depth - 1, this->tmpVert1, this->tmpLen1); 211 } 212 else 213 { 214 PRINTF(3)("Aboarding tree walk: less than 3 vertices left\n"); 215 } 216 217 if( this->tmpLen2 > 2) 218 { 219 OBBTreeNode* node2 = new OBBTreeNode(this->obbTree); 220 this->nodeRight = node2; 221 this->nodeRight->spawnBVTree(depth - 1, this->tmpVert2, this->tmpLen2); 222 } 223 else 224 { 225 PRINTF(3)("Abording tree walk: less than 3 vertices left\n"); 226 } 227 } 172 // PRINT(3)("\n"); 173 // PRINTF(3)("OBB Depth: %i, tree index: %i, numVertices: %i\n", depth, treeIndex, length); 174 // this->depth = depth; 175 // 176 // 177 // this->bvElement = new OBB(); 178 // this->bvElement->vertices = verticesList; 179 // this->bvElement->numOfVertices = length; 180 // PRINTF(3)("Created OBBox\n"); 181 // this->calculateBoxCovariance(this->bvElement, verticesList, length); 182 // PRINTF(3)("Calculated attributes1\n"); 183 // this->calculateBoxEigenvectors(this->bvElement, verticesList, length); 184 // PRINTF(3)("Calculated attributes2\n"); 185 // this->calculateBoxAxis(this->bvElement, verticesList, length); 186 // PRINTF(3)("Calculated attributes3\n"); 187 // 188 // 189 // 190 // if( likely( this->depth > 0)) 191 // { 192 // this->forkBox(this->bvElement); 193 // 194 // 195 // if(this->tmpLen1 > 2) 196 // { 197 // OBBTreeNode* node1 = new OBBTreeNode(this->obbTree); 198 // this->nodeLeft = node1; 199 // this->nodeLeft->spawnBVTree(depth - 1, this->tmpVert1, this->tmpLen1); 200 // } 201 // else 202 // { 203 // PRINTF(3)("Aboarding tree walk: less than 3 vertices left\n"); 204 // } 205 // 206 // if( this->tmpLen2 > 2) 207 // { 208 // OBBTreeNode* node2 = new OBBTreeNode(this->obbTree); 209 // this->nodeRight = node2; 210 // this->nodeRight->spawnBVTree(depth - 1, this->tmpVert2, this->tmpLen2); 211 // } 212 // else 213 // { 214 // PRINTF(3)("Abording tree walk: less than 3 vertices left\n"); 215 // } 216 // } 228 217 } 229 218 … … 235 224 void OBBTreeNode::calculateBoxCovariance(OBB* box, const sVec3D* verticesList, unsigned int length) 236 225 { 226 PRINTF(3)("Created OBBox\n"); 227 237 228 float facelet[length]; //!< surface area of the i'th triangle of the convex hull 238 229 float face = 0.0f; //!< surface area of the entire convex hull … … 428 419 void OBBTreeNode::calculateBoxEigenvectors(OBB* box, const sVec3D* verticesList, unsigned int length) 429 420 { 430 421 PRINTF(3)("Calculated attributes1\n"); 431 422 /* now getting spanning vectors of the sub-space: 432 423 the eigenvectors of a symmertric matrix, such as the … … 484 475 void OBBTreeNode::calculateBoxAxis(OBB* box, const sVec3D* verticesList, unsigned int length) 485 476 { 486 477 PRINTF(3)("Calculated attributes3\n"); 487 478 /* now get the axis length */ 488 479 Line ax[3]; //!< the axis -
branches/collision_detection/src/lib/collision_detection/obb_tree_node.h
r5703 r5704 26 26 public: 27 27 OBBTreeNode(const OBBTree* tree); 28 OBBTreeNode(const OBBTree* tree, bool bRoot); 28 29 virtual ~OBBTreeNode(); 29 30
Note: See TracChangeset
for help on using the changeset viewer.