Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 4911 in orxonox.OLD for orxonox/trunk/src


Ignore:
Timestamp:
Jul 21, 2005, 12:09:36 AM (19 years ago)
Author:
patrick
Message:

orxonox/trunk: creating lookup table with a very fancy algorithm

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  
    5050   /* make an array with access to the leafs of the Quad-Tree */
    5151   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);
    5255}
    5356
  • orxonox/trunk/src/lib/graphics/spatial_separation/quadtree_node.cc

    r4907 r4911  
    101101
    102102  this->offset = 0.0f;
     103  this->nodeIter = 0;
    103104
    104105  this->parent = NULL;
     
    108109  this->nodeD = NULL;
    109110  this->nodes = new QuadtreeNode*[4];
     111  for(int i = 0; i < 4; ++i)
     112    this->nodes[i] = NULL;
    110113
    111114  if( this->treeDepth < this->maxDepth)
     
    127130  if( this->nodeD != NULL)
    128131    delete this->nodeD;
     132}
     133
     134
     135
     136void 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  }
    129155}
    130156
  • orxonox/trunk/src/lib/graphics/spatial_separation/quadtree_node.h

    r4907 r4911  
    2727    virtual ~QuadtreeNode();
    2828
     29    void buildHashTable(QuadtreeNode** nodeList, int* index);
     30
    2931    float getHeight(const Vector& position);
    3032
     
    4749    QuadtreeNode*                   nodeD;              //!< reference to the node D
    4850    QuadtreeNode**                  nodes;              //!< reference to the quadtree nodes
    49 
     51    int                             nodeIter;           //!< temp helping variable for the hashing algorithm
    5052
    5153  private:
Note: See TracChangeset for help on using the changeset viewer.