Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6447 in orxonox.OLD


Ignore:
Timestamp:
Jan 9, 2006, 12:39:15 AM (18 years ago)
Author:
patrick
Message:

collision: some more debug work on the collision detection framework

Location:
branches/collision_detection/src/lib/collision_detection
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • branches/collision_detection/src/lib/collision_detection/bv_tree_node.h

    r5882 r6447  
    3434  inline const int getIndex() const { return this->treeIndex; }
    3535
    36   virtual void spawnBVTree(const modelInfo& modInfo, const int* triangleIndexes, unsigned int length) = 0;
     36  virtual void spawnBVTree(const modelInfo& modInfo, const int* triangleIndexes, int length) = 0;
    3737  virtual void collideWith(const BVTreeNode& treeNode, const WorldEntity& nodeA, const WorldEntity& nodeB) const = 0;
    3838  virtual void drawBV(int depth, int drawMode, const Vector& color = Vector(1,0,0), bool top = true) const = 0;
  • branches/collision_detection/src/lib/collision_detection/obb_tree.cc

    r5882 r6447  
    6666    this->flushTree();
    6767  }
    68   this->rootNode = new OBBTreeNode(*this, depth-1);
     68  this->rootNode = new OBBTreeNode(*this, NULL, depth-1);
    6969
    7070  /* triangles indexes created */
  • branches/collision_detection/src/lib/collision_detection/obb_tree.h

    r5882 r6447  
    3232
    3333    /** returns the next if for the obb tree node @return integer id number of the next node */
    34     const int getID() { return ++this->id;}
     34    inline const int getID() { return ++this->id;}
    3535    /** returns the root node of the bounding volume tree @return reference to the root node */
    3636    inline const OBBTreeNode* getRootNode() const { return this->rootNode; }
     
    4040  private:
    4141    OBBTreeNode*         rootNode;                        //!< reference to the root node of the tree
    42     int                  id;
     42    int                  id;                              //!< the next id of a obb tree node
    4343    int                  depth;                           //!< the depth of the tree to generate
    4444};
  • branches/collision_detection/src/lib/collision_detection/obb_tree_node.cc

    r6140 r6447  
    1111### File Specific:
    1212   main-programmer: Patrick Boenzli
    13    co-programmer: ...
    1413*/
    1514
     
    4443 * @param depth: the depth of the obb tree to generate
    4544 */
    46 OBBTreeNode::OBBTreeNode (const OBBTree& tree, unsigned int depth)
     45OBBTreeNode::OBBTreeNode (const OBBTree& tree, OBBTreeNode* prev, int depth)
    4746    : BVTreeNode()
    4847{
     
    5049
    5150  this->obbTree = &tree;
     51  this->nodePrev = prev;
    5252  this->depth = depth;
     53  this->nextID = 0;
    5354
    5455  this->nodeLeft = NULL;
     
    6465  if( OBBTreeNode_sphereObj == NULL)
    6566    OBBTreeNode_sphereObj = gluNewQuadric();
     67
     68  /* debug ids */
     69  if( this->nodePrev)
     70    this->treeIndex = 100 * this->depth + this->nodePrev->getID();
     71  else
     72    this->treeIndex = 0;
    6673}
    6774
     
    95102 * on the triangle informations (triangle soup not polygon soup)
    96103 */
    97 void OBBTreeNode::spawnBVTree(const modelInfo& modelInf, const int* triangleIndexes, unsigned int length)
     104void OBBTreeNode::spawnBVTree(const modelInfo& modelInf, const int* triangleIndexes, int length)
    98105{
    99106  PRINTF(3)("\n==============================Creating OBB Tree Node==================\n");
    100107  PRINT(3)(" OBB Tree Infos: \n");
    101   PRINT(3)("\tDepth: %i \n\tTree Index: %i \n\tNumber of Triangles: %i\n", depth, treeIndex, length);
     108  PRINT(3)("\tDepth: %i \n\tTree Index: %i \n\tNumber of Triangles: %i\n", depth, this->treeIndex, length);
    102109  this->depth = depth;
    103110
     
    107114  this->bvElement->triangleIndexesLength = length;
    108115
    109   /* create the boxes in three steps */
     116  /* create the bounding boxes in three steps */
    110117  this->calculateBoxCovariance(*this->bvElement, modelInf, triangleIndexes, length);
    111118  this->calculateBoxEigenvectors(*this->bvElement, modelInf, triangleIndexes, length);
     
    119126    if( this->triangleIndexLength1 >= 3)
    120127    {
    121       this->nodeLeft = new OBBTreeNode(*this->obbTree, depth - 1);
     128      this->nodeLeft = new OBBTreeNode(*this->obbTree, this, depth - 1);
    122129      this->nodeLeft->spawnBVTree(modelInf, this->triangleIndexList1, this->triangleIndexLength1);
    123130    }
    124131    if( this->triangleIndexLength2 >= 3)
    125132    {
    126       this->nodeRight = new OBBTreeNode(*this->obbTree, depth - 1);
     133      this->nodeRight = new OBBTreeNode(*this->obbTree, this, depth - 1);
    127134      this->nodeRight->spawnBVTree(modelInf, this->triangleIndexList2, this->triangleIndexLength2);
    128135    }
     
    139146 * @param length: the length of the indexes array
    140147 */
    141 void OBBTreeNode::calculateBoxCovariance(OBB& box, const modelInfo& modelInf, const int* triangleIndexes, unsigned int length)
     148void OBBTreeNode::calculateBoxCovariance(OBB& box, const modelInfo& modelInf, const int* triangleIndexes, int length)
    142149{
    143150  float     facelet[length];                         //!< surface area of the i'th triangle of the convex hull
     
    269276 */
    270277void OBBTreeNode::calculateBoxEigenvectors(OBB& box, const modelInfo& modelInf,
    271     const int* triangleIndexes, unsigned int length)
     278    const int* triangleIndexes, int length)
    272279{
    273280
     
    305312 * @param length: the length of the indexes array
    306313 */
    307 void OBBTreeNode::calculateBoxAxis(OBB& box, const modelInfo& modelInf, const int* triangleIndexes, unsigned int length)
     314void OBBTreeNode::calculateBoxAxis(OBB& box, const modelInfo& modelInf, const int* triangleIndexes, int length)
    308315{
    309316
     
    448455
    449456  /* find the center of the box */
    450 
    451457  this->separationPlane = Plane(box.axis[longestAxisIndex], box.center);
    452458  this->sepPlaneCenter[0] = box.center.x;
  • branches/collision_detection/src/lib/collision_detection/obb_tree_node.h

    r5882 r6447  
    2525
    2626  public:
    27     OBBTreeNode(const OBBTree& tree, unsigned int depth);
     27    OBBTreeNode(const OBBTree& tree, OBBTreeNode* prev, int depth);
    2828    virtual ~OBBTreeNode();
    2929
     
    3131    virtual inline const BoundingVolume* getBV() const { return (BoundingVolume*)this->bvElement; }
    3232
    33     virtual void spawnBVTree(const modelInfo& modelInf, const int* triangleIndexes, unsigned int length);
     33    virtual void spawnBVTree(const modelInfo& modelInf, const int* triangleIndexes, int length);
    3434
    3535    virtual void collideWith(const BVTreeNode& treeNode, const WorldEntity& nodeA, const WorldEntity& nodeB) const;
     
    3737    void debug() const;
    3838
     39    /**  gets the id of the current child @return id of the child */
     40    inline const int getID() { return this->nextID++; }
    3941
    4042  private:
    4143    void calculateBoxAxis(OBB& box, const sVec3D* verticesList, unsigned int length);
    4244
    43     void calculateBoxCovariance(OBB& box, const modelInfo& modelInf, const int* triangleIndexes, unsigned int length);
    44     void calculateBoxEigenvectors(OBB& box, const modelInfo& modelInf, const int* triangleIndexes, unsigned int length);
    45     void calculateBoxAxis(OBB& box, const modelInfo& modelInf, const int* triangleIndexes, unsigned int length);
     45    void calculateBoxCovariance(OBB& box, const modelInfo& modelInf, const int* triangleIndexes, int length);
     46    void calculateBoxEigenvectors(OBB& box, const modelInfo& modelInf, const int* triangleIndexes, int length);
     47    void calculateBoxAxis(OBB& box, const modelInfo& modelInf, const int* triangleIndexes, int length);
    4648    void forkBox(OBB& box);
    4749
     
    5153  protected:
    5254    OBB*                bvElement;                  //!< the obb element
     55    OBBTreeNode*        nodePrev;                   //!< ref to the previous (parent) tree node = NULL if first
    5356    OBBTreeNode*        nodeLeft;                   //!< ref to the left tree node
    5457    OBBTreeNode*        nodeRight;                  //!< ref to the right tree node
     
    5659
    5760  private:
    58     unsigned int        treeIndex;                  //!< Index number of the BV in the tree
     61    int                 treeIndex;                  //!< Index number of the BV in the tree
     62    int                 nextID;                     //!< the id of the next child
    5963    int                 depth;                      //!< the depth of the node in the tree
    6064    const OBBTree*      obbTree;                    //!< reference to the obb tree
Note: See TracChangeset for help on using the changeset viewer.