Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 4614 in orxonox.OLD for orxonox/trunk/src/lib/collision_detection


Ignore:
Timestamp:
Jun 13, 2005, 12:57:53 AM (20 years ago)
Author:
patrick
Message:

orxonox/trunk: now the obb tree is build as it should

Location:
orxonox/trunk/src/lib/collision_detection
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/src/lib/collision_detection/obb_tree_node.cc

    r4613 r4614  
    6464/**
    6565   \brief creates a new BVTree or BVTree partition
    66    \param depth: the depth of the tree
     66   \param depth: how much more depth-steps to go: if == 1 don't go any deeper!
    6767   \param verticesList: the list of vertices of the object - each vertices triple is interpreted as a triangle
    6868*/
    6969void OBBTreeNode::spawnBVTree(const int depth, sVec3D *verticesList, const int length)
    7070{
    71   this->bvElement = this->createBox();
    72   this->calculateBoxAttributes(this->bvElement, verticesList, length);
    73   this->forkBox(this->bvElement);
     71  this->depth = depth;
     72
     73  if( likely( this->depth > 0))
     74  {
     75    this->bvElement = this->createBox();
     76    this->calculateBoxAttributes(this->bvElement, verticesList, length);
     77    this->forkBox(this->bvElement);
     78  }
    7479}
    7580
     
    366371  }
    367372
     373  /* now spawn the obb tree: create the nodes and descent */
     374  OBBTreeNode*       node1 = new OBBTreeNode();
     375  OBBTreeNode*       node2 = new OBBTreeNode();
     376
     377  this->nodeLeft = node1;
     378  this->nodeRight = node2;
     379
     380  this->nodeLeft->spawnBVTree(this->depth - 1, vertList1, partition1.getSize());
     381  this->nodeRight->spawnBVTree(this->depth - 1, vertList2, partition2.getSize());
    368382}
    369383
  • orxonox/trunk/src/lib/collision_detection/obb_tree_node.h

    r4568 r4614  
    1 /*! 
     1/*!
    22    \file bv_tree.h
    33    \brief Definition of a bounding volume tree
    44
    5 */
     5 */
    66
    77#ifndef _OBB_TREE_NODE_H
     
    2121
    2222
    23  public:
    24   OBBTreeNode();
    25   virtual ~OBBTreeNode();
     23  public:
     24    OBBTreeNode();
     25    virtual ~OBBTreeNode();
    2626
    27   virtual void spawnBVTree(const int depth, sVec3D *verticesList, const int length);
     27    virtual void spawnBVTree(const int depth, sVec3D *verticesList, const int length);
    2828
    29   BoundingVolume* getBV(int index) const { return (BoundingVolume*)this->bvElement; }
    30   inline const int getIndex() { return this->treeIndex; } 
     29    BoundingVolume* getBV(int index) const { return (BoundingVolume*)this->bvElement; }
     30    inline const int getIndex() { return this->treeIndex; }
    3131
    32   virtual void collideWith(const BVTree &tree);
     32    virtual void collideWith(const BVTree &tree);
    3333
    34   virtual void drawBV(int currentDepth, const int depth) const;
    35   virtual void drawBVPolygon(int currentDepth, const int depth) const;
    36   virtual void drawBVBlended(int currentDepth, const int depth) const;
     34    virtual void drawBV(int currentDepth, const int depth) const;
     35    virtual void drawBVPolygon(int currentDepth, const int depth) const;
     36    virtual void drawBVBlended(int currentDepth, const int depth) const;
    3737
    38   void debug();
     38    void debug();
    3939
    40  private:
    41   OBB* createBox();
    42   void calculateBoxAttributes(OBB* box, sVec3D* verticesList, int length);
    43   void forkBox(OBB* box);
    44  
    45 
    46  protected:
    47   OBB* bvElement;
    48   OBBTreeNode* nodeLeft;
    49   OBBTreeNode* nodeRight;
     40  private:
     41    OBB* createBox();
     42    void calculateBoxAttributes(OBB* box, sVec3D* verticesList, int length);
     43    void forkBox(OBB* box);
    5044
    5145
    52  private:
    53   unsigned int        treeIndex;                  //!< Index number of the BV in the tree
    54   sVec3D*             vertices;                   //!< pointer to the vertices data
    55   int                 numOfVertices;              //!< number of vertices in vertices data
     46  protected:
     47    OBB* bvElement;                                 //!< the obb element
     48    OBBTreeNode* nodeLeft;                          //!< ref to the left tree node
     49    OBBTreeNode* nodeRight;                         //!< ref to the right tree node
     50
     51
     52  private:
     53    unsigned int        treeIndex;                  //!< Index number of the BV in the tree
     54    sVec3D*             vertices;                   //!< pointer to the vertices data
     55    int                 numOfVertices;              //!< number of vertices in vertices data
     56    int                 depth;                      //!< the depth of the node in the tree
    5657
    5758};
Note: See TracChangeset for help on using the changeset viewer.