Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 4914 in orxonox.OLD for orxonox/trunk/src/lib/graphics


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

orxonox/trunk: the hashing function now works perfect

Location:
orxonox/trunk/src/lib/graphics/spatial_separation
Files:
3 edited

Legend:

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

    r4913 r4914  
    5252   int* index = new int; *index = 0;
    5353   for(int i = 0; i < (int)pow(2, treeDepth); ++i)
     54   {
     55     printf("============================\n");
    5456     this->rootNode->buildHashTable(this->nodes, index);
     57   }
    5558}
    5659
     
    7477{
    7578  //this->rootNode->drawTree(depth, drawMode);
    76   for(int i = 0; i < 4; ++i)
     79  for(int i = 0; i < (int)pow(4, this->treeDepth); ++i)
    7780  {
    7881    this->nodes[i]->drawTree(0, 0);
  • 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
  • orxonox/trunk/src/lib/graphics/spatial_separation/spatial_separation.cc

    r4913 r4914  
    9999Quadtree* SpatialSeparation::createQuadtree(AbstractModel* model)
    100100{
    101   this->quadtree = new Quadtree(model->getModelInfo(), 1);
     101  this->quadtree = new Quadtree(model->getModelInfo(), 4);
    102102
    103103  return this->quadtree;
Note: See TracChangeset for help on using the changeset viewer.