Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7957 in orxonox.OLD


Ignore:
Timestamp:
May 29, 2006, 4:52:10 PM (18 years ago)
Author:
patrick
Message:

cr: new collision check, less false trues

Location:
branches/cr/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/cr/src/lib/collision_detection/obb_tree_node.cc

    r7944 r7957  
    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    }
     495
     496    // right node
     497    if( this->nodeRight != NULL )
     498    {
     499      if( this->overlapTest(this->nodeRight->bvElement, treeNode->bvElement, nodeA, nodeB))
     500      {
     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);
     505      }
     506    }
     507
     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);
     524    }
     525
     526
     527
     528    /* check if left node overlaps */
     529//     if( this->nodeLeft != NULL )
     530//     {
     531//       PRINTF(5)("Checking OBB %i vs %i: ", this->nodeLeft->getIndex(), treeNode->getIndex());
     532//       if( this->overlapTest(this->nodeLeft->bvElement, treeNode->bvElement, nodeA, nodeB))
     533//       {
     534//         this->nodeLeft->collideWith(treeNode->nodeLeft, nodeA, nodeB);
     535//         this->nodeLeft->collideWith(treeNode->nodeRight, nodeA, nodeB);
     536//       }
     537//     }
     538
    493539    /* 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))
    498       {
    499         this->nodeRight->collideWith(treeNode->nodeLeft, nodeA, nodeB);
    500         this->nodeRight->collideWith(treeNode->nodeRight, nodeA, nodeB);
    501       }
    502     }
     540//     if( likely( this->nodeRight != NULL))
     541//     {
     542//       PRINTF(5)("Checking OBB %i vs %i: ", this->nodeRight->getIndex(), treeNode->getIndex());
     543//       if(this->overlapTest(this->nodeRight->bvElement, treeNode->bvElement, nodeA, nodeB))
     544//       {
     545//         this->nodeRight->collideWith(treeNode->nodeLeft, nodeA, nodeB);
     546//         this->nodeRight->collideWith(treeNode->nodeRight, nodeA, nodeB);
     547//       }
     548//     }
    503549
    504550    /* 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     {
     551//     if( unlikely((this->nodeRight == NULL || this->nodeLeft == NULL) ||
     552//                  (treeNode->nodeRight == NULL || treeNode->nodeLeft == NULL)) )
     553//     {
    508554//       nodeA->collidesWith(nodeB, treeNode->bvElement->center);
    509555//       nodeB->collidesWith(nodeA, this->bvElement->center);
    510       nodeA->registerCollision(nodeA, nodeB, (BoundingVolume*)this->bvElement, (BoundingVolume*)treeNode->bvElement);
    511     }
     556//       nodeA->registerCollision(nodeA, nodeB, (BoundingVolume*)this->bvElement, (BoundingVolume*)treeNode->bvElement);
     557//     }
    512558
    513559  }
  • branches/cr/src/world_entities/world_entity.cc

    r7955 r7957  
    294294bool WorldEntity::registerCollision(WorldEntity* entityA, WorldEntity* entityB, BoundingVolume* bvA, BoundingVolume* bvB)
    295295{
     296  PRINTF(0)("Registering Collision: %s vs %s \n", entityA->getClassName(), entityB->getClassName());
    296297  // create a collision event
    297298  Collision* c = CREngine::getInstance()->popCollisionObject();
Note: See TracChangeset for help on using the changeset viewer.