- Timestamp:
- Nov 21, 2005, 10:33:42 PM (19 years ago)
- Location:
- trunk/src
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/collision_detection/bv_tree.h
r5481 r5684 40 40 41 41 virtual void spawnBVTree(int depth, sVec3D *verticesList, const int length) = 0; 42 virtual void spawnBVTree(int depth, const modelInfo& modInfo) = 0; 42 43 virtual void flushTree() = 0; 43 44 -
trunk/src/lib/collision_detection/bv_tree_node.h
r5481 r5684 27 27 28 28 virtual void spawnBVTree(const int depth, sVec3D *verticesList, const int length ) = 0; 29 virtual void spawnBVTree(const int depth, const modelInfo& modInfo) = 0; 29 30 30 31 virtual BoundingVolume* getBV(int index) const = 0; -
trunk/src/lib/collision_detection/obb_tree.cc
r5481 r5684 42 42 } 43 43 44 OBBTree::OBBTree(int depth, const modelInfo& modInfo) 45 { 46 this->init(); 47 this->spawnBVTree(depth, modInfo); 48 } 49 44 50 45 51 … … 74 80 this->rootNode->setTreeRef(this); 75 81 this->rootNode->spawnBVTree(--depth, verticesList, length); 82 } 83 84 85 void OBBTree::spawnBVTree(int depth, const modelInfo& modInfo) 86 { 87 if( unlikely(this->rootNode != NULL)) 88 { 89 PRINTF(2)("The BVTree has already been spawned, flushing and respawning again...\n"); 90 this->flushTree(); 91 } 92 OBBTreeNode* node = new OBBTreeNode(); 93 this->rootNode = node; 94 this->rootNode->setTreeRef(this); 95 this->rootNode->spawnBVTree(--depth, modInfo); 76 96 } 77 97 -
trunk/src/lib/collision_detection/obb_tree.h
r5481 r5684 22 22 OBBTree(); 23 23 OBBTree(int depth, sVec3D *verticesList, const int length); 24 OBBTree(int depth, const modelInfo& modInfo); 24 25 virtual ~OBBTree(); 25 26 void init(); 26 27 27 28 virtual void spawnBVTree(int depth, sVec3D *verticesList, const int length); 29 virtual void spawnBVTree(int depth, const modelInfo& modInfo); 28 30 virtual void flushTree(); 29 31 -
trunk/src/lib/collision_detection/obb_tree_node.cc
r5678 r5684 96 96 97 97 98 /** 99 * creates a new BVTree or BVTree partition 100 * @param depth: how much more depth-steps to go: if == 1 don't go any deeper! 101 * @param modInfo: model informations from the abstrac model 102 * 103 * this function creates the Bounding Volume tree from a modelInfo struct and bases its calculations 104 * on the triangle informations (triangle soup not polygon soup) 105 */ 106 void OBBTreeNode::spawnBVTree(const int depth, const modelInfo& modInfo) 107 { 108 int length = 0; 109 sVec3D* verticesList; 110 111 PRINT(3)("\n"); 112 this->treeIndex = this->obbTree->getID(); 113 PRINTF(3)("OBB Depth: %i, tree index: %i, numVertices: %i\n", depth, treeIndex, length); 114 this->depth = depth; 115 116 117 this->bvElement = new OBB(); 118 this->bvElement->vertices = verticesList; 119 this->bvElement->numOfVertices = length; 120 PRINTF(3)("Created OBBox\n"); 121 this->calculateBoxCovariance(this->bvElement, modInfo); 122 PRINTF(3)("Calculated attributes1\n"); 123 this->calculateBoxEigenvectors(this->bvElement, modInfo); 124 PRINTF(3)("Calculated attributes2\n"); 125 this->calculateBoxAxis(this->bvElement,modInfo); 126 PRINTF(3)("Calculated attributes3\n"); 127 128 /* if this is the first node, the vertices data are the original ones of the model itself, so dont delete them in cleanup */ 129 if( this->treeIndex == 1) 130 this->bvElement->bOrigVertices = true; 131 132 if( likely( this->depth > 0)) 133 { 134 this->forkBox(this->bvElement); 135 136 137 // if(this->tmpLen1 > 2) 138 // { 139 // OBBTreeNode* node1 = new OBBTreeNode(); 140 // this->nodeLeft = node1; 141 // this->nodeLeft->spawnBVTree(depth - 1, this->tmpVert1, this->tmpLen1); 142 // } 143 // else 144 // { 145 // PRINTF(3)("Aboarding tree walk: less than 3 vertices left\n"); 146 // } 147 // 148 // if( this->tmpLen2 > 2) 149 // { 150 // OBBTreeNode* node2 = new OBBTreeNode(); 151 // this->nodeRight = node2; 152 // this->nodeRight->spawnBVTree(depth - 1, this->tmpVert2, this->tmpLen2); 153 // } 154 // else 155 // { 156 // PRINTF(3)("Abording tree walk: less than 3 vertices left\n"); 157 // } 158 159 } 160 } 161 98 162 99 163 /** … … 101 165 * @param depth: how much more depth-steps to go: if == 1 don't go any deeper! 102 166 * @param verticesList: the list of vertices of the object - each vertices triple is interpreted as a triangle 167 * 168 * this function creates an Bounding Volume tree from a vertices soup (no triangle data) 103 169 */ 104 170 void OBBTreeNode::spawnBVTree(const int depth, sVec3D *verticesList, const int length) … … 151 217 PRINTF(3)("Abording tree walk: less than 3 vertices left\n"); 152 218 } 153 154 } 155 } 156 219 } 220 } 221 222 223 void OBBTreeNode::calculateBoxCovariance(OBB* box, const modelInfo& modInfo) 224 {} 157 225 158 226 … … 346 414 347 415 416 void OBBTreeNode::calculateBoxEigenvectors(OBB* box, const modelInfo& modInfo) 417 {} 348 418 349 419 void OBBTreeNode::calculateBoxEigenvectors(OBB* box, sVec3D* verticesList, int length) … … 394 464 // PRINTF(0)("eigenvector: %f, %f, %f\n", box->axis[2].x, box->axis[2].y, box->axis[2].z); 395 465 } 466 467 468 void OBBTreeNode::calculateBoxAxis(OBB* box, const modelInfo& modInfo) 469 {} 396 470 397 471 -
trunk/src/lib/collision_detection/obb_tree_node.h
r5481 r5684 29 29 30 30 virtual void spawnBVTree(const int depth, sVec3D *verticesList, const int length); 31 virtual void spawnBVTree(const int depth, const modelInfo& modInfo); 31 32 32 33 BoundingVolume* getBV(int index) const { return (BoundingVolume*)this->bvElement; } … … 44 45 void calculateBoxEigenvectors(OBB* box, sVec3D* verticesList, int length); 45 46 void calculateBoxAxis(OBB* box, sVec3D* verticesList, int length); 47 48 void calculateBoxCovariance(OBB* box, const modelInfo& modInfo); 49 void calculateBoxEigenvectors(OBB* box, const modelInfo& modInfo); 50 void calculateBoxAxis(OBB* box, const modelInfo& modInfo); 51 52 46 53 void forkBox(OBB* box); 47 54 -
trunk/src/world_entities/world_entity.cc
r5676 r5684 119 119 { 120 120 PRINTF(4)("creating obb tree\n"); 121 121 122 122 123 this->obbTree = new OBBTree(depth, (sVec3D*)this->model->getVertexArray(), this->model->getVertexCount());
Note: See TracChangeset
for help on using the changeset viewer.