Ejemplo n.º 1
0
        public override btBroadphasePair addOverlappingPair(btBroadphaseProxy proxy0, btBroadphaseProxy proxy1)
        {
            global::System.IntPtr cPtr = BulletPINVOKE.btHashedOverlappingPairCache_addOverlappingPair(swigCPtr, btBroadphaseProxy.getCPtr(proxy0), btBroadphaseProxy.getCPtr(proxy1));
            btBroadphasePair      ret  = (cPtr == global::System.IntPtr.Zero) ? null : new btBroadphasePair(cPtr, false);

            return(ret);
        }
Ejemplo n.º 2
0
        public override btBroadphasePair getOverlappingPairArrayPtr()
        {
            global::System.IntPtr cPtr = BulletPINVOKE.btHashedOverlappingPairCache_getOverlappingPairArrayPtr__SWIG_0(swigCPtr);
            btBroadphasePair      ret  = (cPtr == global::System.IntPtr.Zero) ? null : new btBroadphasePair(cPtr, false);

            return(ret);
        }
Ejemplo n.º 3
0
        public virtual btBroadphasePair findPair(btBroadphaseProxy proxy0, btBroadphaseProxy proxy1)
        {
            global::System.IntPtr cPtr = BulletPINVOKE.btOverlappingPairCache_findPair(swigCPtr, btBroadphaseProxy.getCPtr(proxy0), btBroadphaseProxy.getCPtr(proxy1));
            btBroadphasePair      ret  = (cPtr == global::System.IntPtr.Zero) ? null : new btBroadphasePair(cPtr, false);

            return(ret);
        }
Ejemplo n.º 4
0
 public btBroadphasePair(btBroadphasePair other) : this(BulletPINVOKE.new_btBroadphasePair__SWIG_1(btBroadphasePair.getCPtr(other)), true)
 {
     if (BulletPINVOKE.SWIGPendingException.Pending)
     {
         throw BulletPINVOKE.SWIGPendingException.Retrieve();
     }
 }
Ejemplo n.º 5
0
        public override btBroadphasePair findPair(btBroadphaseProxy arg0, btBroadphaseProxy arg1)
        {
            global::System.IntPtr cPtr = BulletPINVOKE.btNullPairCache_findPair(swigCPtr, btBroadphaseProxy.getCPtr(arg0), btBroadphaseProxy.getCPtr(arg1));
            btBroadphasePair      ret  = (cPtr == global::System.IntPtr.Zero) ? null : new btBroadphasePair(cPtr, false);

            return(ret);
        }
Ejemplo n.º 6
0
 public override void cleanOverlappingPair(btBroadphasePair pair, btDispatcher dispatcher)
 {
     BulletPINVOKE.btHashedOverlappingPairCache_cleanOverlappingPair(swigCPtr, btBroadphasePair.getCPtr(pair), btDispatcher.getCPtr(dispatcher));
     if (BulletPINVOKE.SWIGPendingException.Pending)
     {
         throw BulletPINVOKE.SWIGPendingException.Retrieve();
     }
 }
Ejemplo n.º 7
0
 public static void defaultNearCallback(btBroadphasePair collisionPair, btCollisionDispatcher dispatcher, btDispatcherInfo dispatchInfo)
 {
     BulletPINVOKE.btCollisionDispatcher_defaultNearCallback(btBroadphasePair.getCPtr(collisionPair), btCollisionDispatcher.getCPtr(dispatcher), btDispatcherInfo.getCPtr(dispatchInfo));
     if (BulletPINVOKE.SWIGPendingException.Pending)
     {
         throw BulletPINVOKE.SWIGPendingException.Retrieve();
     }
 }
Ejemplo n.º 8
0
 public override void cleanOverlappingPair(btBroadphasePair arg0, btDispatcher arg1)
 {
     BulletPINVOKE.btNullPairCache_cleanOverlappingPair(swigCPtr, btBroadphasePair.getCPtr(arg0), btDispatcher.getCPtr(arg1));
     if (BulletPINVOKE.SWIGPendingException.Pending)
     {
         throw BulletPINVOKE.SWIGPendingException.Retrieve();
     }
 }
Ejemplo n.º 9
0
        public virtual bool processOverlap(btBroadphasePair pair)
        {
            bool ret = BulletPINVOKE.btOverlapCallback_processOverlap(swigCPtr, btBroadphasePair.getCPtr(pair));

            if (BulletPINVOKE.SWIGPendingException.Pending)
            {
                throw BulletPINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
Ejemplo n.º 10
0
 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(btBroadphasePair obj)
 {
     return((obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr);
 }
Ejemplo n.º 11
0
        // Portable static method: prerequisite call: m_dynamicsWorld.getBroadphase().getOverlappingPairCache().setInternalGhostPairCallback(new btGhostPairCallback());
        public static void GetCollidingObjectsInsidePairCachingGhostObject(DiscreteDynamicsWorld m_dynamicsWorld, PairCachingGhostObject m_pairCachingGhostObject, ObjectArray <CollisionObject> collisionArrayOut)
        {
            bool addOnlyObjectsWithNegativeDistance = true;     // With "false" things don't change much, and the code is a bit faster and cleaner...


            collisionArrayOut.Resize(0);
            if (m_pairCachingGhostObject == null || m_dynamicsWorld == null)
            {
                return;
            }

            //#define USE_PLAIN_COLLISION_WORLD // We dispatch all collision pairs of the ghost object every step (slow)
#if USE_PLAIN_COLLISION_WORLD
            //======================================================================================================
            // I thought this line was no longer needed, but it seems to be necessary (and I believe it's an expensive call):
            m_dynamicsWorld.getDispatcher().dispatchAllCollisionPairs(m_pairCachingGhostObject.getOverlappingPairCache(), m_dynamicsWorld.getDispatchInfo(), m_dynamicsWorld.getDispatcher());
            // Maybe the call can be automatically triggered by some other Bullet call (I'm almost sure I could comment it out in another demo I made long ago...)
            // So by now the general rule is: in real projects, simply comment it out and see if it works!
            //======================================================================================================
            // UPDATE: in dynamic worlds, the line above can be commented out and the broadphase pair can be retrieved through the call to findPair(...) below.
            // In collision worlds probably the above line is needed only if collision detection for all the bodies hasn't been made... This is something
            // I'm still not sure of... the general rule is to try to comment out the line above and try to use findPair(...) and see if it works whenever possible....
            //======================================================================================================
#endif //USE_PLAIN_COLLISION_WORLD

            ObjectArray <BroadphasePair> collisionPairs = m_pairCachingGhostObject.GetOverlappingPairCache().GetOverlappingPairArray();
            int numObjects = collisionPairs.Count;
            PersistentManifoldArray m_manifoldArray = new PersistentManifoldArray();
            bool added;
            for (int i = 0; i < numObjects; i++)
            {
                m_manifoldArray.Resize(0);

#if USE_PLAIN_COLLISION_WORLD
                const btBroadphasePair& collisionPair = collisionPairs[i];
                if (collisionPair.m_algorithm)
                {
                    collisionPair.m_algorithm.getAllContactManifolds(m_manifoldArray);
                }
                else    // THIS SHOULD NEVER HAPPEN, AND IF IT DOES, PLEASE RE-ENABLE the "call" a few lines above...
                {
                    printf("No collisionPair.m_algorithm - probably m_dynamicsWorld.getDispatcher().dispatchAllCollisionPairs(...) must be missing.\n");
                }
#else // USE_PLAIN_COLLISION_WORLD
                BroadphasePair cPair = collisionPairs[i];
                //unless we manually perform collision detection on this pair, the contacts are in the dynamics world paircache:
                BroadphasePair collisionPair = m_dynamicsWorld.GetPairCache().FindPair(cPair.m_pProxy0, cPair.m_pProxy1);
                if (collisionPair == null)
                {
                    continue;
                }
                if (collisionPair.m_algorithm != null)
                {
                    collisionPair.m_algorithm.GetAllContactManifolds(m_manifoldArray);
                }
                else
                {       // THIS SHOULD NEVER HAPPEN, AND IF IT DOES, PLEASE RE-ENABLE the "call" a few lines above...
                    //printf("No collisionPair.m_algorithm - probably m_dynamicsWorld.getDispatcher().dispatchAllCollisionPairs(...) must be missing.\n");
                }
#endif //USE_PLAIN_COLLISION_WORLD

                added = false;
                for (int j = 0; j < m_manifoldArray.Count; j++)
                {
                    PersistentManifold manifold = m_manifoldArray[j];
                    // Here we are in the narrowphase, but can happen that manifold.getNumContacts()==0:
                    if (addOnlyObjectsWithNegativeDistance)
                    {
                        for (int p = 0, numContacts = manifold.GetNumContacts(); p < numContacts; p++)
                        {
                            ManifoldPoint pt = manifold.GetContactPoint(p);
                            if (pt.GetDistance() < 0.0)
                            {
                                // How can I be sure that the colObjs are all distinct ? I use the "added" flag.
                                collisionArrayOut.Add((CollisionObject)(manifold.GetBody0() == m_pairCachingGhostObject ? manifold.GetBody1() : manifold.GetBody0()));
                                added = true;
                                break;
                            }
                        }
                        if (added)
                        {
                            break;
                        }
                    }
                    else if (manifold.GetNumContacts() > 0)
                    {
                        collisionArrayOut.Add((CollisionObject)(manifold.GetBody0() == m_pairCachingGhostObject ? manifold.GetBody1() : manifold.GetBody0()));
                        break;
                    }
                }
            }
        }
Ejemplo n.º 12
0
	virtual bool	processOverlap(btBroadphasePair& pair)
	{
		(void)pair;
		Debug.Assert(false);
		return false;
	}
Ejemplo n.º 13
0
	virtual bool processOverlap(btBroadphasePair& pair)
	{
		return (!btSimpleBroadphase::aabbOverlap(static_cast<btSimpleBroadphaseProxy*>(pair.m_pProxy0),static_cast<btSimpleBroadphaseProxy*>(pair.m_pProxy1)));
	}
Ejemplo n.º 14
0
	virtual bool processOverlap(btBroadphasePair& pair)
	{
		btSimpleBroadphaseProxy* proxy0 = static_cast<btSimpleBroadphaseProxy*>(pair.m_pProxy0);
		btSimpleBroadphaseProxy* proxy1 = static_cast<btSimpleBroadphaseProxy*>(pair.m_pProxy1);

		return ((m_targetProxy == proxy0 || m_targetProxy == proxy1));
	};