Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 5717 in orxonox.OLD for branches/collision_detection


Ignore:
Timestamp:
Nov 23, 2005, 12:31:47 AM (19 years ago)
Author:
patrick
Message:

collision_detection: work flush

Location:
branches/collision_detection/src
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • branches/collision_detection/src/defs/debug.h

    r5713 r5717  
    3636#define WARN            2
    3737#define INFO            3
    38 //#define DEBUG           4
     38#define DEBUG           4
    3939#define vDEBUG          5
    4040
     
    7575  #define DEBUG_MODULE_OBJECT_MANAGER        2
    7676  #define DEBUG_MODULE_ANIM                  2
    77   #define DEBUG_MODULE_COLLISON_DETECTION    5
     77  #define DEBUG_MODULE_COLLISON_DETECTION    4
    7878  #define DEBUG_MODULE_SPATIAL_SEPARATION    2
    7979  #define DEBUG_MODULE_GUI                   2
  • branches/collision_detection/src/lib/collision_detection/bv_tree_node.h

    r5716 r5717  
    2626  virtual ~BVTreeNode();
    2727
     28  virtual const BoundingVolume* getBV() const = 0;
     29  inline const int getIndex() const { return this->treeIndex; }
     30
    2831  virtual void spawnBVTree(const sVec3D *verticesList, unsigned int length ) = 0;
    2932  virtual void spawnBVTree(const modelInfo& modInfo, const int* triangleIndexes, unsigned int length) = 0;
    3033
    31   virtual const BoundingVolume* getBV() const = 0;
    32   inline const int getIndex() { return this->treeIndex; }
    33 
    34   virtual void collideWith(BVTreeNode* treeNode, WorldEntity* nodeA, WorldEntity* nodeB) = 0;
     34  virtual void collideWith(const BVTreeNode& treeNode, const WorldEntity& nodeA, const WorldEntity& nodeB) const = 0;
    3535
    3636  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/cd_engine.cc

    r5716 r5717  
    1414*/
    1515
    16 #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_COLLISION_DETECTION
     16#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_COLLISION
    1717
    1818#include "cd_engine.h"
     
    7878void CDEngine::checkCollisionObjects()
    7979{
    80   BVTree* tree;
     80  const BVTree* tree;
    8181  tIterator<WorldEntity>* iterator1 = entityList->getIterator();
    8282  tIterator<WorldEntity>* iterator2 = entityList->getIterator();
     
    9494        if( likely(entity2 != this->terrain))
    9595        {
    96           PRINTF(4)("checking object %s against %s\n", entity1->getName(), entity2->getName());
     96          printf("checking object %s against %s\n", entity1->getName(), entity2->getName());
    9797          tree = entity1->getOBBTree();
    98           if( likely(tree != NULL) && entity2->getOBBTree() != NULL) tree->collideWith(entity1, entity2);
     98
     99          if( likely(tree != NULL) && entity2->getOBBTree() != NULL)
     100            //tree->collideWith(entity1, entity2);
     101            PRINTF(5)("Collision check\n");
    99102        }
    100103        entity2 = iterator2->nextElement();
  • branches/collision_detection/src/lib/collision_detection/obb_tree.cc

    r5716 r5717  
    8787    this->flushTree();
    8888  }
    89   OBBTreeNode* node = new OBBTreeNode(*this, depth);
    90   this->rootNode = node;
     89  this->rootNode = new OBBTreeNode(*this, depth-1);
    9190
    9291  /* triangles indexes created */
     
    9796  this->rootNode->spawnBVTree(modelInf, triangleIndexes, modelInf.numTriangles);
    9897}
     98
     99
    99100
    100101
  • branches/collision_detection/src/lib/collision_detection/obb_tree.h

    r5716 r5717  
    3434    virtual void drawBV(int depth, int drawMode) const;
    3535
    36     int getID() { return ++this->id;}
    37     inline OBBTreeNode* getRootNode() { return this->rootNode; }
     36    const int getID() { return ++this->id;}
     37    inline const OBBTreeNode* getRootNode() const { return this->rootNode; }
    3838
    3939    void debug();
  • branches/collision_detection/src/lib/collision_detection/obb_tree_node.cc

    r5716 r5717  
    600600
    601601
    602 void OBBTreeNode::collideWith(BVTreeNode* treeNode, WorldEntity* nodeA, WorldEntity* nodeB)
     602void OBBTreeNode::collideWith(BVTreeNode* treeNode, WorldEntity* nodeA, WorldEntity* nodeB) const
    603603{
    604604  PRINTF(3)("collideWith\n");
     
    645645
    646646
    647 bool OBBTreeNode::overlapTest(OBB* boxA, OBB* boxB, WorldEntity* nodeA, WorldEntity* nodeB)
     647bool OBBTreeNode::overlapTest(OBB* boxA, OBB* boxB, WorldEntity* nodeA, WorldEntity* nodeB) const
    648648{
    649649  if( boxB == NULL || boxA == NULL)
  • branches/collision_detection/src/lib/collision_detection/obb_tree_node.h

    r5716 r5717  
    3434    virtual void spawnBVTree(const modelInfo& modelInf, const int* triangleIndexes, unsigned int length);
    3535
    36     virtual void collideWith(BVTreeNode* treeNode, WorldEntity* nodeA, WorldEntity* nodeB);
     36    virtual void collideWith(BVTreeNode* treeNode, WorldEntity* nodeA, WorldEntity* nodeB) const;
    3737    virtual void drawBV(int depth, int drawMode, const Vector& color = Vector(1,0,0), bool top = true) const;
    3838    void debug() const;
     
    4848    void forkBox(OBB& box);
    4949
    50     bool overlapTest(OBB* boxA, OBB* boxB, WorldEntity* nodeA, WorldEntity* nodeB);
     50    bool overlapTest(OBB* boxA, OBB* boxB, WorldEntity* nodeA, WorldEntity* nodeB) const;
    5151
    5252
  • branches/collision_detection/src/world_entities/world_entity.cc

    r5713 r5717  
    104104  }
    105105  else
    106     this->model = NULL;
     106  {
     107        this->model = NULL;
     108        this->obbTree = NULL;
     109  }
    107110}
    108111
     
    113116bool WorldEntity::buildObbTree(unsigned int depth)
    114117{
    115   if (this->obbTree)
    116     delete this->obbTree;
    117 
    118   if (this->model != NULL)
    119   {
     118  if( this->model != NULL) {
    120119    PRINTF(4)("creating obb tree\n");
    121 
    122 
    123120    //this->obbTree = new OBBTree(depth, (sVec3D*)this->model->getVertexArray(), this->model->getVertexCount());
    124121    this->obbTree = new OBBTree(depth, *model->getModelInfo());
     
    127124  else
    128125  {
    129     PRINTF(2)("could not create obb-tree, because no model was loaded yet\n");
     126    PRINTF(1)("could not create obb-tree, because no model was loaded yet\n");
    130127    this->obbTree = NULL;
    131128    return false;
  • branches/collision_detection/src/world_entities/world_entity.h

    r5511 r5717  
    4747  void drawBVTree(unsigned int depth, int drawMode) const;
    4848  /** @returns a reference to the obb tree of this worldentity */
    49   BVTree* getOBBTree() const { return this->obbTree; };
     49  inline const BVTree* getOBBTree() const { return this->obbTree; };
    5050
    5151  /* @returns the Count of Faces on this WorldEntity */
     
    5959 protected:
    6060  Model*                  model;            //!< The model that should be loaded for this entity.
    61   BVTree*                 obbTree;          //!< this is the obb tree reference needed for collision detection
     61  const BVTree*           obbTree;          //!< this is the obb tree reference needed for collision detection
    6262  //  CharacterAttributes*    charAttr;         //!< the character attributes of a world_entity
    6363
Note: See TracChangeset for help on using the changeset viewer.