Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6921 in orxonox.OLD for branches/current_cd/src/lib


Ignore:
Timestamp:
Jan 31, 2006, 11:05:36 PM (19 years ago)
Author:
patrick
Message:

cd: collision algorithm works almost

Location:
branches/current_cd/src/lib/collision_detection
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/current_cd/src/lib/collision_detection/cd_engine.cc

    r6911 r6921  
    5959
    6060/**
    61  *  this is the collision checking function
    62 
    63     there are some speed improvements that can be done here. a rewrite of the list a would be appropriate to
    64     be able to enhance iteration speed.
     61 *
    6562 */
    66 //void CDEngine::checkCollisions()
    67 //{
    68 //  this->checkCollisionObjects();
    69   //this->checkCollisionGround();
    70 //}
    71 
    72 /**
    73  *  this checks the collisions with the objects
    74  */
    75 //void CDEngine::checkCollisionObjects()
    76 //{
    77 //   BVTree* tree;
    78 //   tIterator<WorldEntity>* iterator1 = entityList->getIterator();
    79 //   tIterator<WorldEntity>* iterator2 = entityList->getIterator();
    80 //   WorldEntity* entity1 = iterator1->firstElement();
    81 //   WorldEntity* entity2 = iterator2->iteratorElement(iterator1);
    82 //   PRINTF(3)("checking for collisions\n");
    83 //   while( entity1 != NULL)
    84 //   {
    85 //     if( likely(entity1 != this->terrain))
    86 //     {
    87 //       entity2 = iterator2->nextElement();
    88 //
    89 //       while( entity2 != NULL)
    90 //       {
    91 //         if( likely(entity2 != this->terrain))
    92 //         {
    93 //           PRINTF(4)("checking object %s against %s\n", entity1->getName(), entity2->getName());
    94 //           tree = entity1->getOBBTree();
    95 //           if( likely(tree != NULL) && entity2->getOBBTree() != NULL) tree->collideWith(entity1, entity2);
    96 //         }
    97 //         entity2 = iterator2->nextElement();
    98 //       }
    99 //     }
    100 //     entity1 = iterator1->nextElement();
    101 //     entity2 = iterator2->iteratorElement(iterator1);
    102 //     entity2 = iterator2->nextElement();
    103 //   }
    104 //   delete iterator1;
    105 //   delete iterator2;
    106 //}
    107 
    10863void CDEngine::checkCollisions(std::list<WorldEntity*>& list1, std::list<WorldEntity*>& list2)
    10964{
     
    151106
    152107/**
    153  *  this draws the bounding volume tree
    154  * @param depth until which depth to draw the tree
    155  * @param drawMode mod which states how to draw it
    156  */
    157 void CDEngine::drawBV(int depth, int drawMode) const
    158 {
    159   /* this would operate on  worldList bases, for testing purposes, we only use one OBBTree */
    160   //this->rootTree->drawBV(depth, drawMode);
    161   /// FIXME
    162 /*  tIterator<WorldEntity>* iterator = entityList->getIterator();
    163   WorldEntity* entity = iterator->firstElement();
    164   while( entity != NULL)
    165   {
    166     entity->drawBVTree(depth, drawMode);
    167     entity = iterator->nextElement();
    168   }
    169   delete iterator;*/
    170 }
    171 
    172 
    173 /**
    174108 * some debug output on the class
    175109 */
     
    199133  std::list<WorldEntity*>::const_iterator entity;
    200134  for (entity = drawList.begin(); entity != drawList.end(); entity++)
    201     if ((*entity)->isVisible())
    202       (*entity)->drawBVTree(3, 226);
     135    (*entity)->drawBVTree(1, 226);
    203136}
    204137
  • branches/current_cd/src/lib/collision_detection/cd_engine.h

    r6316 r6921  
    5050
    5151  inline void setTerrain(Terrain* terrain) { this->terrain = terrain; }
    52   //  inline void setPlayer(Player* player) { this->player = player; } /* only for debug purposes \todo: delete*/
    5352
    54   void drawBV(int depth, int drawMode) const;
    55 
    56 //  void checkCollisions();
    5753  void checkCollisions(std::list<WorldEntity*>& list1, std::list<WorldEntity*>& list2);
    5854
  • branches/current_cd/src/lib/collision_detection/obb_tree_node.cc

    r6919 r6921  
    515515
    516516
    517 void OBBTreeNode::collideWith(const BVTreeNode& treeNode, WorldEntity* nodeA, WorldEntity* nodeB)
    518 {
     517void OBBTreeNode::collideWith(BVTreeNode* treeNode, WorldEntity* nodeA, WorldEntity* nodeB)
     518{
     519  if( unlikely(treeNode == 1))
     520    return;
     521
    519522  PRINTF(3)("collideWith\n");
    520523  /* if the obb overlap, make subtests: check which node is realy overlaping  */
     
    772775    }
    773776
    774     if( this->nodeLeft == NULL || this->nodeRight == NULL)
     777    if( this->nodeLeft == NULL && this->nodeRight == NULL)
    775778      depth = 0;
     779
    776780    if( !(drawMode & DRAW_SINGLE && depth != 0))
    777781    {
     782      PRINTF(0)("debug poly draw: depth: %i, mode: %i\n", depth, drawMode);
     783
    778784      Vector cen = this->bvElement->center;
    779785      Vector* axis = this->bvElement->axis;
Note: See TracChangeset for help on using the changeset viewer.