- Timestamp:
- Nov 22, 2005, 7:01:42 PM (19 years ago)
- Location:
- branches/collision_detection/src
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/collision_detection/src/defs/debug.h
r5476 r5713 75 75 #define DEBUG_MODULE_OBJECT_MANAGER 2 76 76 #define DEBUG_MODULE_ANIM 2 77 #define DEBUG_MODULE_COLLISON_DETECTION 277 #define DEBUG_MODULE_COLLISON_DETECTION 5 78 78 #define DEBUG_MODULE_SPATIAL_SEPARATION 2 79 79 #define DEBUG_MODULE_GUI 2 -
branches/collision_detection/src/lib/collision_detection/cd_engine.cc
r5134 r5713 14 14 */ 15 15 16 #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_COLLISION 16 #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_COLLISION_DETECTION 17 17 18 18 #include "cd_engine.h" -
branches/collision_detection/src/lib/collision_detection/obb_tree.cc
r5705 r5713 14 14 */ 15 15 16 #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_COLLISION 16 #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_COLLISION_DETECTION 17 17 18 18 #include "obb_tree.h" … … 76 76 this->flushTree(); 77 77 } 78 OBBTreeNode* node = new OBBTreeNode( this);78 OBBTreeNode* node = new OBBTreeNode(*this, depth); 79 79 this->rootNode = node; 80 80 this->rootNode->spawnBVTree(--depth, verticesList, length); … … 89 89 this->flushTree(); 90 90 } 91 OBBTreeNode* node = new OBBTreeNode( this);91 OBBTreeNode* node = new OBBTreeNode(*this, depth); 92 92 this->rootNode = node; 93 93 94 94 /* triangles indexes created */ 95 95 int* triangleIndexes = new int[modelInf.numTriangles]; 96 96 for(int i = 0; i < modelInf.numTriangles; ++i) 97 97 triangleIndexes[i] = i; 98 98 99 99 this->rootNode->spawnBVTree(--depth, modelInf, triangleIndexes, modelInf.numTriangles); 100 100 } -
branches/collision_detection/src/lib/collision_detection/obb_tree_node.cc
r5712 r5713 14 14 */ 15 15 16 #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_COLLISION 16 #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_COLLISION_DETECTION 17 17 18 18 #include "obb_tree_node.h" … … 42 42 * standard constructor 43 43 */ 44 OBBTreeNode::OBBTreeNode (const OBBTree * tree)44 OBBTreeNode::OBBTreeNode (const OBBTree& tree, unsigned int depth) 45 45 : BVTreeNode() 46 46 { 47 47 this->setClassID(CL_OBB_TREE_NODE, "OBBTreeNode"); 48 this->obbTree = tree; 48 49 this->obbTree = &tree; 50 this->depth = depth; 51 49 52 this->nodeLeft = NULL; 50 53 this->nodeRight = NULL; 51 54 this->bvElement = NULL; 55 52 56 this->tmpVert1 = NULL; 53 57 this->tmpVert2 = NULL; … … 75 79 OBBTreeNode_sphereObj = gluNewQuadric(); 76 80 } 77 78 81 79 82 /** … … 117 120 118 121 PRINTF(3)("OBB Depth: %i, tree index: %i, numVertices: %i\n", depth, treeIndex, length); 122 printf("OBBTreeNode::spawnBVTree()\n"); 119 123 this->depth = depth; 120 124 … … 132 136 if( likely( this->depth > 0)) 133 137 { 134 this->forkBox(*this->bvElement);138 //this->forkBox(*this->bvElement); 135 139 136 140 … … 170 174 void OBBTreeNode::spawnBVTree(const int depth, const sVec3D *verticesList, unsigned int length) 171 175 { 172 // PRINT (3)("\n");176 // PRINTF(3)("\n"); 173 177 // PRINTF(3)("OBB Depth: %i, tree index: %i, numVertices: %i\n", depth, treeIndex, length); 174 178 // this->depth = depth; … … 239 243 for( int i = 0; i < length ; ++i) 240 244 { 241 sVec3D* a = (sVec3D*)(&modelInf.pVertices[modelInf.pTriangles[i].indexToVertices[0]]); 242 p = *a; 243 p.debug(); 244 //q = modelInf.pVertices[modelInf.pTriangles[i][1]]; //verticesList[i + 1]; 245 //r = modelInf.pVertices[modelInf.pTriangles[i][2]]; //verticesList[i + 2]; 246 245 tmpVec = (sVec3D*)(&modelInf.pVertices[modelInf.pTriangles[triangleIndexes[i]].indexToVertices[0]]); 246 p = *tmpVec; 247 tmpVec = (sVec3D*)(&modelInf.pVertices[modelInf.pTriangles[triangleIndexes[i]].indexToVertices[1]]); 248 q = *tmpVec; 249 tmpVec = (sVec3D*)(&modelInf.pVertices[modelInf.pTriangles[triangleIndexes[i]].indexToVertices[2]]); 250 r = *tmpVec; 251 252 /* finding the facelet surface via cross-product */ 247 253 t1 = p - q; t2 = p - r; 248 249 /* finding the facelet surface via cross-product */250 254 facelet[i] = 0.5f * fabs( t1.cross(t2).len() ); 251 255 /* update the entire convex hull surface */ … … 270 274 for( int i = 0; i + 3 < length; i+=3) 271 275 { 272 p = verticesList[i]; 273 q = verticesList[i + 1]; 274 r = verticesList[i + 2]; 276 tmpVec = (sVec3D*)(&modelInf.pVertices[modelInf.pTriangles[triangleIndexes[i]].indexToVertices[0]]); 277 p = *tmpVec; 278 tmpVec = (sVec3D*)(&modelInf.pVertices[modelInf.pTriangles[triangleIndexes[i]].indexToVertices[1]]); 279 q = *tmpVec; 280 tmpVec = (sVec3D*)(&modelInf.pVertices[modelInf.pTriangles[triangleIndexes[i]].indexToVertices[2]]); 281 r = *tmpVec; 282 275 283 276 284 covariance[j][k] = facelet[i] / (12.0f * face) * (9.0f * centroid[i][j] * centroid[i][k] + p[j] * p[k] + … … 286 294 PRINTF(3)(" Vertex[%i]: %f, %f, %f\n", i, box.vertices[i][0], box.vertices[i][1], box.vertices[i][2]); 287 295 PRINTF(3)("\nOBB Covariance Matrix:\n"); 288 for(int j = 0; j < 3; ++j) { PRINT (3)(" |"); for(int k = 0; k < 3; ++k) { PRINT(3)(" \b%f ", covariance[j][k]); } PRINT(3)(" |\n"); }296 for(int j = 0; j < 3; ++j) { PRINTF(3)(" |"); for(int k = 0; k < 3; ++k) { PRINTF(3)(" \b%f ", covariance[j][k]); } PRINTF(3)(" |\n"); } 289 297 PRINTF(3)("OBB Center: %f, %f, %f\n", center.x, center.y, center.z); 290 298 … … 357 365 void OBBTreeNode::calculateBoxAxis(OBB& box, const modelInfo& modInfo, const int* triangleIndexes, unsigned int length) 358 366 { 359 this->calculateBoxAxis(box, (const sVec3D*)modInfo.pVertices, modInfo.numVertices);367 //this->calculateBoxAxis(box, (const sVec3D*)modInfo.pVertices, modInfo.numVertices); 360 368 } 361 369 … … 597 605 PRINTF(3)("collideWith\n"); 598 606 /* if the obb overlap, make subtests: check which node is realy overlaping */ 599 PRINT (3)("Checking OBB %i vs %i: ", this->getIndex(), treeNode->getIndex());607 PRINTF(3)("Checking OBB %i vs %i: ", this->getIndex(), treeNode->getIndex()); 600 608 if( unlikely(treeNode == NULL)) return; 601 609 … … 607 615 if( likely( this->nodeLeft != NULL)) 608 616 { 609 PRINT (3)("Checking OBB %i vs %i: ", this->nodeLeft->getIndex(), treeNode->getIndex());617 PRINTF(3)("Checking OBB %i vs %i: ", this->nodeLeft->getIndex(), treeNode->getIndex()); 610 618 if( this->overlapTest(this->nodeLeft->bvElement, ((OBBTreeNode*)treeNode)->bvElement, nodeA, nodeB)) 611 619 { … … 617 625 if( likely( this->nodeRight != NULL)) 618 626 { 619 PRINT (3)("Checking OBB %i vs %i: ", this->nodeRight->getIndex(), treeNode->getIndex());627 PRINTF(3)("Checking OBB %i vs %i: ", this->nodeRight->getIndex(), treeNode->getIndex()); 620 628 if(this->overlapTest(this->nodeRight->bvElement, ((OBBTreeNode*)treeNode)->bvElement, nodeA, nodeB)) 621 629 { … … 691 699 if( (rA + rB) < fabs(t.dot(l))) 692 700 { 693 PRINT (3)("no Collision\n");701 PRINTF(3)("no Collision\n"); 694 702 return false; 695 703 } … … 715 723 if( (rA + rB) < fabs(t.dot(l))) 716 724 { 717 PRINT (3)("no Collision\n");725 PRINTF(3)("no Collision\n"); 718 726 return false; 719 727 } … … 743 751 if( (rA + rB) < fabs(t.dot(l))) 744 752 { 745 PRINT (3)("keine Kollision\n");753 PRINTF(3)("keine Kollision\n"); 746 754 return false; 747 755 } … … 752 760 boxA->bCollided = true; /* use this ONLY(!!!!) for drawing operations */ 753 761 boxB->bCollided = true; 754 PRINT (3)("Kollision!\n");762 PRINTF(3)("Kollision!\n"); 755 763 return true; 756 764 } -
branches/collision_detection/src/lib/collision_detection/obb_tree_node.h
r5712 r5713 25 25 26 26 public: 27 OBBTreeNode(const OBBTree* tree); 28 OBBTreeNode(const OBBTree* tree, bool bRoot); 27 OBBTreeNode(const OBBTree& tree, unsigned int depth); 29 28 virtual ~OBBTreeNode(); 30 29 -
branches/collision_detection/src/world_entities/world_entity.cc
r5684 r5713 119 119 { 120 120 PRINTF(4)("creating obb tree\n"); 121 122 123 this->obbTree = new OBBTree(depth, (sVec3D*)this->model->getVertexArray(), this->model->getVertexCount()); 121 122 123 //this->obbTree = new OBBTree(depth, (sVec3D*)this->model->getVertexArray(), this->model->getVertexCount()); 124 this->obbTree = new OBBTree(depth, *model->getModelInfo()); 124 125 return true; 125 126 }
Note: See TracChangeset
for help on using the changeset viewer.