Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jul 21, 2005, 11:17:54 AM (19 years ago)
Author:
patrick
Message:

orxonox/trunk: the hashing function now works perfect

File:
1 edited

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/src/lib/graphics/spatial_separation/quadtree_node.cc

    r4913 r4914  
    101101
    102102  this->offset = 0.0f;
    103   this->nodeIter = 0;
     103  this->nodeIter = -1;
    104104
    105105  this->parent = NULL;
     
    136136void QuadtreeNode::buildHashTable(QuadtreeNode** nodeList, int* index)
    137137{
    138   int elCount = (int)pow(4, maxDepth - treeDepth) / 2;
    139   int loopLimit = (this->nodeIter < elCount)?2:4;
    140 
    141   for( int i = 0; i < this->treeDepth; ++i)
    142     printf(" ");
    143   printf("entering %i: hit counts: %i/%i\n", treeDepth, nodeIter, elCount);
     138  if( this->nodeIter == -1)
     139    this->nodeIter = *index;
     140
     141  /*              offset              #of elements in a row            #of rows in a quadtree          */
     142  int threshold = this->nodeIter + (int)pow(2, this->maxDepth) * (int)pow(2, maxDepth - treeDepth - 1);
     143  int loopLimit = (*index < threshold)?2:4;
    144144
    145145  /* is it a leaf? */
    146146  if( this->treeDepth < this->maxDepth)
    147   {
    148     for(int i = (this->nodeIter < elCount)?0:2; i < loopLimit; ++i)
    149     {
    150       for( int j = 0; j < this->treeDepth; ++j)
    151         printf(" ");
    152       printf("-> %i @ depth: %i, %i/%i \n", i, this->treeDepth, nodeIter, elCount);
    153 
     147    for(int i = (*index < threshold)?0:2; i < loopLimit; ++i)
    154148      this->nodes[i]->buildHashTable(nodeList, index);
    155       ++this->nodeIter;
    156     }
    157   }
    158149  else
    159   {
    160     for( int j = 0; j < this->treeDepth; ++j)
    161       printf(" ");
    162     printf("        leaf, index: %i, pointer: %p\n", *index, this);
    163150    nodeList[(*index)++] = this;
    164   }
    165151}
    166152
Note: See TracChangeset for help on using the changeset viewer.