Changeset 4911 in orxonox.OLD for orxonox/trunk/src
- Timestamp:
- Jul 21, 2005, 12:09:36 AM (19 years ago)
- Location:
- orxonox/trunk/src/lib/graphics/spatial_separation
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/src/lib/graphics/spatial_separation/quadtree.cc
r4907 r4911 50 50 /* make an array with access to the leafs of the Quad-Tree */ 51 51 this->nodes = new QuadtreeNode*[(int)pow(4, treeDepth)]; 52 int* index = new int; *index = 0; 53 for(int i = 0; i < (int)pow(2, treeDepth); ++i) 54 this->rootNode->buildHashTable(this->nodes, index); 52 55 } 53 56 -
orxonox/trunk/src/lib/graphics/spatial_separation/quadtree_node.cc
r4907 r4911 101 101 102 102 this->offset = 0.0f; 103 this->nodeIter = 0; 103 104 104 105 this->parent = NULL; … … 108 109 this->nodeD = NULL; 109 110 this->nodes = new QuadtreeNode*[4]; 111 for(int i = 0; i < 4; ++i) 112 this->nodes[i] = NULL; 110 113 111 114 if( this->treeDepth < this->maxDepth) … … 127 130 if( this->nodeD != NULL) 128 131 delete this->nodeD; 132 } 133 134 135 136 void QuadtreeNode::buildHashTable(QuadtreeNode** nodeList, int* index) 137 { 138 int loopLimit = (this->nodeIter < ((int)pow(4, maxDepth - treeDepth) / 2))?2:4; 139 140 printf("buildHashTable depth: %i, nodeIter : %i, limit: %i, @nodeIndex: %i\n", this->treeDepth, nodeIter, loopLimit, indexNode); 141 /* is it a leaf? */ 142 if( this->treeDepth < this->maxDepth) 143 { 144 for(int i = (this->nodeIter < ((int)pow(4, maxDepth - treeDepth) / 2))?0:2; i < loopLimit; ++i) 145 { 146 this->nodes[i]->buildHashTable(nodeList, index); 147 ++this->nodeIter; 148 } 149 } 150 else 151 { 152 printf("leaf, index: %i\n", *index); 153 nodeList[(*index)++] = this; 154 } 129 155 } 130 156 -
orxonox/trunk/src/lib/graphics/spatial_separation/quadtree_node.h
r4907 r4911 27 27 virtual ~QuadtreeNode(); 28 28 29 void buildHashTable(QuadtreeNode** nodeList, int* index); 30 29 31 float getHeight(const Vector& position); 30 32 … … 47 49 QuadtreeNode* nodeD; //!< reference to the node D 48 50 QuadtreeNode** nodes; //!< reference to the quadtree nodes 49 51 int nodeIter; //!< temp helping variable for the hashing algorithm 50 52 51 53 private:
Note: See TracChangeset
for help on using the changeset viewer.