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