Changeset 6911 in orxonox.OLD for branches/current_cd/src/lib/collision_detection
- Timestamp:
- Jan 31, 2006, 7:12:41 PM (19 years ago)
- Location:
- branches/current_cd/src/lib/collision_detection
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/current_cd/src/lib/collision_detection/bv_tree.h
r6909 r6911 44 44 virtual void flushTree() = 0; 45 45 46 virtual void collideWith( const WorldEntity& entity1, const WorldEntity& entity2) const= 0;46 virtual void collideWith(WorldEntity* entity1, WorldEntity* entity2) = 0; 47 47 48 48 virtual void drawBV(int depth, int drawMode) const = 0; -
branches/current_cd/src/lib/collision_detection/bv_tree_node.h
r6909 r6911 35 35 36 36 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; 38 38 virtual void drawBV(int depth, int drawMode, const Vector& color = Vector(1,0,0), bool top = true) const = 0; 39 39 -
branches/current_cd/src/lib/collision_detection/cd_engine.cc
r6909 r6911 108 108 void CDEngine::checkCollisions(std::list<WorldEntity*>& list1, std::list<WorldEntity*>& list2) 109 109 { 110 constBVTree* tree;110 BVTree* tree; 111 111 std::list<WorldEntity*>::iterator entity1, entity2, pre1, pre2; 112 112 PRINTF(5)("checking for collisions\n"); … … 126 126 PRINTF(4)("checking object %s against %s\n", (*entity1)->getName(), (*entity2)->getName()); 127 127 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); 129 130 } 130 131 } -
branches/current_cd/src/lib/collision_detection/obb_tree.cc
r6909 r6911 31 31 * standard constructor 32 32 */ 33 OBBTree::OBBTree(int depth, const modelInfo &modelInf)33 OBBTree::OBBTree(int depth, const modelInfo* modelInf) 34 34 : BVTree() 35 35 { 36 36 this->depth = depth; 37 37 this->init(); 38 this->spawnBVTree( modelInf);38 this->spawnBVTree(*modelInf); 39 39 } 40 40 … … 92 92 * @param nodeB: Pnode of object B 93 93 */ 94 void OBBTree::collideWith( const WorldEntity& entity1, const WorldEntity& entity2) const94 void OBBTree::collideWith(WorldEntity* entity1, WorldEntity* entity2) 95 95 { 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); 98 98 } 99 99 -
branches/current_cd/src/lib/collision_detection/obb_tree.h
r6909 r6911 21 21 22 22 public: 23 OBBTree(int depth, const modelInfo &modInfo);23 OBBTree(int depth, const modelInfo* modInfo); 24 24 virtual ~OBBTree(); 25 25 void init(); … … 28 28 virtual void flushTree(); 29 29 30 virtual void collideWith( const WorldEntity& entity1, const WorldEntity& entity2) const;30 virtual void collideWith(WorldEntity* entity1, WorldEntity* entity2); 31 31 virtual void drawBV(int depth, int drawMode) const; 32 32 -
branches/current_cd/src/lib/collision_detection/obb_tree_node.cc
r6909 r6911 515 515 516 516 517 void OBBTreeNode::collideWith(const BVTreeNode& treeNode, const WorldEntity& nodeA, const WorldEntity& nodeB) const517 void OBBTreeNode::collideWith(const BVTreeNode& treeNode, WorldEntity* nodeA, WorldEntity* nodeB) 518 518 { 519 519 PRINTF(3)("collideWith\n"); … … 525 525 if( this->overlapTest(*this->bvElement, *(((const OBBTreeNode*)&treeNode)->bvElement), nodeA, nodeB)) 526 526 { 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); 528 528 529 529 /* check if left node overlaps */ … … 552 552 if( unlikely(this->nodeRight == NULL && this->nodeLeft == NULL)) 553 553 { 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) const554 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, WorldEntity* nodeA, WorldEntity* nodeB) 565 565 { 566 566 // if( boxB == NULL || boxA == NULL) … … 575 575 Vector rotAxisB[3]; 576 576 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)); 587 587 588 588 // printf("\n"); -
branches/current_cd/src/lib/collision_detection/obb_tree_node.h
r6909 r6911 9 9 10 10 #include "bv_tree_node.h" 11 11 #include "plane.h" 12 12 13 13 class BoundingVolume; … … 32 32 virtual void spawnBVTree(const modelInfo& modelInf, const int* triangleIndexes, int length); 33 33 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); 35 35 virtual void drawBV(int depth, int drawMode, const Vector& color = Vector(1,0,0), bool top = true) const; 36 36 void debug() const; … … 48 48 void forkBox(OBB& box); 49 49 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); 51 51 52 52
Note: See TracChangeset
for help on using the changeset viewer.