Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 4704 in orxonox.OLD


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
Files:
4 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}
  • orxonox/trunk/src/subprojects/collision_detection/collision_detection.cc

    r4701 r4704  
    3838int drawMode;
    3939int depth;
     40float iterata;
    4041tList<WorldEntity>* entityList;
    4142
     
    4344bool drawModel;
    4445
    45 TestEntity* a;
     46Environment* a;
    4647Environment* b;
    4748
     
    6869  entityList = new tList<WorldEntity>();
    6970
    70   a = new TestEntity(); a->setName("Clown1");
     71  //a = new TestEntity(); a->setName("Clown1");
     72  a = new Environment(); a->setName("Clown");
    7173  b = new Environment(); b->setName("Jaeger");
    7274  b->setRelCoor(0.0, 0.0, -10.0);
     
    9294  depth = 0;
    9395  dt = lastFrame = currentFrame = 0;
    94 
     96  iterata = 0.05f;
    9597
    9698  moduleHelp();
     
    198200          }
    199201          break;
     202        case SDLK_o:
     203          if(iterata == 0.0f)
     204          {
     205            iterata = 0.05f;
     206          }
     207          else
     208          {
     209            iterata = 0.0f;
     210          }
     211          break;
    200212
    201213      }
     
    227239  }
    228240
    229   b->shiftCoor(Vector(0.0, 0.0, 0.1));
     241  b->shiftCoor(Vector(0.0, 0.0, iterata));
    230242
    231243
Note: See TracChangeset for help on using the changeset viewer.