Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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


Ignore:
Timestamp:
Jun 7, 2006, 3:00:01 PM (19 years ago)
Author:
patrick
Message:

trunk: merged the cr branche to trunk

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

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/collision_detection/Makefile.am

    r5750 r8190  
    55
    66libORXcd_a_SOURCES = cd_engine.cc \
    7                      collision.cc \
    87                     obb.cc \
    98                     obb_tree.cc \
     
    1716noinst_HEADERS =     cd_engine.h \
    1817                     collision_defs.h \
    19                      collision.h \
    2018                     obb.h \
    2119                     obb_tree.h \
  • trunk/src/lib/collision_detection/obb_tree_node.cc

    r7736 r8190  
    481481    PRINTF(5)("collision @ lvl %i, object %s vs. %s, (%p, %p)\n", this->depth, nodeA->getClassName(), nodeB->getClassName(), this->nodeLeft, this->nodeRight);
    482482
    483     /* check if left node overlaps */
     483
     484    // left node
    484485    if( this->nodeLeft != NULL )
    485486    {
    486       PRINTF(5)("Checking OBB %i vs %i: ", this->nodeLeft->getIndex(), treeNode->getIndex());
    487487      if( this->overlapTest(this->nodeLeft->bvElement, treeNode->bvElement, nodeA, nodeB))
    488488      {
    489         this->nodeLeft->collideWith(treeNode->nodeLeft, nodeA, nodeB);
    490         this->nodeLeft->collideWith(treeNode->nodeRight, nodeA, nodeB);
     489        if( treeNode->nodeLeft != NULL)
     490          this->nodeLeft->collideWith(treeNode->nodeLeft, nodeA, nodeB);
     491        if( treeNode->nodeRight != NULL)
     492          this->nodeLeft->collideWith(treeNode->nodeRight, nodeA, nodeB);
    491493      }
    492494    }
    493     /* check if right node overlaps */
    494     if( likely( this->nodeRight != NULL))
    495     {
    496       PRINTF(5)("Checking OBB %i vs %i: ", this->nodeRight->getIndex(), treeNode->getIndex());
    497       if(this->overlapTest(this->nodeRight->bvElement, treeNode->bvElement, nodeA, nodeB))
     495
     496    // right node
     497    if( this->nodeRight != NULL )
     498    {
     499      if( this->overlapTest(this->nodeRight->bvElement, treeNode->bvElement, nodeA, nodeB))
    498500      {
    499         this->nodeRight->collideWith(treeNode->nodeLeft, nodeA, nodeB);
    500         this->nodeRight->collideWith(treeNode->nodeRight, nodeA, nodeB);
     501        if( treeNode->nodeLeft != NULL)
     502          this->nodeRight->collideWith(treeNode->nodeLeft, nodeA, nodeB);
     503        if( treeNode->nodeRight != NULL)
     504          this->nodeRight->collideWith(treeNode->nodeRight, nodeA, nodeB);
    501505      }
    502506    }
    503507
    504     /* so there is a collision and this is the last box in the tree (i.e. leaf) */
    505     if( unlikely((this->nodeRight == NULL || this->nodeLeft == NULL) ||
    506                  (treeNode->nodeRight == NULL || treeNode->nodeLeft == NULL)) )
    507     {
    508       nodeA->collidesWith(nodeB, treeNode->bvElement->center);
    509       nodeB->collidesWith(nodeA, this->bvElement->center);
     508
     509    // hybrid mode: we reached the end of this obbtree, now reach the end of the other tree
     510    if( this->nodeLeft == NULL && this->nodeRight == NULL)
     511    {
     512      if( treeNode->nodeLeft != NULL)
     513        this->collideWith(treeNode->nodeLeft, nodeA, nodeB);
     514      if( treeNode->nodeRight != NULL)
     515        this->collideWith(treeNode->nodeRight, nodeA, nodeB);
     516    }
     517
     518
     519    // now check if we reached the end of both trees
     520    if( unlikely((this->nodeRight == NULL && this->nodeLeft == NULL) &&
     521        (treeNode->nodeRight == NULL && treeNode->nodeLeft == NULL)) )
     522    {
     523      nodeA->registerCollision(nodeA, nodeB, (BoundingVolume*)this->bvElement, (BoundingVolume*)treeNode->bvElement);
    510524    }
    511525
Note: See TracChangeset for help on using the changeset viewer.