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

void btConvexPlaneCollisionAlgorithm::collideSingleContact ( const btQuaternion perturbeRot,
btCollisionObject *  body0,
btCollisionObject *  body1,
const btDispatcherInfo &  dispatchInfo,
btManifoldResult resultOut 
)

report a contact. internally this will be kept persistent, and contact reduction is done

Definition at line 53 of file btConvexPlaneCollisionAlgorithm.cpp.

References btManifoldResult::addContactPoint(), btTransform::getBasis(), btStaticPlaneShape::getPlaneConstant(), btStaticPlaneShape::getPlaneNormal(), btTransform::inverse(), and btManifoldResult::setPersistentManifold().

{
    btCollisionObject* convexObj = m_isSwapped? body1 : body0;
      btCollisionObject* planeObj = m_isSwapped? body0: body1;

      btConvexShape* convexShape = (btConvexShape*) convexObj->getCollisionShape();
      btStaticPlaneShape* planeShape = (btStaticPlaneShape*) planeObj->getCollisionShape();

    bool hasCollision = false;
      const btVector3& planeNormal = planeShape->getPlaneNormal();
      const btScalar& planeConstant = planeShape->getPlaneConstant();
      
      btTransform convexWorldTransform = convexObj->getWorldTransform();
      btTransform convexInPlaneTrans;
      convexInPlaneTrans= planeObj->getWorldTransform().inverse() * convexWorldTransform;
      //now perturbe the convex-world transform
      convexWorldTransform.getBasis()*=btMatrix3x3(perturbeRot);
      btTransform planeInConvex;
      planeInConvex= convexWorldTransform.inverse() * planeObj->getWorldTransform();
      
      btVector3 vtx = convexShape->localGetSupportingVertex(planeInConvex.getBasis()*-planeNormal);

      btVector3 vtxInPlane = convexInPlaneTrans(vtx);
      btScalar distance = (planeNormal.dot(vtxInPlane) - planeConstant);

      btVector3 vtxInPlaneProjected = vtxInPlane - distance*planeNormal;
      btVector3 vtxInPlaneWorld = planeObj->getWorldTransform() * vtxInPlaneProjected;

      hasCollision = distance < m_manifoldPtr->getContactBreakingThreshold();
      resultOut->setPersistentManifold(m_manifoldPtr);
      if (hasCollision)
      {
            /// report a contact. internally this will be kept persistent, and contact reduction is done
            btVector3 normalOnSurfaceB = planeObj->getWorldTransform().getBasis() * planeNormal;
            btVector3 pOnB = vtxInPlaneWorld;
            resultOut->addContactPoint(normalOnSurfaceB,pOnB,distance);
      }
}


Generated by  Doxygen 1.6.0   Back to index