Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6142 in orxonox.OLD for trunk/src/lib/collision_detection


Ignore:
Timestamp:
Dec 16, 2005, 7:13:57 PM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: merge the ObjectManager to the trunk
merged with command:
svn merge -r6082:HEAD objectmanager/ ../trunk/

conflicts resolution was easy this time :)
but specially merged the world to network_world

Location:
trunk/src/lib/collision_detection
Files:
2 edited

Legend:

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

    r6022 r6142  
    6565    be able to enhance iteration speed.
    6666 */
    67 void CDEngine::checkCollisions()
    68 {
    69   this->checkCollisionObjects();
     67//void CDEngine::checkCollisions()
     68//{
     69//  this->checkCollisionObjects();
    7070  //this->checkCollisionGround();
    71 }
    72 
    73 #include "class_list.h"
    74 #include "state.h"
     71//}
     72
    7573/**
    7674 *  this checks the collisions with the objects
    7775 */
    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
     109void CDEngine::checkCollisions(std::list<WorldEntity*>& list1, std::list<WorldEntity*>& list2)
    79110{
    80111  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, pre1, pre2;
    85113  PRINTF(3)("checking for collisions\n");
    86   while( entity1 != NULL)
     114
     115  pre1 = list1.begin();
     116  while (pre1 != list1.end())
    87117  {
    88     if( likely(entity1 != this->terrain))
     118    entity1 = pre1++;
     119    if( likely((*entity1) != this->terrain))
    89120    {
    90       entity2 = iterator2->nextElement();
    91 
    92       while( entity2 != NULL)
     121      pre2 = list2.begin();
     122      while (pre2 != list2.end())
    93123      {
    94         if( likely(entity2 != this->terrain))
     124        entity2 = pre2++;
     125        if( likely((*entity2) != this->terrain))
    95126        {
    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);
     127          PRINTF(4)("checking object %s against %s\n", (*entity1)->getName(), (*entity2)->getName());
     128          tree = (*entity1)->getOBBTree();
     129          if( likely(tree != NULL) && (*entity2)->getOBBTree() != NULL) tree->collideWith(*entity1, *entity2);
    99130        }
    100         entity2 = iterator2->nextElement();
    101131      }
    102132    }
    103     entity1 = iterator1->nextElement();
    104     entity2 = iterator2->iteratorElement(iterator1);
    105     entity2 = iterator2->nextElement();
    106133  }
    107   delete iterator1;
    108   delete iterator2;
    109134}
    110135
     
    134159  /* this would operate on  worldList bases, for testing purposes, we only use one OBBTree */
    135160  //this->rootTree->drawBV(depth, drawMode);
    136 
    137   tIterator<WorldEntity>* iterator = entityList->getIterator();
     161  /// FIXME
     162/*  tIterator<WorldEntity>* iterator = entityList->getIterator();
    138163  WorldEntity* entity = iterator->firstElement();
    139164  while( entity != NULL)
     
    142167    entity = iterator->nextElement();
    143168  }
    144   delete iterator;
     169  delete iterator;*/
    145170}
    146171
  • trunk/src/lib/collision_detection/cd_engine.h

    r6022 r6142  
    1212#include "model.h"
    1313
     14#include <list>
    1415
    15 template<class T> class tList;
    1616class WorldEntity;
    1717class OBBTree;
     
    4949  inline void disable(const int options) { int temp = this->state & options; this->state ^= temp; }
    5050
    51   inline void setEntityList(tList<WorldEntity>* entityList) { this->entityList = entityList; }
    5251  inline void setTerrain(Terrain* terrain) { this->terrain = terrain; }
    5352  //  inline void setPlayer(Player* player) { this->player = player; } /* only for debug purposes \todo: delete*/
     
    5554  void drawBV(int depth, int drawMode) const;
    5655
    57   void checkCollisions();
     56//  void checkCollisions();
     57  void checkCollisions(std::list<WorldEntity*>& list1, std::list<WorldEntity*>& list2);
    5858
    5959  void debug();
     
    7575 private:
    7676  int                     state;                            //!< the current state of the cd engine
    77   tList<WorldEntity>*     entityList;                       //!< pointer to the world entity list
    7877  OBBTree*                rootTree;                         //!< for testing purposes a root tree
    7978
Note: See TracChangeset for help on using the changeset viewer.