Search in sources :

Example 11 with ConvexShape

use of com.bulletphysics.collision.shapes.ConvexShape in project bdx by GoranM.

the class ConvexConvexAlgorithm method processCollision.

/**
	 * Convex-Convex collision algorithm.
	 */
@Override
public void processCollision(CollisionObject body0, CollisionObject body1, DispatcherInfo dispatchInfo, ManifoldResult resultOut) {
    if (manifoldPtr == null) {
        // swapped?
        manifoldPtr = dispatcher.getNewManifold(body0, body1);
        ownManifold = true;
    }
    resultOut.setPersistentManifold(manifoldPtr);
    //	#ifdef USE_BT_GJKEPA
    //		btConvexShape*				shape0(static_cast<btConvexShape*>(body0->getCollisionShape()));
    //		btConvexShape*				shape1(static_cast<btConvexShape*>(body1->getCollisionShape()));
    //		const btScalar				radialmargin(0/*shape0->getMargin()+shape1->getMargin()*/);
    //		btGjkEpaSolver::sResults	results;
    //		if(btGjkEpaSolver::Collide(	shape0,body0->getWorldTransform(),
    //									shape1,body1->getWorldTransform(),
    //									radialmargin,results))
    //			{
    //			dispatchInfo.m_debugDraw->drawLine(results.witnesses[1],results.witnesses[1]+results.normal,btVector3(255,0,0));
    //			resultOut->addContactPoint(results.normal,results.witnesses[1],-results.depth);
    //			}
    //	#else
    ConvexShape min0 = (ConvexShape) body0.getCollisionShape();
    ConvexShape min1 = (ConvexShape) body1.getCollisionShape();
    ClosestPointInput input = pointInputsPool.get();
    input.init();
    // JAVA NOTE: original: TODO: if (dispatchInfo.m_useContinuous)
    gjkPairDetector.setMinkowskiA(min0);
    gjkPairDetector.setMinkowskiB(min1);
    input.maximumDistanceSquared = min0.getMargin() + min1.getMargin() + manifoldPtr.getContactBreakingThreshold();
    input.maximumDistanceSquared *= input.maximumDistanceSquared;
    //input.m_stackAlloc = dispatchInfo.m_stackAllocator;
    //	input.m_maximumDistanceSquared = btScalar(1e30);
    body0.getWorldTransform(input.transformA);
    body1.getWorldTransform(input.transformB);
    gjkPairDetector.getClosestPoints(input, resultOut, dispatchInfo.debugDraw);
    pointInputsPool.release(input);
    if (ownManifold) {
        resultOut.refreshContactPoints();
    }
}
Also used : ClosestPointInput(com.bulletphysics.collision.narrowphase.DiscreteCollisionDetectorInterface.ClosestPointInput) ConvexShape(com.bulletphysics.collision.shapes.ConvexShape)

Aggregations

ConvexShape (com.bulletphysics.collision.shapes.ConvexShape)11 Vector3f (javax.vecmath.Vector3f)7 Transform (com.bulletphysics.linearmath.Transform)4 Stack (com.bulletphysics.util.Stack)4 VoronoiSimplexSolver (com.bulletphysics.collision.narrowphase.VoronoiSimplexSolver)3 LocationComponent (org.terasology.logic.location.LocationComponent)3 PairCachingGhostObject (com.bulletphysics.collision.dispatch.PairCachingGhostObject)2 ConvexCast (com.bulletphysics.collision.narrowphase.ConvexCast)2 CastResult (com.bulletphysics.collision.narrowphase.ConvexCast.CastResult)2 GjkConvexCast (com.bulletphysics.collision.narrowphase.GjkConvexCast)2 SubsimplexConvexCast (com.bulletphysics.collision.narrowphase.SubsimplexConvexCast)2 BvhTriangleMeshShape (com.bulletphysics.collision.shapes.BvhTriangleMeshShape)2 CollisionShape (com.bulletphysics.collision.shapes.CollisionShape)2 CompoundShape (com.bulletphysics.collision.shapes.CompoundShape)2 ConcaveShape (com.bulletphysics.collision.shapes.ConcaveShape)2 SphereShape (com.bulletphysics.collision.shapes.SphereShape)2 KinematicCharacterController (com.bulletphysics.dynamics.character.KinematicCharacterController)2 ClosestPointInput (com.bulletphysics.collision.narrowphase.DiscreteCollisionDetectorInterface.ClosestPointInput)1 GjkEpaPenetrationDepthSolver (com.bulletphysics.collision.narrowphase.GjkEpaPenetrationDepthSolver)1 CapsuleShape (com.bulletphysics.collision.shapes.CapsuleShape)1