Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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


Ignore:
Timestamp:
Jun 26, 2005, 4:13:11 PM (19 years ago)
Author:
patrick
Message:

orxonox/trunk: now collision detection is accurate. Now I have to tune the code, so the cd becomes faster

Location:
orxonox/trunk/src/lib/collision_detection
Files:
3 edited

Legend:

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

    r4695 r4704  
    6666  WorldEntity* entity1 = iterator1->nextElement();
    6767  WorldEntity* entity2 = iterator2->seekElement(entity1);
    68   printf("checking for collisions\n");
     68  PRINTF(3)("checking for collisions\n");
    6969  while( entity1 != NULL)
    7070  {
    71     printf("entering l1\n");
    7271    while( entity2 != NULL)
    7372    {
    74       printf("entering l2 - checking object %s against %s\n", entity1->getName(), entity2->getName());
     73      PRINTF(3)("checking object %s against %s\n", entity1->getName(), entity2->getName());
    7574      entity1->collideWith(entity2);
    7675      entity2 = iterator2->nextElement();
  • orxonox/trunk/src/lib/collision_detection/obb.cc

    r4660 r4704  
    3131   this->axis = new Vector[3];
    3232   this->halfLength = new float[3];
     33   this->bCollided = false;
    3334}
    3435
  • orxonox/trunk/src/lib/collision_detection/obb_tree_node.cc

    r4703 r4704  
    609609  PRINTF(0)("collideWith\n");
    610610  /* if the obb overlap, make subtests: check which node is realy overlaping  */
     611  PRINT(0)("Checking OBB %i vs %i: ", this->getIndex(), treeNode->getIndex());
    611612  if( this->overlapTest(this->bvElement, ((OBBTreeNode*)treeNode)->bvElement, nodeA, nodeB))
    612613  {
    613614    /* check if left node overlaps */
    614     if( unlikely( this->nodeLeft != NULL))
     615    if( likely( this->nodeLeft != NULL))
     616    {
     617      PRINT(0)("Checking OBB %i vs %i: ", this->nodeLeft->getIndex(), treeNode->getIndex());
    615618      if( this->overlapTest(this->nodeLeft->bvElement, ((OBBTreeNode*)treeNode)->bvElement, nodeA, nodeB))
     619      {
    616620        this->nodeLeft->collideWith(((OBBTreeNode*)treeNode)->nodeLeft, nodeA, nodeB);
     621        this->nodeLeft->collideWith(((OBBTreeNode*)treeNode)->nodeRight, nodeA, nodeB);
     622      }
     623    }
    617624    /* check if right node overlaps */
    618     if( unlikely( this->nodeRight != NULL))
     625    if( likely( this->nodeRight != NULL))
     626    {
     627      PRINT(0)("Checking OBB %i vs %i: ", this->nodeRight->getIndex(), treeNode->getIndex());
    619628      if(this->overlapTest(this->nodeRight->bvElement, ((OBBTreeNode*)treeNode)->bvElement, nodeA, nodeB))
    620         this->nodeLeft->collideWith(((OBBTreeNode*)treeNode)->nodeRight, nodeA, nodeB);
     629      {
     630       this->nodeRight->collideWith(((OBBTreeNode*)treeNode)->nodeLeft, nodeA, nodeB);
     631       this->nodeRight->collideWith(((OBBTreeNode*)treeNode)->nodeRight, nodeA, nodeB);
     632      }
     633    }
    621634  }
    622635}
     
    626639bool OBBTreeNode::overlapTest(OBB* boxA, OBB* boxB, PNode* nodeA, PNode* nodeB)
    627640{
     641
    628642
    629643
     
    641655      l = boxA->axis[j];
    642656
     657      /* \todo unroll all loops */
    643658      for(int i = 0; i < 3; ++i)
    644659        rA += fabs(boxA->halfLength[i] * boxA->axis[i].dot(l));
     
    651666      if( (rA + rB) < fabs(t.dot(l)))
    652667      {
    653         PRINTF(0)(" - Keine Kollision in der Bahnfohstrasse! Passagiere der Linien 6, 14 sind gebeten zu fliegen!\n");
     668        PRINT(0)("keine Kollision\n");
     669        PRINTF(3)(" - Keine Kollision in der Bahnfohstrasse! Passagiere der Linien 6, 14 sind gebeten zu fliegen!\n");
    654670        return false;
    655671      }
     
    673689      if( (rA + rB) < fabs(t.dot(l)))
    674690      {
    675         PRINTF(0)(" - Keine Kollision in der Bahnfohstrasse! Passagiere der Linien 6, 14 sind gebeten zu fliegen!\n");
     691        PRINT(0)("keine Kollision\n");
     692        PRINTF(3)(" - Keine Kollision in der Bahnfohstrasse! Passagiere der Linien 6, 14 sind gebeten zu fliegen!\n");
    676693        return false;
    677694      }
     
    699716          if( (rA + rB) < fabs(t.dot(l)))
    700717          {
    701             PRINTF(0)(" - Keine Kollision in der Bahnfohstrasse! Passagiere der Linien 6, 14 sind gebeten zu fliegen!\n");
     718            PRINT(0)("keine Kollision\n");
     719            PRINTF(3)(" - Keine Kollision in der Bahnfohstrasse! Passagiere der Linien 6, 14 sind gebeten zu fliegen!\n");
    702720            return false;
    703721          }
     
    710728    boxA->bCollided = true; /* use this ONLY!!!! for drawing operations */
    711729    boxB->bCollided = true;
     730    PRINT(0)("Kollision!\n");
    712731    return true;
    713732}
Note: See TracChangeset for help on using the changeset viewer.