Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6911 in orxonox.OLD for branches/current_cd


Ignore:
Timestamp:
Jan 31, 2006, 7:12:41 PM (19 years ago)
Author:
patrick
Message:

cd: compiles again

Location:
branches/current_cd/src
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • branches/current_cd/src/lib/collision_detection/bv_tree.h

    r6909 r6911  
    4444    virtual void flushTree() = 0;
    4545
    46     virtual void collideWith(const WorldEntity& entity1, const WorldEntity& entity2) const = 0;
     46    virtual void collideWith(WorldEntity* entity1, WorldEntity* entity2) = 0;
    4747
    4848    virtual void drawBV(int depth, int drawMode) const = 0;
  • branches/current_cd/src/lib/collision_detection/bv_tree_node.h

    r6909 r6911  
    3535
    3636  virtual void spawnBVTree(const modelInfo& modInfo, const int* triangleIndexes, int length) = 0;
    37   virtual void collideWith(const BVTreeNode& treeNode, const WorldEntity& nodeA, const WorldEntity& nodeB) const = 0;
     37  virtual void collideWith(const BVTreeNode& treeNode, WorldEntity* nodeA, WorldEntity* nodeB) = 0;
    3838  virtual void drawBV(int depth, int drawMode, const Vector& color = Vector(1,0,0), bool top = true) const = 0;
    3939
  • branches/current_cd/src/lib/collision_detection/cd_engine.cc

    r6909 r6911  
    108108void CDEngine::checkCollisions(std::list<WorldEntity*>& list1, std::list<WorldEntity*>& list2)
    109109{
    110   const BVTree* tree;
     110  BVTree* tree;
    111111  std::list<WorldEntity*>::iterator entity1, entity2, pre1, pre2;
    112112  PRINTF(5)("checking for collisions\n");
     
    126126          PRINTF(4)("checking object %s against %s\n", (*entity1)->getName(), (*entity2)->getName());
    127127          tree = (*entity1)->getOBBTree();
    128           if( likely(tree != NULL) && (*entity2)->getOBBTree() != NULL) tree->collideWith(*entity1, *entity2);
     128          if( likely(tree != NULL) && (*entity2)->getOBBTree() != NULL)
     129            tree->collideWith(*entity1, *entity2);
    129130        }
    130131      }
  • branches/current_cd/src/lib/collision_detection/obb_tree.cc

    r6909 r6911  
    3131 *  standard constructor
    3232*/
    33 OBBTree::OBBTree(int depth, const modelInfo& modelInf)
     33OBBTree::OBBTree(int depth, const modelInfo* modelInf)
    3434  : BVTree()
    3535{
    3636  this->depth = depth;
    3737  this->init();
    38   this->spawnBVTree(modelInf);
     38  this->spawnBVTree(*modelInf);
    3939}
    4040
     
    9292 * @param nodeB: Pnode of object B
    9393 */
    94 void OBBTree::collideWith(const WorldEntity& entity1, const WorldEntity& entity2) const
     94void OBBTree::collideWith(WorldEntity* entity1, WorldEntity* entity2)
    9595{
    96   if( likely(entity2.getOBBTree() != NULL) )
    97     this->rootNode->collideWith(*(((OBBTree*)entity2.getOBBTree())->getRootNode()), entity1, entity2);
     96  if( likely(entity2->getOBBTree() != NULL) )
     97    this->rootNode->collideWith(*(((OBBTree*)entity2->getOBBTree())->getRootNode()), entity1, entity2);
    9898}
    9999
  • branches/current_cd/src/lib/collision_detection/obb_tree.h

    r6909 r6911  
    2121
    2222  public:
    23     OBBTree(int depth, const modelInfo& modInfo);
     23    OBBTree(int depth, const modelInfo* modInfo);
    2424    virtual ~OBBTree();
    2525    void init();
     
    2828    virtual void flushTree();
    2929
    30     virtual void collideWith(const WorldEntity& entity1, const WorldEntity& entity2) const;
     30    virtual void collideWith(WorldEntity* entity1, WorldEntity* entity2);
    3131    virtual void drawBV(int depth, int drawMode) const;
    3232
  • branches/current_cd/src/lib/collision_detection/obb_tree_node.cc

    r6909 r6911  
    515515
    516516
    517 void OBBTreeNode::collideWith(const BVTreeNode& treeNode, const WorldEntity& nodeA, const WorldEntity& nodeB) const
     517void OBBTreeNode::collideWith(const BVTreeNode& treeNode, WorldEntity* nodeA, WorldEntity* nodeB)
    518518{
    519519  PRINTF(3)("collideWith\n");
     
    525525  if( this->overlapTest(*this->bvElement, *(((const OBBTreeNode*)&treeNode)->bvElement), nodeA, nodeB))
    526526  {
    527     PRINTF(3)("collision @ lvl %i, object %s vs. %s, (%p, %p)\n", this->depth, nodeA.getClassName(), nodeB.getClassName(), this->nodeLeft, this->nodeRight);
     527    PRINTF(3)("collision @ lvl %i, object %s vs. %s, (%p, %p)\n", this->depth, nodeA->getClassName(), nodeB->getClassName(), this->nodeLeft, this->nodeRight);
    528528
    529529    /* check if left node overlaps */
     
    552552    if( unlikely(this->nodeRight == NULL && this->nodeLeft == NULL))
    553553    {
    554       nodeA.collidesWith(nodeB, (((const OBBTreeNode*)&treeNode)->bvElement->center));
    555 
    556       nodeB.collidesWith(nodeA, this->bvElement->center);
    557     }
    558 
    559   }
    560 }
    561 
    562 
    563 
    564 bool OBBTreeNode::overlapTest(const OBB& boxA, const OBB& boxB, const WorldEntity& nodeA, const WorldEntity& nodeB) const
     554      nodeA->collidesWith(nodeB, (((const OBBTreeNode*)&treeNode)->bvElement->center));
     555
     556      nodeB->collidesWith(nodeA, this->bvElement->center);
     557    }
     558
     559  }
     560}
     561
     562
     563
     564bool OBBTreeNode::overlapTest(const OBB& boxA, const OBB& boxB, WorldEntity* nodeA, WorldEntity* nodeB)
    565565{
    566566  //   if( boxB == NULL || boxA == NULL)
     
    575575  Vector rotAxisB[3];
    576576
    577   rotAxisA[0] =  nodeA.getAbsDir().apply(boxA.axis[0]);
    578   rotAxisA[1] =  nodeA.getAbsDir().apply(boxA.axis[1]);
    579   rotAxisA[2] =  nodeA.getAbsDir().apply(boxA.axis[2]);
    580 
    581   rotAxisB[0] =  nodeB.getAbsDir().apply(boxB.axis[0]);
    582   rotAxisB[1] =  nodeB.getAbsDir().apply(boxB.axis[1]);
    583   rotAxisB[2] =  nodeB.getAbsDir().apply(boxB.axis[2]);
    584 
    585 
    586   t = nodeA.getAbsCoor() + nodeA.getAbsDir().apply(boxA.center) - ( nodeB.getAbsCoor() + nodeB.getAbsDir().apply(boxB.center));
     577  rotAxisA[0] =  nodeA->getAbsDir().apply(boxA.axis[0]);
     578  rotAxisA[1] =  nodeA->getAbsDir().apply(boxA.axis[1]);
     579  rotAxisA[2] =  nodeA->getAbsDir().apply(boxA.axis[2]);
     580
     581  rotAxisB[0] =  nodeB->getAbsDir().apply(boxB.axis[0]);
     582  rotAxisB[1] =  nodeB->getAbsDir().apply(boxB.axis[1]);
     583  rotAxisB[2] =  nodeB->getAbsDir().apply(boxB.axis[2]);
     584
     585
     586  t = nodeA->getAbsCoor() + nodeA->getAbsDir().apply(boxA.center) - ( nodeB->getAbsCoor() + nodeB->getAbsDir().apply(boxB.center));
    587587
    588588  //   printf("\n");
  • branches/current_cd/src/lib/collision_detection/obb_tree_node.h

    r6909 r6911  
    99
    1010#include "bv_tree_node.h"
    11 
     11#include "plane.h"
    1212
    1313class BoundingVolume;
     
    3232    virtual void spawnBVTree(const modelInfo& modelInf, const int* triangleIndexes, int length);
    3333
    34     virtual void collideWith(const BVTreeNode& treeNode, const WorldEntity& nodeA, const WorldEntity& nodeB) const;
     34    virtual void collideWith(const BVTreeNode& treeNode, WorldEntity* nodeA, WorldEntity* nodeB);
    3535    virtual void drawBV(int depth, int drawMode, const Vector& color = Vector(1,0,0), bool top = true) const;
    3636    void debug() const;
     
    4848    void forkBox(OBB& box);
    4949
    50     bool overlapTest(const OBB& boxA, const OBB& boxB, const WorldEntity& nodeA, const WorldEntity& nodeB) const;
     50    bool overlapTest(const OBB& boxA, const OBB& boxB, WorldEntity* nodeA, WorldEntity* nodeB);
    5151
    5252
  • branches/current_cd/src/world_entities/world_entity.cc

    r6909 r6911  
    204204 * @param depth the depth to calculate
    205205 */
    206 bool WorldEntity::buildObbTree(unsigned int depth)
    207 {
    208 <<<<<<< .working
     206bool WorldEntity::buildObbTree(int depth)
     207{
    209208  if (this->obbTree)
    210209    delete this->obbTree;
     
    212211  if (this->models[0] != NULL)
    213212  {
    214 =======
    215   if( this->model != NULL) {
    216 >>>>>>> .merge-right.r6905
    217     PRINTF(4)("creating obb tree\n");
    218 <<<<<<< .working
    219 
    220 
    221     this->obbTree = new OBBTree(depth, (sVec3D*)this->models[0]->getVertexArray(), this->models[0]->getVertexCount());
    222 =======
    223     //this->obbTree = new OBBTree(depth, (sVec3D*)this->model->getVertexArray(), this->model->getVertexCount());
    224     this->obbTree = new OBBTree(depth, *model->getModelInfo());
    225 >>>>>>> .merge-right.r6905
     213    this->obbTree = new OBBTree(depth, models[0]->getModelInfo());
    226214    return true;
    227215  }
     
    266254 * Implement behaviour like damage application or other miscellaneous collision stuff in this function
    267255 */
    268 void WorldEntity::collidesWith(const WorldEntity& entity, const Vector& location) const
     256void WorldEntity::collidesWith(WorldEntity* entity, const Vector& location)
    269257{
    270258  /**
  • branches/current_cd/src/world_entities/world_entity.h

    r6910 r6911  
    3939  void setModel(Model* model, unsigned int modelNumber = 0);
    4040  Model* getModel(unsigned int modelNumber = 0) const { return (this->models.size() > modelNumber)? this->models[modelNumber] : NULL; };
     41  bool buildObbTree(int depth);
    4142
    4243  inline void loadMD2Texture(const char* fileName) { this->md2TextureFileName = fileName; }
    43 
    44   bool buildObbTree(unsigned int depth);
    45   /** @returns a reference to the obb tree of this worldentity */
    46   BVTree* getOBBTree() const { return this->obbTree; };
    4744
    4845  /** @param visibility if the Entity should be visible (been draw) */
     
    5148  inline bool isVisible() const { return this->bVisible; };
    5249
    53 
    54 
    5550  virtual void postSpawn ();
    5651  virtual void leftWorld ();
    5752
    5853  virtual void tick (float time);
    59 
    6054  virtual void draw () const;
    6155
    62 
    6356  virtual void collidesWith (WorldEntity* entity, const Vector& location);
    64 
    6557  void drawBVTree(unsigned int depth, int drawMode) const;
    6658  /** @returns a reference to the obb tree of this worldentity */
    67   inline const BVTree* getOBBTree() const { return this->obbTree; };
    68 
     59  inline BVTree* getOBBTree() const { return this->obbTree; };
    6960
    7061
Note: See TracChangeset for help on using the changeset viewer.