Changeset 6657 in orxonox.OLD for branches/cd_merge/src/lib/collision_detection/obb_tree.cc
- Timestamp:
- Jan 23, 2006, 2:25:13 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/cd_merge/src/lib/collision_detection/obb_tree.cc
r5684 r6657 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" … … 31 31 * standard constructor 32 32 */ 33 OBBTree::OBBTree () 33 OBBTree::OBBTree(int depth, const modelInfo& modelInf) 34 : BVTree() 34 35 { 36 this->depth = depth; 35 37 this->init(); 36 } 37 38 OBBTree::OBBTree(int depth, sVec3D *verticesList, const int length) 39 { 40 this->init(); 41 this->spawnBVTree(depth, verticesList, length); 42 } 43 44 OBBTree::OBBTree(int depth, const modelInfo& modInfo) 45 { 46 this->init(); 47 this->spawnBVTree(depth, modInfo); 38 this->spawnBVTree(modelInf); 48 39 } 49 40 … … 53 44 { 54 45 this->setClassID(CL_OBB_TREE, "OBBTree"); 55 56 46 this->rootNode = NULL; 57 58 47 this->id = 0; 59 48 } … … 69 58 70 59 71 void OBBTree::spawnBVTree(int depth, sVec3D *verticesList, const int length) 72 { 73 if( unlikely(this->rootNode != NULL)) 74 { 75 PRINTF(2)("The BVTree has already been spawned, flushing and respawning again...\n"); 76 this->flushTree(); 77 } 78 OBBTreeNode* node = new OBBTreeNode(); 79 this->rootNode = node; 80 this->rootNode->setTreeRef(this); 81 this->rootNode->spawnBVTree(--depth, verticesList, length); 82 } 83 84 85 void OBBTree::spawnBVTree(int depth, const modelInfo& modInfo) 60 /** 61 * this function creates a bv tree out of a modelInf structure 62 * @param modelInf the model info of a model (modelInfo), containing vertices, triangle and normal infos 63 */ 64 void OBBTree::spawnBVTree(const modelInfo& modelInf) 86 65 { 87 66 if( unlikely(this->rootNode != NULL)) … … 90 69 this->flushTree(); 91 70 } 92 OBBTreeNode* node = new OBBTreeNode(); 93 this->rootNode = node; 94 this->rootNode->setTreeRef(this); 95 this->rootNode->spawnBVTree(--depth, modInfo); 71 this->rootNode = new OBBTreeNode(*this, NULL, depth-1); 72 73 /* triangles indexes created */ 74 int* triangleIndexes = new int[modelInf.numTriangles]; 75 for( int i = 0; i < modelInf.numTriangles; ++i) 76 triangleIndexes[i] = i; 77 78 this->rootNode->spawnBVTree(modelInf, triangleIndexes, modelInf.numTriangles); 96 79 } 97 80 98 81 82 /** 83 * release the current bv tree if any 84 */ 99 85 void OBBTree:: flushTree() 100 86 {} 101 87 102 88 103 void OBBTree::collideWith(WorldEntity* entity1, WorldEntity* entity2) 89 /** 90 * this collides two bvtrees together. the trees are attached to pnodes Objects A and B 91 * @param nodeA: PNode of object A 92 * @param nodeB: Pnode of object B 93 */ 94 void OBBTree::collideWith(const WorldEntity& entity1, const WorldEntity& entity2) const 104 95 { 105 if( likely(entity2 ->getOBBTree() != NULL) )106 this->rootNode->collideWith( ((OBBTree*)entity2->getOBBTree())->getRootNode(), entity1, entity2);96 if( likely(entity2.getOBBTree() != NULL) ) 97 this->rootNode->collideWith(*(((OBBTree*)entity2.getOBBTree())->getRootNode()), entity1, entity2); 107 98 } 108 99 109 100 110 101 /** 111 * this collides two bvtrees together. the trees are attached to pnodes Objects A and B 112 * @param tree: the other tree to collide with (Object B) 113 * @param nodeA: PNode of object A 114 * @param nodeB: Pnode of object B 102 * draw bv tree 115 103 */ 116 void OBBTree::collideWith(BVTree* tree, WorldEntity* nodeA, WorldEntity* nodeB)117 {118 this->rootNode->collideWith(((OBBTree*)tree)->getRootNode(), nodeA, nodeB);119 }120 121 122 104 void OBBTree::drawBV(int depth, int drawMode) const 123 105 { … … 129 111 130 112 131 113 /** 114 * some debug output and creation function 115 * 116 * doesn't work at the moment 117 */ 132 118 void OBBTree::debug() 133 119 { … … 153 139 } 154 140 155 this->spawnBVTree(3,vertList, length);141 // this->spawnBVTree(vertList, length); 156 142 157 143 PRINT(0)("= Spawning Tree: Finished\n");
Note: See TracChangeset
for help on using the changeset viewer.