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

void btCollisionWorld::rayTest ( const btVector3 rayFromWorld,
const btVector3 rayToWorld,
RayResultCallback resultCallback,
short int  collisionFilterMask = -1 
) [inherited]

rayTest performs a raycast on all objects in the btCollisionWorld, and calls the resultCallback This allows for several queries: first hit, all hits, any hit, dependent on the value returned by the callback.

go over all objects, and if the ray intersects their aabb, do a ray-shape query using convexCaster (CCD)

Definition at line 326 of file btCollisionWorld.cpp.

References btCollisionWorld::rayTestSingle(), btTransform::setIdentity(), btTransform::setOrigin(), and btAlignedObjectArray< T >::size().

{

      
      btTransform rayFromTrans,rayToTrans;
      rayFromTrans.setIdentity();
      rayFromTrans.setOrigin(rayFromWorld);
      rayToTrans.setIdentity();
      
      rayToTrans.setOrigin(rayToWorld);

      /// go over all objects, and if the ray intersects their 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(collisionObject->getBroadphaseHandle()->m_collisionFilterGroup & collisionFilterMask) { 
                  //RigidcollisionObject* collisionObject = ctrl->GetRigidcollisionObject();
                  btVector3 collisionObjectAabbMin,collisionObjectAabbMax;
                  collisionObject->getCollisionShape()->getAabb(collisionObject->getWorldTransform(),collisionObjectAabbMin,collisionObjectAabbMax);

                  btScalar hitLambda = btScalar(1.); //could use resultCallback.m_closestHitFraction, but needs testing
                  btVector3 hitNormal;
                  if (btRayAabb(rayFromWorld,rayToWorld,collisionObjectAabbMin,collisionObjectAabbMax,hitLambda,hitNormal))
                  {
                        rayTestSingle(rayFromTrans,rayToTrans,
                              collisionObject,
                                    collisionObject->getCollisionShape(),
                                    collisionObject->getWorldTransform(),
                                    resultCallback);
                  }     
            }
      }

}


Generated by  Doxygen 1.6.0   Back to index