Beispiel #1
0
        public override bool process(BroadphaseProxy proxy)
        {
            ///terminate further ray tests, once the closestHitFraction reached zero
            if (aabbMin == aabbMax)
            {
                return(false);
            }

            CollisionObject collisionObject = proxy.clientObject;

            PersistentManifold result = new PersistentManifold(this.collisionObject, collisionObject);
            //only perform raycast if filterMask matches

            CollisionAlgorithm algorithm = dispatcher.findAlgorithm(collisionObject, this.collisionObject);

            algorithm(collisionObject, this.collisionObject,
                      dispatcher.getDispatchInfo(),
                      result);

            if (result.getContactPointsNum() > 0)
            {
                results.Add(result);
            }

            return(true);
        }
Beispiel #2
0
        public override bool handleCollision(BroadphasePair collisionPair, CollisionDispatcher dispatcher)
        {
            CollisionObject colObj0 = collisionPair.pProxy0.clientObject;
            CollisionObject colObj1 = collisionPair.pProxy1.clientObject;

            if (colObj0.isStaticOrKinematicObject() && colObj1.isStaticOrKinematicObject())
            {
                collisionPair.manifold.clearManifold();
                return(false);
            }

            PersistentManifold manifold = collisionPair.manifold;
            int oldContacts             = manifold.getContactPointsNum();

            manifold.refreshContactPoints(colObj0.getWorldTransform(), colObj1.getWorldTransform());

            /*if (oldContacts == manifold.getContactPointsNum() && oldContacts > 0)
             *  return true;*/

            manifold.clearManifold();
            CollisionAlgorithm algorithm = dispatcher.findAlgorithm(colObj0, colObj1);

            // discrete collision detection query
            algorithm(colObj0, colObj1, dispatcher.getDispatchInfo(), manifold);
            return(manifold.getContactPointsNum() > 0);
        }
Beispiel #3
0
 /// <summary>
 /// Resets this contact set to default values.
 /// </summary>
 /// <param name="objectA">The first collision object.</param>
 /// <param name="objectB">The second collision object.</param>
 /// <remarks>
 /// This method allows to re-use an existing contact set instead of allocating a new instance on
 /// the heap. This avoids garbage on the heap. In general, this method must only be used by the
 /// creator of this instance. If the <see cref="ContactSet"/> was created by the collision
 /// detection, this method should not be used.
 /// </remarks>
 public void Reset(CollisionObject objectA, CollisionObject objectB)
 {
     ObjectA                   = objectA;
     ObjectB                   = objectB;
     IsValid                   = true;
     PreferredNormal           = Vector3.Zero;
     HaveContact               = false;
     IsPerturbationTestAllowed = true;
     CanCollide                = -1;
     CollisionAlgorithm        = null;
     Clear();
 }
        public DefaultCollisionConfiguration()
        {
            sphereSphereCF   = SphereSphereCollisionAlgorithm.processCollision;
            sphereBoxCF      = SphereBoxCollisionAlgorithm.processCollision;
            sphereCapsuleCF  = SphereCapsuleCollisionAlgorithm.processCollision;
            capsuleCapsuleCF = CapsuleCapsuleCollisionAlgorithm.processCollision;
            boxCapsuleCF     = BoxCapsuleCollisionAlgorithm.processCollision;
            boxBoxCF         = BoxBoxCollisionAlgorithm.processCollision;
            emptyCreateFunc  = EmptyAlgorithm.processCollision;

            emptyRaytestFunc   = EmptyRaytestAlgorithm.rayTestSingle;
            sphereRaytestFunc  = SphereRaytestAlgorithm.rayTestSingle;
            boxRaytestFunc     = BoxRaytestAlgorithm.rayTestSingle;
            capsuleRaytestFunc = CapsuleRaytestAlgorithm.rayTestSingle;

            emptySweepFunc          = EmptySweepFunc.objectQuerySingle;
            sphereBoxSweepFunc      = SphereBoxSweepAlgorithm.objectQuerySingle;
            sphereSphereSweepFunc   = SphereSphereSweepAlgorithm.objectQuerySingle;
            sphereCapsuleSweepFunc  = SphereCapsuleSweepAlgorithm.objectQuerySingle;
            capsuleCapsuleSweepFunc = CapsuleCapsuleSweepAlgorithm.objectQuerySingle;
            capsuleBoxSweepFunc     = CapsuleBoxSweepAlgorithm.objectQuerySingle;
        }
Beispiel #5
0
        public override CollisionAlgorithm findAlgorithm(CollisionObject body0, CollisionObject body1)
        {
            CollisionAlgorithm algo = doubleDispatch[(int)body0.getCollisionShape().getShapeType(), (int)body1.getCollisionShape().getShapeType()];

            return(algo);
        }