Changeset 4694 in orxonox.OLD for orxonox/trunk/src/lib
- Timestamp:
- Jun 24, 2005, 6:10:13 PM (19 years ago)
- Location:
- orxonox/trunk/src/lib
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/src/lib/collision_detection/cd_engine.cc
r4689 r4694 59 59 tIterator<WorldEntity>* iterator2 = entityList->getIterator(); 60 60 WorldEntity* entity1 = iterator1->nextElement(); 61 WorldEntity* entity2 = iterator2->nextElement(); 61 WorldEntity* entity2 = iterator2->seekElement(entity1); 62 printf("checking for collisions\n"); 62 63 while( entity1 != NULL) 63 64 { 64 while( entity2 != NULL && entity1 != entity2) 65 printf("entering l1\n"); 66 while( entity2 != NULL) 65 67 { 68 printf("entering l2 - checking object %s against %s\n", entity1->getName(), entity2->getName()); 66 69 entity1->collideWith(entity2); 67 70 entity2 = iterator2->nextElement(); 71 68 72 } 69 73 entity1 = iterator1->nextElement(); 74 entity2 = iterator2->seekElement(entity1); 75 70 76 } 71 77 delete iterator1; 72 78 delete iterator2; 73 74 75 79 } 76 80 -
orxonox/trunk/src/lib/util/list.h
r4574 r4694 34 34 35 35 T* nextElement(); 36 T* seekElement(T* element); 36 37 37 38 private: 38 39 listElement<T>* currentEl; //!< pointer to the current list element in the iterator 39 40 listElement<T>* tmpEl; //!< temp listElemnt pointer 41 listElement<T>* startElement; //!< pointer to the start of the list 40 42 }; 41 43 … … 61 63 this->currentEl = startElement; 62 64 this->tmpEl = NULL; 65 this->startElement = startElement; 63 66 } 64 67 … … 87 90 this->currentEl = this->currentEl->next; 88 91 return this->tmpEl->curr; 92 } 93 94 /** 95 \brief gets the element after the selected one, sets the iterator to this point in the list 96 \param element the element to seek 97 \returns next list element 98 99 Attention: if you seek an element, the iterator pointer will point to the NEXT listelement after the argument! 100 */ 101 template<class T> 102 inline T* tIterator<T>::seekElement (T* element) 103 { 104 for(this->tmpEl = this->startElement; this->tmpEl != NULL; this->tmpEl = this->tmpEl->next) 105 { 106 if( unlikely(this->tmpEl->curr == element)) 107 { 108 if( this->tmpEl->next != NULL) 109 { 110 this->currentEl = this->tmpEl->next->next; 111 return this->tmpEl->next->curr; 112 } 113 return NULL; 114 } 115 } 116 return NULL; 89 117 } 90 118 … … 109 137 bool isEmpty(); 110 138 int getSize(); 111 //T* enumerate();112 139 bool inList(T* entity); 113 140 tIterator<T>* getIterator();
Note: See TracChangeset
for help on using the changeset viewer.