Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jul 19, 2005, 10:28:36 PM (19 years ago)
Author:
patrick
Message:

orxonox/trunk: the separation now works correctly again. tree index introduced

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

Legend:

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

    r4898 r4900  
    1212#include "abstract_model.h"
    1313
     14
    1415class QuadtreeNode;
     16class Material;
    1517
    1618//! A class for quadtree separation of the world
  • orxonox/trunk/src/lib/graphics/spatial_separation/quadtree_node.cc

    r4899 r4900  
    3030                            const float* pVertices, int numVertices,
    3131                            Quadtree* quadtree, QuadtreeNode* parent,
    32                             Rectangle* rect, int treeDepth, const int maxDepth
     32                            Rectangle* rect, int treeDepth, const int maxDepth, int index
    3333                           )
    3434{
     
    4444  this->treeDepth = treeDepth;
    4545  this->maxDepth = maxDepth;
     46  this->indexNode = index;
    4647
    4748
     
    4950  for( int i = 0; i < this->treeDepth; ++i)
    5051    PRINT(3)(" |");
    51   PRINT(3)(" | +-| (Event) Separating Node Depth: %i/%i\n", treeDepth, maxDepth);
     52  PRINT(3)(" | +-| (Event) Separating Node Nr. %i Depth: %i/%i\n", this->indexNode, treeDepth, maxDepth);
    5253
    5354  for( int i = 0; i < this->treeDepth; ++i)
     
    7475  for( int i = 0; i < this->pModelInfo->numTriangles; ++i)
    7576    this->pTriangles[i] = &this->pModelInfo->pTriangles[i];
     77
    7678  this->treeDepth = 0;
    7779  this->maxDepth = maxDepth;
     80  this->indexNode = 0;
    7881
    7982  /* debug output */
    8083  for( int i = 0; i < this->treeDepth; ++i)
    8184    PRINT(3)(" |");
    82   PRINT(3)(" | +-| (Event) Separating Node Depth: %i/%i\n", treeDepth, maxDepth);
     85  PRINT(3)(" | +-| (Event) Separating Node Nr. %i Depth: %i/%i\n", this->indexNode, treeDepth, maxDepth);
    8386
    8487  this->pDimension = this->getDimFromModel();
     
    164167          if( pVert[0] > rectCenter->x + this->offset && pVert[2] > rectCenter->z + this->offset)
    165168            listA->add(&this->pTriangles[i]);
    166           if( pVert[0] > rectCenter->x + this->offset && pVert[2]< rectCenter->z + this->offset)
     169          if( pVert[0] < rectCenter->x + this->offset && pVert[2] > rectCenter->z + this->offset)
    167170            listB->add(&this->pTriangles[i]);
    168           if( pVert[0] < rectCenter->x + this->offset && pVert[2] > rectCenter->z + this->offset)
     171          if( pVert[0] < rectCenter->x + this->offset && pVert[2] < rectCenter->z + this->offset)
    169172            listC->add(&this->pTriangles[i]);
    170           if( pVert[0] < rectCenter->x + this->offset && pVert[2] < rectCenter->z + this->offset)
     173          if( pVert[0] > rectCenter->x + this->offset && pVert[2] < rectCenter->z + this->offset)
    171174            listD->add(&this->pTriangles[i]);
    172175        }
     
    252255
    253256  v.x = this->pDimension->getCenter()->x + this->pDimension->getAxis() / 2.0f;
     257  v.y = 0.0;
    254258  v.z = this->pDimension->getCenter()->z + this->pDimension->getAxis() / 2.0f;
    255259  Rectangle* rA = new Rectangle(v, this->pDimension->getAxis() / 2.0f);
     
    265269
    266270  /* now propagate */
    267   this->nodeA = new QuadtreeNode(pTriA, lenA, this->pVertices, this->numVertices, this->quadtree, this, rA, this->treeDepth + 1, this->maxDepth);
    268   this->nodeB = new QuadtreeNode(pTriB, lenB, this->pVertices, this->numVertices, this->quadtree, this, rB, this->treeDepth + 1, this->maxDepth);
    269   this->nodeC = new QuadtreeNode(pTriC, lenC, this->pVertices, this->numVertices, this->quadtree, this, rC, this->treeDepth + 1, this->maxDepth);
    270   this->nodeD = new QuadtreeNode(pTriD, lenD, this->pVertices, this->numVertices, this->quadtree, this, rD, this->treeDepth + 1, this->maxDepth);
     271  this->nodeA = new QuadtreeNode(pTriA, lenA, this->pVertices, this->numVertices, this->quadtree, this, rA, this->treeDepth + 1, this->maxDepth, (this->treeDepth + 1) * 10 + 0);
     272
     273  this->nodeB = new QuadtreeNode(pTriB, lenB, this->pVertices, this->numVertices, this->quadtree, this, rB, this->treeDepth + 1, this->maxDepth, (this->treeDepth + 1) * 10 + 1);
     274
     275  this->nodeC = new QuadtreeNode(pTriC, lenC, this->pVertices, this->numVertices, this->quadtree, this, rC, this->treeDepth + 1, this->maxDepth, (this->treeDepth + 1) * 10 + 2);
     276
     277  this->nodeD = new QuadtreeNode(pTriD, lenD, this->pVertices, this->numVertices, this->quadtree, this, rD, this->treeDepth + 1, this->maxDepth, (this->treeDepth + 1) * 10 + 3);
    271278}
    272279
  • orxonox/trunk/src/lib/graphics/spatial_separation/quadtree_node.h

    r4899 r4900  
    2323                 const float* pVertices, int numVertices,
    2424                 Quadtree* quadtree, QuadtreeNode* parent,
    25                  Rectangle* rect, int treeDepth, const int maxDepth);
     25                 Rectangle* rect, int treeDepth, const int maxDepth, int index);
    2626    QuadtreeNode(modelInfo* pModelInfo, const int maxDepth);
    2727    virtual ~QuadtreeNode();
     
    5454    int                             treeDepth;          //!< the depth of the tree
    5555    int                             maxDepth;           //!< the maximal depth of the tree
     56    int                             indexNode;          //!< the index number of the node
    5657
    5758    sTriangleExt**                  pTriangles;         //!< reference to the triangles of the node
Note: See TracChangeset for help on using the changeset viewer.