Logo Search packages:      
Sourcecode: blender version File versions  Download package

void btCollisionWorld::convexSweepTest ( const btConvexShape *  castShape,
const btTransform from,
const btTransform to,
ConvexResultCallback resultCallback,
btScalar  allowedCcdPenetration = btScalar(0.) 
) const [inherited]

use the broadphase to accelerate the search for objects, based on their aabb and for each object with ray-aabb overlap, perform an exact ray test unfortunately the implementation for rayTest and convexSweepTest duplicated, albeit practically identical

Definition at line 776 of file btCollisionWorld.cpp.

References btTransform::getOrigin(), btTransform::getRotation(), btCollisionWorld::ConvexResultCallback::needsCollision(), btCollisionWorld::objectQuerySingle(), btBroadphaseInterface::rayTest(), btTransform::setIdentity(), btTransform::setRotation(), and btAlignedObjectArray< T >::size().

{

      BT_PROFILE("convexSweepTest");
      /// use the broadphase to accelerate the search for objects, based on their aabb
      /// and for each object with ray-aabb overlap, perform an exact ray test
      /// unfortunately the implementation for rayTest and convexSweepTest duplicated, albeit practically identical

      

      btTransform convexFromTrans,convexToTrans;
      convexFromTrans = convexFromWorld;
      convexToTrans = convexToWorld;
      btVector3 castShapeAabbMin, castShapeAabbMax;
      /* Compute AABB that encompasses angular movement */
      {
            btVector3 linVel, angVel;
            btTransformUtil::calculateVelocity (convexFromTrans, convexToTrans, 1.0, linVel, angVel);
            btVector3 zeroLinVel;
            zeroLinVel.setValue(0,0,0);
            btTransform R;
            R.setIdentity ();
            R.setRotation (convexFromTrans.getRotation());
            castShape->calculateTemporalAabb (R, zeroLinVel, angVel, 1.0, castShapeAabbMin, castShapeAabbMax);
      }

#ifndef USE_BRUTEFORCE_RAYBROADPHASE

      btSingleSweepCallback   convexCB(castShape,convexFromWorld,convexToWorld,this,resultCallback,allowedCcdPenetration);

      m_broadphasePairCache->rayTest(convexFromTrans.getOrigin(),convexToTrans.getOrigin(),convexCB,castShapeAabbMin,castShapeAabbMax);

#else
      /// go over all objects, and if the ray intersects their aabb + cast shape aabb,
      // do a ray-shape query using convexCaster (CCD)
      int i;
      for (i=0;i<m_collisionObjects.size();i++)
      {
            btCollisionObject*      collisionObject= m_collisionObjects[i];
            //only perform raycast if filterMask matches
            if(resultCallback.needsCollision(collisionObject->getBroadphaseHandle())) {
                  //RigidcollisionObject* collisionObject = ctrl->GetRigidcollisionObject();
                  btVector3 collisionObjectAabbMin,collisionObjectAabbMax;
                  collisionObject->getCollisionShape()->getAabb(collisionObject->getWorldTransform(),collisionObjectAabbMin,collisionObjectAabbMax);
                  AabbExpand (collisionObjectAabbMin, collisionObjectAabbMax, castShapeAabbMin, castShapeAabbMax);
                  btScalar hitLambda = btScalar(1.); //could use resultCallback.m_closestHitFraction, but needs testing
                  btVector3 hitNormal;
                  if (btRayAabb(convexFromWorld.getOrigin(),convexToWorld.getOrigin(),collisionObjectAabbMin,collisionObjectAabbMax,hitLambda,hitNormal))
                  {
                        objectQuerySingle(castShape, convexFromTrans,convexToTrans,
                              collisionObject,
                                    collisionObject->getCollisionShape(),
                                    collisionObject->getWorldTransform(),
                                    resultCallback,
                                    allowedCcdPenetration);
                  }
            }
      }
#endif //USE_BRUTEFORCE_RAYBROADPHASE
}


Generated by  Doxygen 1.6.0   Back to index