Changeset 5717 in orxonox.OLD for branches/collision_detection
- Timestamp:
- Nov 23, 2005, 12:31:47 AM (19 years ago)
- Location:
- branches/collision_detection/src
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/collision_detection/src/defs/debug.h
r5713 r5717 36 36 #define WARN 2 37 37 #define INFO 3 38 //#define DEBUG 438 #define DEBUG 4 39 39 #define vDEBUG 5 40 40 … … 75 75 #define DEBUG_MODULE_OBJECT_MANAGER 2 76 76 #define DEBUG_MODULE_ANIM 2 77 #define DEBUG_MODULE_COLLISON_DETECTION 577 #define DEBUG_MODULE_COLLISON_DETECTION 4 78 78 #define DEBUG_MODULE_SPATIAL_SEPARATION 2 79 79 #define DEBUG_MODULE_GUI 2 -
branches/collision_detection/src/lib/collision_detection/bv_tree_node.h
r5716 r5717 26 26 virtual ~BVTreeNode(); 27 27 28 virtual const BoundingVolume* getBV() const = 0; 29 inline const int getIndex() const { return this->treeIndex; } 30 28 31 virtual void spawnBVTree(const sVec3D *verticesList, unsigned int length ) = 0; 29 32 virtual void spawnBVTree(const modelInfo& modInfo, const int* triangleIndexes, unsigned int length) = 0; 30 33 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; 35 35 36 36 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 14 14 */ 15 15 16 #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_COLLISION _DETECTION16 #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_COLLISION 17 17 18 18 #include "cd_engine.h" … … 78 78 void CDEngine::checkCollisionObjects() 79 79 { 80 BVTree* tree;80 const BVTree* tree; 81 81 tIterator<WorldEntity>* iterator1 = entityList->getIterator(); 82 82 tIterator<WorldEntity>* iterator2 = entityList->getIterator(); … … 94 94 if( likely(entity2 != this->terrain)) 95 95 { 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()); 97 97 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"); 99 102 } 100 103 entity2 = iterator2->nextElement(); -
branches/collision_detection/src/lib/collision_detection/obb_tree.cc
r5716 r5717 87 87 this->flushTree(); 88 88 } 89 OBBTreeNode* node = new OBBTreeNode(*this, depth); 90 this->rootNode = node; 89 this->rootNode = new OBBTreeNode(*this, depth-1); 91 90 92 91 /* triangles indexes created */ … … 97 96 this->rootNode->spawnBVTree(modelInf, triangleIndexes, modelInf.numTriangles); 98 97 } 98 99 99 100 100 101 -
branches/collision_detection/src/lib/collision_detection/obb_tree.h
r5716 r5717 34 34 virtual void drawBV(int depth, int drawMode) const; 35 35 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; } 38 38 39 39 void debug(); -
branches/collision_detection/src/lib/collision_detection/obb_tree_node.cc
r5716 r5717 600 600 601 601 602 void OBBTreeNode::collideWith(BVTreeNode* treeNode, WorldEntity* nodeA, WorldEntity* nodeB) 602 void OBBTreeNode::collideWith(BVTreeNode* treeNode, WorldEntity* nodeA, WorldEntity* nodeB) const 603 603 { 604 604 PRINTF(3)("collideWith\n"); … … 645 645 646 646 647 bool OBBTreeNode::overlapTest(OBB* boxA, OBB* boxB, WorldEntity* nodeA, WorldEntity* nodeB) 647 bool OBBTreeNode::overlapTest(OBB* boxA, OBB* boxB, WorldEntity* nodeA, WorldEntity* nodeB) const 648 648 { 649 649 if( boxB == NULL || boxA == NULL) -
branches/collision_detection/src/lib/collision_detection/obb_tree_node.h
r5716 r5717 34 34 virtual void spawnBVTree(const modelInfo& modelInf, const int* triangleIndexes, unsigned int length); 35 35 36 virtual void collideWith(BVTreeNode* treeNode, WorldEntity* nodeA, WorldEntity* nodeB) ;36 virtual void collideWith(BVTreeNode* treeNode, WorldEntity* nodeA, WorldEntity* nodeB) const; 37 37 virtual void drawBV(int depth, int drawMode, const Vector& color = Vector(1,0,0), bool top = true) const; 38 38 void debug() const; … … 48 48 void forkBox(OBB& box); 49 49 50 bool overlapTest(OBB* boxA, OBB* boxB, WorldEntity* nodeA, WorldEntity* nodeB) ;50 bool overlapTest(OBB* boxA, OBB* boxB, WorldEntity* nodeA, WorldEntity* nodeB) const; 51 51 52 52 -
branches/collision_detection/src/world_entities/world_entity.cc
r5713 r5717 104 104 } 105 105 else 106 this->model = NULL; 106 { 107 this->model = NULL; 108 this->obbTree = NULL; 109 } 107 110 } 108 111 … … 113 116 bool WorldEntity::buildObbTree(unsigned int depth) 114 117 { 115 if (this->obbTree) 116 delete this->obbTree; 117 118 if (this->model != NULL) 119 { 118 if( this->model != NULL) { 120 119 PRINTF(4)("creating obb tree\n"); 121 122 123 120 //this->obbTree = new OBBTree(depth, (sVec3D*)this->model->getVertexArray(), this->model->getVertexCount()); 124 121 this->obbTree = new OBBTree(depth, *model->getModelInfo()); … … 127 124 else 128 125 { 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"); 130 127 this->obbTree = NULL; 131 128 return false; -
branches/collision_detection/src/world_entities/world_entity.h
r5511 r5717 47 47 void drawBVTree(unsigned int depth, int drawMode) const; 48 48 /** @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; }; 50 50 51 51 /* @returns the Count of Faces on this WorldEntity */ … … 59 59 protected: 60 60 Model* model; //!< The model that should be loaded for this entity. 61 BVTree*obbTree; //!< this is the obb tree reference needed for collision detection61 const BVTree* obbTree; //!< this is the obb tree reference needed for collision detection 62 62 // CharacterAttributes* charAttr; //!< the character attributes of a world_entity 63 63
Note: See TracChangeset
for help on using the changeset viewer.