Changeset 4898 in orxonox.OLD for orxonox/trunk/src/lib/graphics/spatial_separation/quadtree_node.cc
- Timestamp:
- Jul 19, 2005, 9:59:28 PM (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/src/lib/graphics/spatial_separation/quadtree_node.cc
r4897 r4898 30 30 const float* pVertices, int numVertices, 31 31 Quadtree* quadtree, QuadtreeNode* parent, 32 Rectangle* rect 32 Rectangle* rect, int treeDepth, const int maxDepth 33 33 ) 34 34 { … … 41 41 this->parent = parent; 42 42 this->pDimension = rect; 43 this->treeDepth = treeDepth; 44 this->maxDepth = maxDepth; 45 46 47 /* debug output */ 48 for( int i = 0; i < this->treeDepth; ++i) 49 PRINT(3)(" |"); 50 PRINT(3)(" | +-| (Event) Separating Node Depth: %i/%i\n", treeDepth, maxDepth); 51 52 for( int i = 0; i < this->treeDepth; ++i) 53 PRINT(3)(" |"); 54 PRINT(3)(" | +-| (II) Rectangle Center (%5.2f, %5.2f), half axis length: %5.2f\n", 55 this->pDimension->getCenter()->x, this->pDimension->getCenter()->z, this->pDimension->getAxis()); 43 56 44 57 this->init(); … … 49 62 * standard constructor 50 63 */ 51 QuadtreeNode::QuadtreeNode(modelInfo* pModelInfo )64 QuadtreeNode::QuadtreeNode(modelInfo* pModelInfo, const int maxDepth) 52 65 { 53 66 this->pModelInfo = pModelInfo; … … 61 74 this->pTriangles[i] = &this->pModelInfo->pTriangles[i]; 62 75 this->treeDepth = 0; 76 this->maxDepth = maxDepth; 77 78 /* debug output */ 79 for( int i = 0; i < this->treeDepth; ++i) 80 PRINT(3)(" |"); 81 PRINT(3)(" | +-| (Event) Separating Node Depth: %i/%i\n", treeDepth, maxDepth); 63 82 64 83 this->pDimension = this->getDimFromModel(); … … 80 99 this->nodeC = NULL; 81 100 this->nodeD = NULL; 101 102 this->separateNode(this->treeDepth, this->maxDepth); 82 103 } 83 104 … … 105 126 void QuadtreeNode::separateNode(int treeDepth, const int maxDepth) 106 127 { 107 this->treeDepth = treeDepth; 108 /* debug output */ 109 for( int i = 0; i < treeDepth; ++i) 110 PRINT(3)(" |"); 111 PRINT(3)(" | +-| (Event) Separating Node Depth: %i/%i\n", treeDepth, maxDepth); 128 112 129 113 130 /* dimension calculation & limit checking */ … … 118 135 /* node separation */ 119 136 this->separateNode(); 120 this->nodeA->separateNode(treeDepth + 1, maxDepth); 121 this->nodeB->separateNode(treeDepth + 1, maxDepth); 122 this->nodeC->separateNode(treeDepth + 1, maxDepth); 123 this->nodeD->separateNode(treeDepth + 1, maxDepth); 137 138 // this->nodeA->separateNode(treeDepth + 1, maxDepth); 139 // this->nodeB->separateNode(treeDepth + 1, maxDepth); 140 // this->nodeC->separateNode(treeDepth + 1, maxDepth); 141 // this->nodeD->separateNode(treeDepth + 1, maxDepth); 124 142 } 125 143 … … 252 270 Vector v; 253 271 254 v.x = this-> center.x + this->pDimension->getAxis() / 2.0f;255 v.z = this-> center.z + this->pDimension->getAxis() / 2.0f;272 v.x = this->pDimension->getCenter()->x + this->pDimension->getAxis() / 2.0f; 273 v.z = this->pDimension->getCenter()->z + this->pDimension->getAxis() / 2.0f; 256 274 Rectangle* rA = new Rectangle(v, this->pDimension->getAxis() / 2.0f); 257 275 258 v.z = this-> center.z - this->pDimension->getAxis() / 2.0f;276 v.z = this->pDimension->getCenter()->z - this->pDimension->getAxis() / 2.0f; 259 277 Rectangle* rB = new Rectangle(v, this->pDimension->getAxis() / 2.0f); 260 278 261 v.x = this-> center.x - this->pDimension->getAxis() / 2.0f;279 v.x = this->pDimension->getCenter()->x - this->pDimension->getAxis() / 2.0f; 262 280 Rectangle* rC = new Rectangle(v, this->pDimension->getAxis() / 2.0f); 263 281 264 v.z = this-> center.z + this->pDimension->getAxis() / 2.0f;282 v.z = this->pDimension->getCenter()->z + this->pDimension->getAxis() / 2.0f; 265 283 Rectangle* rD = new Rectangle(v, this->pDimension->getAxis() / 2.0f); 266 284 267 285 /* now propagate */ 268 this->nodeA = new QuadtreeNode(pTriA, lenA, this->pVertices, this->numVertices, this->quadtree, this, rA );269 this->nodeB = new QuadtreeNode(pTriB, lenB, this->pVertices, this->numVertices, this->quadtree, this, rB );270 this->nodeC = new QuadtreeNode(pTriC, lenC, this->pVertices, this->numVertices, this->quadtree, this, rC );271 this->nodeD = new QuadtreeNode(pTriD, lenD, this->pVertices, this->numVertices, this->quadtree, this, rD );286 this->nodeA = new QuadtreeNode(pTriA, lenA, this->pVertices, this->numVertices, this->quadtree, this, rA, this->treeDepth + 1, this->maxDepth); 287 this->nodeB = new QuadtreeNode(pTriB, lenB, this->pVertices, this->numVertices, this->quadtree, this, rB, this->treeDepth + 1, this->maxDepth); 288 this->nodeC = new QuadtreeNode(pTriC, lenC, this->pVertices, this->numVertices, this->quadtree, this, rC, this->treeDepth + 1, this->maxDepth); 289 this->nodeD = new QuadtreeNode(pTriD, lenD, this->pVertices, this->numVertices, this->quadtree, this, rD, this->treeDepth + 1, this->maxDepth); 272 290 } 273 291
Note: See TracChangeset
for help on using the changeset viewer.