Changeset 6911 in orxonox.OLD for branches/current_cd
- Timestamp:
- Jan 31, 2006, 7:12:41 PM (19 years ago)
- Location:
- branches/current_cd/src
- Files:
-
- 9 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 -
branches/current_cd/src/world_entities/world_entity.cc
r6909 r6911 204 204 * @param depth the depth to calculate 205 205 */ 206 bool WorldEntity::buildObbTree(unsigned int depth) 207 { 208 <<<<<<< .working 206 bool WorldEntity::buildObbTree(int depth) 207 { 209 208 if (this->obbTree) 210 209 delete this->obbTree; … … 212 211 if (this->models[0] != NULL) 213 212 { 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()); 226 214 return true; 227 215 } … … 266 254 * Implement behaviour like damage application or other miscellaneous collision stuff in this function 267 255 */ 268 void WorldEntity::collidesWith( const WorldEntity& entity, const Vector& location) const256 void WorldEntity::collidesWith(WorldEntity* entity, const Vector& location) 269 257 { 270 258 /** -
branches/current_cd/src/world_entities/world_entity.h
r6910 r6911 39 39 void setModel(Model* model, unsigned int modelNumber = 0); 40 40 Model* getModel(unsigned int modelNumber = 0) const { return (this->models.size() > modelNumber)? this->models[modelNumber] : NULL; }; 41 bool buildObbTree(int depth); 41 42 42 43 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; };47 44 48 45 /** @param visibility if the Entity should be visible (been draw) */ … … 51 48 inline bool isVisible() const { return this->bVisible; }; 52 49 53 54 55 50 virtual void postSpawn (); 56 51 virtual void leftWorld (); 57 52 58 53 virtual void tick (float time); 59 60 54 virtual void draw () const; 61 55 62 63 56 virtual void collidesWith (WorldEntity* entity, const Vector& location); 64 65 57 void drawBVTree(unsigned int depth, int drawMode) const; 66 58 /** @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; }; 69 60 70 61
Note: See TracChangeset
for help on using the changeset viewer.