Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6890 in orxonox.OLD for branches/cd_merge/src


Ignore:
Timestamp:
Jan 31, 2006, 1:55:42 PM (19 years ago)
Author:
patrick
Message:

cd_merge: comipiles again. major interface adjustements

Location:
branches/cd_merge/src
Files:
8 edited

Legend:

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

    r6657 r6890  
    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) const = 0;
    4747
    4848    virtual void drawBV(int depth, int drawMode) const = 0;
  • branches/cd_merge/src/lib/collision_detection/bv_tree_node.h

    r6657 r6890  
    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/cd_merge/src/lib/collision_detection/obb_tree.cc

    r6657 r6890  
    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) const
    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/cd_merge/src/lib/collision_detection/obb_tree.h

    r6657 r6890  
    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) const;
    3131    virtual void drawBV(int depth, int drawMode) const;
    3232
  • branches/cd_merge/src/lib/collision_detection/obb_tree_node.cc

    r6657 r6890  
    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");
    520520  /* if the obb overlap, make subtests: check which node is realy overlaping  */
    521   PRINTF(3)("Checking OBB %i vs %i: ", this->getIndex(), treeNode.getIndex());
     521  PRINTF(3)("Checking OBB %i vs %i: ", this->getIndex(), treeNode->getIndex());
    522522  //   if( unlikely(treeNode == NULL)) return;
    523523
    524524
    525   if( this->overlapTest(*this->bvElement, *(((const OBBTreeNode*)&treeNode)->bvElement), nodeA, nodeB))
    526   {
    527     PRINTF(3)("collision @ lvl %i, object %s vs. %s, (%p, %p)\n", this->depth, nodeA.getClassName(), nodeB.getClassName(), this->nodeLeft, this->nodeRight);
     525  if( this->overlapTest(this->bvElement, ((const OBBTreeNode*)&treeNode)->bvElement, nodeA, nodeB))
     526  {
     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 */
    530530    if( likely( this->nodeLeft != NULL))
    531531    {
    532       PRINTF(3)("Checking OBB %i vs %i: ", this->nodeLeft->getIndex(), treeNode.getIndex());
    533       if( this->overlapTest(*this->nodeLeft->bvElement, *(((const OBBTreeNode*)&treeNode)->bvElement), nodeA, nodeB))
     532      PRINTF(3)("Checking OBB %i vs %i: ", this->nodeLeft->getIndex(), treeNode->getIndex());
     533      if( this->overlapTest(this->nodeLeft->bvElement, ((const OBBTreeNode*)&treeNode)->bvElement, nodeA,nodeB))
    534534      {
    535         this->nodeLeft->collideWith(*(((const OBBTreeNode*)&treeNode)->nodeLeft), nodeA, nodeB);
    536         this->nodeLeft->collideWith(*(((const OBBTreeNode*)&treeNode)->nodeRight), nodeA, nodeB);
     535        this->nodeLeft->collideWith(((const OBBTreeNode*)&treeNode)->nodeLeft, nodeA, nodeB);
     536        this->nodeLeft->collideWith(((const OBBTreeNode*)&treeNode)->nodeRight, nodeA, nodeB);
    537537      }
    538538    }
     
    540540    if( likely( this->nodeRight != NULL))
    541541    {
    542       PRINTF(3)("Checking OBB %i vs %i: ", this->nodeRight->getIndex(), treeNode.getIndex());
    543       if(this->overlapTest(*this->nodeRight->bvElement, *(((const OBBTreeNode*)&treeNode)->bvElement), nodeA, nodeB))
     542      PRINTF(3)("Checking OBB %i vs %i: ", this->nodeRight->getIndex(), treeNode->getIndex());
     543      if(this->overlapTest(this->nodeRight->bvElement, ((const OBBTreeNode*)&treeNode)->bvElement, nodeA, nodeB))
    544544      {
    545         this->nodeRight->collideWith(*(((const OBBTreeNode*)&treeNode)->nodeLeft), nodeA, nodeB);
    546         this->nodeRight->collideWith(*(((const OBBTreeNode*)&treeNode)->nodeRight), nodeA, nodeB);
     545        this->nodeRight->collideWith(((const OBBTreeNode*)&treeNode)->nodeLeft, nodeA, nodeB);
     546        this->nodeRight->collideWith(((const OBBTreeNode*)&treeNode)->nodeRight, nodeA, nodeB);
    547547      }
    548548    }
     
    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");
     
    603603    l = rotAxisA[j];
    604604
    605     rA += fabs(boxA.halfLength[0] * rotAxisA[0].dot(l));
    606     rA += fabs(boxA.halfLength[1] * rotAxisA[1].dot(l));
    607     rA += fabs(boxA.halfLength[2] * rotAxisA[2].dot(l));
    608 
    609     rB += fabs(boxB.halfLength[0] * rotAxisB[0].dot(l));
    610     rB += fabs(boxB.halfLength[1] * rotAxisB[1].dot(l));
    611     rB += fabs(boxB.halfLength[2] * rotAxisB[2].dot(l));
     605    rA += fabs(boxA->halfLength[0] * rotAxisA[0].dot(l));
     606    rA += fabs(boxA->halfLength[1] * rotAxisA[1].dot(l));
     607    rA += fabs(boxA->halfLength[2] * rotAxisA[2].dot(l));
     608
     609    rB += fabs(boxB->halfLength[0] * rotAxisB[0].dot(l));
     610    rB += fabs(boxB->halfLength[1] * rotAxisB[1].dot(l));
     611    rB += fabs(boxB->halfLength[2] * rotAxisB[2].dot(l));
    612612
    613613    PRINTF(3)("s = %f, rA+rB = %f\n", fabs(t.dot(l)), rA+rB);
     
    627627    l = rotAxisB[j];
    628628
    629     rA += fabs(boxA.halfLength[0] * rotAxisA[0].dot(l));
    630     rA += fabs(boxA.halfLength[1] * rotAxisA[1].dot(l));
    631     rA += fabs(boxA.halfLength[2] * rotAxisA[2].dot(l));
    632 
    633     rB += fabs(boxB.halfLength[0] * rotAxisB[0].dot(l));
    634     rB += fabs(boxB.halfLength[1] * rotAxisB[1].dot(l));
    635     rB += fabs(boxB.halfLength[2] * rotAxisB[2].dot(l));
     629    rA += fabs(boxA->halfLength[0] * rotAxisA[0].dot(l));
     630    rA += fabs(boxA->halfLength[1] * rotAxisA[1].dot(l));
     631    rA += fabs(boxA->halfLength[2] * rotAxisA[2].dot(l));
     632
     633    rB += fabs(boxB->halfLength[0] * rotAxisB[0].dot(l));
     634    rB += fabs(boxB->halfLength[1] * rotAxisB[1].dot(l));
     635    rB += fabs(boxB->halfLength[2] * rotAxisB[2].dot(l));
    636636
    637637    PRINTF(3)("s = %f, rA+rB = %f\n", fabs(t.dot(l)), rA+rB);
     
    655655      l = rotAxisA[j].cross(rotAxisB[k]);
    656656
    657       rA += fabs(boxA.halfLength[0] * rotAxisA[0].dot(l));
    658       rA += fabs(boxA.halfLength[1] * rotAxisA[1].dot(l));
    659       rA += fabs(boxA.halfLength[2] * rotAxisA[2].dot(l));
    660 
    661       rB += fabs(boxB.halfLength[0] * rotAxisB[0].dot(l));
    662       rB += fabs(boxB.halfLength[1] * rotAxisB[1].dot(l));
    663       rB += fabs(boxB.halfLength[2] * rotAxisB[2].dot(l));
     657      rA += fabs(boxA->halfLength[0] * rotAxisA[0].dot(l));
     658      rA += fabs(boxA->halfLength[1] * rotAxisA[1].dot(l));
     659      rA += fabs(boxA->halfLength[2] * rotAxisA[2].dot(l));
     660
     661      rB += fabs(boxB->halfLength[0] * rotAxisB[0].dot(l));
     662      rB += fabs(boxB->halfLength[1] * rotAxisB[1].dot(l));
     663      rB += fabs(boxB->halfLength[2] * rotAxisB[2].dot(l));
    664664
    665665      PRINTF(3)("s = %f, rA+rB = %f\n", fabs(t.dot(l)), rA+rB);
     
    674674
    675675  /* FIXME: there is no collision mark set now */
    676   //   boxA.bCollided = true; /* use this ONLY(!!!!) for drawing operations */
    677   //   boxB.bCollided = true;
     676  //   boxA->bCollided = true; /* use this ONLY(!!!!) for drawing operations */
     677  //   boxB->bCollided = true;
    678678
    679679
  • branches/cd_merge/src/lib/collision_detection/obb_tree_node.h

    r6657 r6890  
    99
    1010#include "bv_tree_node.h"
     11#include "plane.h"
    1112
    1213
     
    3233    virtual void spawnBVTree(const modelInfo& modelInf, const int* triangleIndexes, int length);
    3334
    34     virtual void collideWith(const BVTreeNode& treeNode, const WorldEntity& nodeA, const WorldEntity& nodeB) const;
     35    virtual void collideWith(const BVTreeNode* treeNode, WorldEntity* nodeA, WorldEntity* nodeB);
    3536    virtual void drawBV(int depth, int drawMode, const Vector& color = Vector(1,0,0), bool top = true) const;
    3637    void debug() const;
     
    4849    void forkBox(OBB& box);
    4950
    50     bool overlapTest(const OBB& boxA, const OBB& boxB, const WorldEntity& nodeA, const WorldEntity& nodeB) const;
     51    bool overlapTest(const OBB* boxA, const OBB* boxB, WorldEntity* nodeA, WorldEntity* nodeB);
    5152
    5253
  • branches/cd_merge/src/world_entities/world_entity.cc

    r6634 r6890  
    202202 * @param depth the depth to calculate
    203203 */
    204 bool WorldEntity::buildObbTree(unsigned int depth)
     204bool WorldEntity::buildObbTree(int depth)
    205205{
    206206  if (this->obbTree)
     
    211211    PRINTF(4)("creating obb tree\n");
    212212
    213 
    214     this->obbTree = new OBBTree(depth, (sVec3D*)this->models[0]->getVertexArray(), this->models[0]->getVertexCount());
     213    this->obbTree = new OBBTree(depth, this->models[0]->getModelInfo());
    215214    return true;
    216215  }
  • branches/cd_merge/src/world_entities/world_entity.h

    r6512 r6890  
    4242  inline void loadMD2Texture(const char* fileName) { this->md2TextureFileName = fileName; }
    4343
    44   bool buildObbTree(unsigned int depth);
     44  bool buildObbTree(int depth);
    4545  /** @returns a reference to the obb tree of this worldentity */
    4646  BVTree* getOBBTree() const { return this->obbTree; };
Note: See TracChangeset for help on using the changeset viewer.