Changeset 6124 in orxonox.OLD for branches/objectmanager/src/lib
- Timestamp:
- Dec 15, 2005, 2:28:27 AM (19 years ago)
- Location:
- branches/objectmanager/src/lib/collision_detection
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/objectmanager/src/lib/collision_detection/cd_engine.cc
r6022 r6124 65 65 be able to enhance iteration speed. 66 66 */ 67 void CDEngine::checkCollisions()68 {69 this->checkCollisionObjects();67 //void CDEngine::checkCollisions() 68 //{ 69 // this->checkCollisionObjects(); 70 70 //this->checkCollisionGround(); 71 } 72 73 #include "class_list.h" 74 #include "state.h" 71 //} 72 75 73 /** 76 74 * this checks the collisions with the objects 77 75 */ 78 void CDEngine::checkCollisionObjects() 76 //void CDEngine::checkCollisionObjects() 77 //{ 78 // BVTree* tree; 79 // tIterator<WorldEntity>* iterator1 = entityList->getIterator(); 80 // tIterator<WorldEntity>* iterator2 = entityList->getIterator(); 81 // WorldEntity* entity1 = iterator1->firstElement(); 82 // WorldEntity* entity2 = iterator2->iteratorElement(iterator1); 83 // PRINTF(3)("checking for collisions\n"); 84 // while( entity1 != NULL) 85 // { 86 // if( likely(entity1 != this->terrain)) 87 // { 88 // entity2 = iterator2->nextElement(); 89 // 90 // while( entity2 != NULL) 91 // { 92 // if( likely(entity2 != this->terrain)) 93 // { 94 // PRINTF(4)("checking object %s against %s\n", entity1->getName(), entity2->getName()); 95 // tree = entity1->getOBBTree(); 96 // if( likely(tree != NULL) && entity2->getOBBTree() != NULL) tree->collideWith(entity1, entity2); 97 // } 98 // entity2 = iterator2->nextElement(); 99 // } 100 // } 101 // entity1 = iterator1->nextElement(); 102 // entity2 = iterator2->iteratorElement(iterator1); 103 // entity2 = iterator2->nextElement(); 104 // } 105 // delete iterator1; 106 // delete iterator2; 107 //} 108 109 void CDEngine::checkCollisions(std::list<WorldEntity*>& list1, std::list<WorldEntity*>& list2) 79 110 { 80 111 BVTree* tree; 81 tIterator<WorldEntity>* iterator1 = entityList->getIterator(); 82 tIterator<WorldEntity>* iterator2 = entityList->getIterator(); 83 WorldEntity* entity1 = iterator1->firstElement(); 84 WorldEntity* entity2 = iterator2->iteratorElement(iterator1); 112 std::list<WorldEntity*>::iterator entity1, entity2; 85 113 PRINTF(3)("checking for collisions\n"); 86 while( entity1 != NULL)114 for (entity1 = list1.begin(); entity1 != list1.end(); entity1++) 87 115 { 88 if( likely( entity1!= this->terrain))116 if( likely((*entity1) != this->terrain)) 89 117 { 90 entity2 = iterator2->nextElement(); 91 92 while( entity2 != NULL) 118 for (entity2 = list2.begin(); entity2 != list2.end(); entity2++) 93 119 { 94 if( likely( entity2!= this->terrain))120 if( likely((*entity2) != this->terrain)) 95 121 { 96 PRINTF(4)("checking object %s against %s\n", entity1->getName(), entity2->getName());97 tree = entity1->getOBBTree();98 if( likely(tree != NULL) && entity2->getOBBTree() != NULL) tree->collideWith(entity1,entity2);122 PRINTF(4)("checking object %s against %s\n", (*entity1)->getName(), (*entity2)->getName()); 123 tree = (*entity1)->getOBBTree(); 124 if( likely(tree != NULL) && (*entity2)->getOBBTree() != NULL) tree->collideWith(*entity1, *entity2); 99 125 } 100 entity2 = iterator2->nextElement();101 126 } 102 127 } 103 entity1 = iterator1->nextElement();104 entity2 = iterator2->iteratorElement(iterator1);105 entity2 = iterator2->nextElement();106 128 } 107 delete iterator1;108 delete iterator2;109 129 } 110 130 … … 134 154 /* this would operate on worldList bases, for testing purposes, we only use one OBBTree */ 135 155 //this->rootTree->drawBV(depth, drawMode); 136 137 tIterator<WorldEntity>* iterator = entityList->getIterator();156 /// FIXME 157 /* tIterator<WorldEntity>* iterator = entityList->getIterator(); 138 158 WorldEntity* entity = iterator->firstElement(); 139 159 while( entity != NULL) … … 142 162 entity = iterator->nextElement(); 143 163 } 144 delete iterator; 164 delete iterator;*/ 145 165 } 146 166 -
branches/objectmanager/src/lib/collision_detection/cd_engine.h
r6022 r6124 12 12 #include "model.h" 13 13 14 #include <list> 14 15 15 template<class T> class tList;16 16 class WorldEntity; 17 17 class OBBTree; … … 49 49 inline void disable(const int options) { int temp = this->state & options; this->state ^= temp; } 50 50 51 inline void setEntityList(tList<WorldEntity>* entityList) { this->entityList = entityList; }52 51 inline void setTerrain(Terrain* terrain) { this->terrain = terrain; } 53 52 // inline void setPlayer(Player* player) { this->player = player; } /* only for debug purposes \todo: delete*/ … … 55 54 void drawBV(int depth, int drawMode) const; 56 55 57 void checkCollisions(); 56 // void checkCollisions(); 57 void checkCollisions(std::list<WorldEntity*>& list1, std::list<WorldEntity*>& list2); 58 58 59 59 void debug(); … … 75 75 private: 76 76 int state; //!< the current state of the cd engine 77 tList<WorldEntity>* entityList; //!< pointer to the world entity list78 77 OBBTree* rootTree; //!< for testing purposes a root tree 79 78
Note: See TracChangeset
for help on using the changeset viewer.