Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 4694 in orxonox.OLD for orxonox/trunk


Ignore:
Timestamp:
Jun 24, 2005, 6:10:13 PM (19 years ago)
Author:
patrick
Message:

orxonox/trunk: now ready to implement the collision detection algorithm

Location:
orxonox/trunk/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/src/lib/collision_detection/cd_engine.cc

    r4689 r4694  
    5959  tIterator<WorldEntity>* iterator2 = entityList->getIterator();
    6060  WorldEntity* entity1 = iterator1->nextElement();
    61   WorldEntity* entity2 = iterator2->nextElement();
     61  WorldEntity* entity2 = iterator2->seekElement(entity1);
     62  printf("checking for collisions\n");
    6263  while( entity1 != NULL)
    6364  {
    64     while( entity2 != NULL && entity1 != entity2)
     65    printf("entering l1\n");
     66    while( entity2 != NULL)
    6567    {
     68      printf("entering l2 - checking object %s against %s\n", entity1->getName(), entity2->getName());
    6669      entity1->collideWith(entity2);
    6770      entity2 = iterator2->nextElement();
     71
    6872    }
    6973    entity1 = iterator1->nextElement();
     74    entity2 = iterator2->seekElement(entity1);
     75
    7076  }
    7177  delete iterator1;
    7278  delete iterator2;
    73 
    74 
    7579}
    7680
  • orxonox/trunk/src/lib/util/list.h

    r4574 r4694  
    3434
    3535  T* nextElement();
     36  T* seekElement(T* element);
    3637
    3738 private:
    3839  listElement<T>*    currentEl;                      //!< pointer to the current list element in the iterator
    3940  listElement<T>*    tmpEl;                          //!< temp listElemnt pointer
     41  listElement<T>*    startElement;                   //!< pointer to the start of the list
    4042};
    4143
     
    6163  this->currentEl = startElement;
    6264  this->tmpEl = NULL;
     65  this->startElement = startElement;
    6366}
    6467
     
    8790  this->currentEl = this->currentEl->next;
    8891  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 */
     101template<class T>
     102inline 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;
    89117}
    90118
     
    109137  bool isEmpty();
    110138  int getSize();
    111   //T* enumerate();
    112139  bool inList(T* entity);
    113140  tIterator<T>* getIterator();
  • orxonox/trunk/src/subprojects/collision_detection/collision_detection.cc

    r4688 r4694  
    6565  entityList = new tList<WorldEntity>();
    6666
    67   TestEntity* a = new TestEntity();
    68   Environment* b = new Environment();
     67  TestEntity* a = new TestEntity(); a->setName("Clown1");
     68  Environment* b = new Environment(); b->setName("Jaeger");
    6969  b->setRelCoor(0.0, 0.0, -10.0);
     70
     71  TestEntity* c = new TestEntity(); c->setName("Colwn2");
     72  c->setRelCoor(0.0, 0.0, -20.0);
    7073
    7174  entityList->add(a);
    7275  entityList->add(b);
     76  entityList->add(c);
    7377
    7478  CDEngine::getInstance()->setEntityList(entityList);
     
    205209  dt = currentFrame - lastFrame;
    206210
    207   if( dt > 10)
     211  if( dt > 0)
    208212  {
    209213    float fps = 1000/dt;
    210214
    211215          // temporary, only for showing how fast the text-engine is
    212     char tmpChar[20];
    213     sprintf(tmpChar, "fps: %4.0f", fps);
     216    printf("we got %f fps\n", fps);
    214217  }
    215218  else
Note: See TracChangeset for help on using the changeset viewer.