// return true when pairs need collision
		public virtual bool NeedBroadphaseCollision(BroadphaseProxy childProxy0,BroadphaseProxy childProxy1)
		{
			BroadphaseProxy multiProxy0 = (BroadphaseProxy)childProxy0.m_multiSapParentProxy;
			BroadphaseProxy multiProxy1 = (BroadphaseProxy)childProxy1.m_multiSapParentProxy;
			
			bool collides = (multiProxy0.m_collisionFilterGroup & multiProxy1.m_collisionFilterMask) != 0;
			collides = collides && ((multiProxy1.m_collisionFilterGroup & multiProxy0.m_collisionFilterMask) != 0);
	
			return collides;
		}
Example #2
0
 public override bool Process(BroadphaseProxy proxy)
 {
     return(true);
 }
Example #3
0
 public RemovePairCallback(BroadphaseProxy obsoleteProxy)
 {
     m_obsoleteProxy = obsoleteProxy;
 }
Example #4
0
 public virtual void RemoveOverlappingPairsContainingProxy(BroadphaseProxy proxy0, IDispatcher dispatcher)
 {
 }
Example #5
0
 public virtual BroadphasePair AddOverlappingPair(BroadphaseProxy proxy0, BroadphaseProxy proxy1)
 {
     return null;
 }
Example #6
0
 public abstract void removeOverlappingPair(BroadphaseProxy proxy0, BroadphaseProxy proxy1);
Example #7
0
 public virtual bool NeedsCollision(BroadphaseProxy proxy0)
 {
     bool collides = (proxy0.m_collisionFilterGroup & m_collisionFilterMask) != 0;
     collides = collides && ((m_collisionFilterGroup & proxy0.m_collisionFilterMask) != 0);
     return collides;
 }
 public virtual void RemoveOverlappingPairsContainingProxy(BroadphaseProxy proxy0, IDispatcher dispatcher)
 {
     Debug.Assert(false);
     //need to keep track of all ghost objects and call them here
     //m_hashPairCache->removeOverlappingPairsContainingProxy(proxy0,dispatcher);
 }
 public override bool Process(BroadphaseProxy proxy)
 {
     HasHit = true;
     return(true);
 }
Example #10
0
 public override void RemoveOverlappingPairsContainingProxy(BroadphaseProxy proxy0, Dispatcher dispatcher)
 {
     throw new NotImplementedException();
 }
Example #11
0
 public override IntPtr RemoveOverlappingPair(BroadphaseProxy proxy0, BroadphaseProxy proxy1, Dispatcher dispatcher)
 {
     return(IntPtr.Zero);
 }
Example #12
0
 public override BroadphasePair AddOverlappingPair(BroadphaseProxy proxy0, BroadphaseProxy proxy1)
 {
     return(null);
 }
Example #13
0
 public CollisionPair(BroadphaseProxy proxyA, BroadphaseProxy proxyB) : this()
 {
     ProxyA = proxyA;
     ProxyB = proxyB;
 }
Example #14
0
 public override bool NeedsCollision(BroadphaseProxy proxy0)
 {
     return(base.NeedsCollision(proxy0));
 }
Example #15
0
 public abstract void removeOverlappingPairsContainingProxy(BroadphaseProxy proxy0);
        ///this method is mainly for expert/internal use only.
        public override void AddOverlappingObjectInternal(BroadphaseProxy otherProxy, BroadphaseProxy thisProxy)
        {
            BroadphaseProxy actualThisProxy = thisProxy != null ? thisProxy : GetBroadphaseHandle();
            Debug.Assert(actualThisProxy != null);

            CollisionObject otherObject = otherProxy.m_clientObject as CollisionObject;
            Debug.Assert(otherObject != null);
            if (!m_overlappingObjects.Contains(otherObject))
            {
                m_overlappingObjects.Add(otherObject);
                m_hashPairCache.AddOverlappingPair(actualThisProxy, otherProxy);
            }
        }
 public virtual BroadphasePair AddOverlappingPair(BroadphaseProxy proxy0, BroadphaseProxy proxy1)
 {
     CollisionObject colObj0 = proxy0.m_clientObject as CollisionObject;
     CollisionObject colObj1 = proxy1.m_clientObject as CollisionObject;
     GhostObject ghost0 = GhostObject.Upcast(colObj0);
     GhostObject ghost1 = GhostObject.Upcast(colObj1);
     if (ghost0 != null)
     {
         ghost0.AddOverlappingObjectInternal(proxy1, proxy0);
     }
     if (ghost1 != null)
     {
         ghost1.AddOverlappingObjectInternal(proxy0, proxy1);
     }
     return null;
 }
Example #18
0
 public abstract bool needBroadphaseCollision(BroadphaseProxy proxy0, BroadphaseProxy proxy1);
Example #19
0
        public override bool Process(BroadphaseProxy proxy)
        {
            ///terminate further ray tests, once the closestHitFraction reached zero
            if (MathUtil.FuzzyZero(m_resultCallback.m_closestHitFraction))
            {
                return false;
            }
            CollisionObject collisionObject = proxy.m_clientObject as CollisionObject;

            //only perform raycast if filterMask matches
            if (m_resultCallback.NeedsCollision(collisionObject.GetBroadphaseHandle()))
            {
                //RigidcollisionObject* collisionObject = ctrl.GetRigidcollisionObject();
                //IndexedVector3 collisionObjectAabbMin,collisionObjectAabbMax;
                //#if 0
                //#ifdef RECALCULATE_AABB
                //            IndexedVector3 collisionObjectAabbMin,collisionObjectAabbMax;
                //            collisionObject.getCollisionShape().getAabb(collisionObject.getWorldTransform(),collisionObjectAabbMin,collisionObjectAabbMax);
                //#else
                //getBroadphase().getAabb(collisionObject.getBroadphaseHandle(),collisionObjectAabbMin,collisionObjectAabbMax);
                IndexedVector3 collisionObjectAabbMin = collisionObject.GetBroadphaseHandle().m_aabbMin;
                IndexedVector3 collisionObjectAabbMax = collisionObject.GetBroadphaseHandle().m_aabbMax;
                //#endif
                //#endif
                //float hitLambda = m_resultCallback.m_closestHitFraction;
                //culling already done by broadphase
                //if (btRayAabb(m_rayFromWorld,m_rayToWorld,collisionObjectAabbMin,collisionObjectAabbMax,hitLambda,m_hitNormal))
                {
                    IndexedMatrix trans = collisionObject.GetWorldTransform();
                    CollisionWorld.RayTestSingle(ref m_rayFromTrans, ref m_rayToTrans,
                        collisionObject,
                            collisionObject.GetCollisionShape(),
                            ref trans,
                            m_resultCallback);
                }
            }
            return true;
        }
 public override bool NeedBroadphaseCollision(BroadphaseProxy proxy0, BroadphaseProxy proxy1)
 {
     throw new NotImplementedException();
 }
Example #21
0
        public virtual bool Process(BroadphaseProxy proxy)
        {
            if (proxy.m_clientObject == m_collisionObject)
            {
                return true;
            }
            CollisionObject collisionObject = proxy.m_clientObject as CollisionObject;

            //only perform raycast if filterMask matches
            if (m_resultCallback.NeedsCollision(collisionObject.GetBroadphaseHandle()))
            {
                CollisionAlgorithm algorithm = m_world.GetDispatcher().FindAlgorithm(m_collisionObject, collisionObject);
                if (algorithm != null)
                {
                    BridgedManifoldResult contactPointResult = new BridgedManifoldResult(m_collisionObject, collisionObject, m_resultCallback);
                    //discrete collision detection query
                    algorithm.ProcessCollision(m_collisionObject, collisionObject, m_world.GetDispatchInfo(), contactPointResult);

                    m_world.GetDispatcher().FreeCollisionAlgorithm(algorithm);
                }
            }
            return true;
        }
Example #22
0
 public void SetNewBroadphaseProxy(BroadphaseProxy broadphaseProxy)
 {
     m_broadphaseHandle = broadphaseProxy;
 }
Example #23
0
 public virtual BroadphasePair FindPair(BroadphaseProxy proxy0, BroadphaseProxy proxy1)
 {
     return null;
 }
        public virtual CollisionAlgorithmCreateFunc GetCollisionAlgorithmCreateFunc(BroadphaseNativeTypes proxyType0, BroadphaseNativeTypes proxyType1)
        {
            if ((proxyType0 == BroadphaseNativeTypes.SPHERE_SHAPE_PROXYTYPE) && (proxyType1 == BroadphaseNativeTypes.SPHERE_SHAPE_PROXYTYPE))
            {
                return(m_sphereSphereCF);
            }

            if ((proxyType0 == BroadphaseNativeTypes.SPHERE_SHAPE_PROXYTYPE) && (proxyType1 == BroadphaseNativeTypes.BOX_SHAPE_PROXYTYPE))
            {
                return(m_sphereBoxCF);
            }

            if ((proxyType0 == BroadphaseNativeTypes.BOX_SHAPE_PROXYTYPE) && (proxyType1 == BroadphaseNativeTypes.SPHERE_SHAPE_PROXYTYPE))
            {
                return(m_boxSphereCF);
            }

            if ((proxyType0 == BroadphaseNativeTypes.CONVEX_2D_SHAPE_PROXYTYPE) && (proxyType1 == BroadphaseNativeTypes.CONVEX_2D_SHAPE_PROXYTYPE))
            {
                return(m_convexAlgo2DCF);
            }

            if ((proxyType0 == BroadphaseNativeTypes.SPHERE_SHAPE_PROXYTYPE) && (proxyType1 == BroadphaseNativeTypes.TRIANGLE_SHAPE_PROXYTYPE))
            {
                return(m_sphereTriangleCF);
            }

            if ((proxyType0 == BroadphaseNativeTypes.TRIANGLE_SHAPE_PROXYTYPE) && (proxyType1 == BroadphaseNativeTypes.SPHERE_SHAPE_PROXYTYPE))
            {
                return(m_triangleSphereCF);
            }

            if ((proxyType0 == BroadphaseNativeTypes.BOX_SHAPE_PROXYTYPE) && (proxyType1 == BroadphaseNativeTypes.BOX_SHAPE_PROXYTYPE))
            {
                return(m_boxBoxCF);
            }

            if (BroadphaseProxy.IsConvex(proxyType0) && (proxyType1 == BroadphaseNativeTypes.STATIC_PLANE_PROXYTYPE))
            {
                return(m_convexPlaneCF);
            }

            if (BroadphaseProxy.IsConvex(proxyType1) && (proxyType0 == BroadphaseNativeTypes.STATIC_PLANE_PROXYTYPE))
            {
                return(m_planeConvexCF);
            }
            if (BroadphaseProxy.IsConvex(proxyType0) && BroadphaseProxy.IsConvex(proxyType1))
            {
                return(m_convexConvexCreateFunc);
            }

            if (BroadphaseProxy.IsConvex(proxyType0) && BroadphaseProxy.IsConcave(proxyType1))
            {
                return(m_convexConcaveCreateFunc);
            }

            if (BroadphaseProxy.IsConvex(proxyType1) && BroadphaseProxy.IsConcave(proxyType0))
            {
                return(m_swappedConvexConcaveCreateFunc);
            }

            if (BroadphaseProxy.IsCompound(proxyType0))
            {
                return(m_compoundCreateFunc);
            }
            else
            {
                if (BroadphaseProxy.IsCompound(proxyType1))
                {
                    return(m_swappedCompoundCreateFunc);
                }
            }

            //failed to find an algorithm
            return(m_emptyCreateFunc);
        }
Example #25
0
 public virtual Object RemoveOverlappingPair(BroadphaseProxy proxy0, BroadphaseProxy proxy1, IDispatcher dispatcher)
 {
     return null;
 }
Example #26
0
        public BroadphasePair FindPair(BroadphaseProxy proxy0, BroadphaseProxy proxy1)
        {
            OverlappingPairCacheGlobals.gFindPairs++;
            if (proxy0.m_uniqueId > proxy1.m_uniqueId)
            {
                BroadphaseProxy temp;
                temp = proxy0;
                proxy0 = proxy1;
                proxy1 = temp;
            }
            int proxyId1 = proxy0.GetUid();
            int proxyId2 = proxy1.GetUid();

            /*if (proxyId1 > proxyId2) 
                btSwap(proxyId1, proxyId2);*/

            int hash = (int)(GetHash((uint)(proxyId1), (uint)(proxyId2)) & (m_overlappingPairArray.Capacity - 1));

            if (hash >= m_hashTable.Count)
            {
                return null;
            }

            int index = m_hashTable[hash];
            while (index != BT_NULL_PAIR && EqualsPair(m_overlappingPairArray[index], proxyId1, proxyId2) == false)
            {
                index = m_next[index];
            }

            if (index == BT_NULL_PAIR)
            {
                return null;
            }

            Debug.Assert(index < m_overlappingPairArray.Count);

            return m_overlappingPairArray[index];
        }
Example #27
0
 public CleanPairCallback(BroadphaseProxy cleanProxy, IOverlappingPairCache pairCache, IDispatcher dispatcher)
 {
     m_cleanProxy = cleanProxy;
     m_pairCache = pairCache;
     m_dispatcher = dispatcher;
 }
Example #28
0
        private BroadphasePair InternalAddPair(BroadphaseProxy proxy0, BroadphaseProxy proxy1)
        {
            if (proxy0.m_uniqueId > proxy1.m_uniqueId)
            {
                BroadphaseProxy temp = proxy0;
                proxy0 = proxy1;
                proxy1 = temp;
            }

            int proxyId1 = proxy0.GetUid();
            int proxyId2 = proxy1.GetUid();


            int hash = (int)(GetHash((uint)proxyId1, (uint)proxyId2) & (m_overlappingPairArray.Capacity - 1));	// New hash value with new mask

            BroadphasePair pair = InternalFindPair(proxy0, proxy1, hash);
            if (pair != null)
            {
                return pair;
            }
            else
            {
                /*for(int i=0;i<m_overlappingPairArray.size();++i)
                    {
                    if(	(m_overlappingPairArray[i].m_pProxy0==proxy0)&&
                        (m_overlappingPairArray[i].m_pProxy1==proxy1))
                        {
                        printf("Adding duplicated %u<>%u\r\n",proxyId1,proxyId2);
                        internalFindPair(proxy0, proxy1, hash);
                        }
                    }*/
                int count = m_overlappingPairArray.Count;
                int oldCapacity = m_overlappingPairArray.Capacity;

                // MAN - 2.76 - uses expand noninitializing....??
                //void* mem = &m_overlappingPairArray.expand();

                //this is where we add an actual pair, so also call the 'ghost'
                if (m_ghostPairCallback != null)
                {
                    m_ghostPairCallback.AddOverlappingPair(proxy0, proxy1);
                }
                pair = new BroadphasePair(proxy0, proxy1);
                m_overlappingPairArray.Add(pair);

                int newCapacity = m_overlappingPairArray.Capacity;

                if (oldCapacity < newCapacity)
                {
                    GrowTables();
                    //hash with new capacity
                    hash = (int)(GetHash((uint)(proxyId1), (uint)(proxyId2)) & (m_overlappingPairArray.Capacity - 1));
                }


                m_next[count] = m_hashTable[hash];
                m_hashTable[hash] = count;

                return pair;
            }
        }
Example #29
0
 public virtual void RemoveOverlappingPairsContainingProxy(BroadphaseProxy proxy, IDispatcher dispatcher)
 {
     RemovePairCallback removeCallback = new RemovePairCallback(proxy);
     ProcessAllOverlappingPairs(removeCallback, dispatcher);
 }
Example #30
0
        public BroadphasePair InternalFindPair(BroadphaseProxy proxy0, BroadphaseProxy proxy1, int hash)
        {
            BroadphasePair[] rawPairArray = m_overlappingPairArray.GetRawArray();
            int proxyId1 = proxy0.GetUid();
            int proxyId2 = proxy1.GetUid();
            //#if 0 // wrong, 'equalsPair' use unsorted uids, copy-past devil striked again. Nat.
            //if (proxyId1 > proxyId2) 
            //    btSwap(proxyId1, proxyId2);
            //#endif

            int index = m_hashTable[hash];

            while (index != BT_NULL_PAIR && EqualsPair(rawPairArray[index], proxyId1, proxyId2) == false)
            {
                index = m_next[index];
            }

            if (index == BT_NULL_PAIR)
            {
                return null;
            }

            //btAssert(index < m_overlappingPairArray.size());
            // if we know this then don't we don't need to look it up again..
            rawPairArray[index].m_index = index;
            return rawPairArray[index];
        }
 ///this method is mainly for expert/internal use only.
 public virtual void RemoveOverlappingObjectInternal(BroadphaseProxy otherProxy, IDispatcher dispatcher, BroadphaseProxy thisProxy)
 {
     CollisionObject otherObject = otherProxy.m_clientObject as CollisionObject;
     Debug.Assert(otherObject != null);
     ///if this linearSearch becomes too slow (too many overlapping objects) we should add a more appropriate data structure
     {
         m_overlappingObjects.RemoveQuick(otherObject);
     }
 }
Example #32
0
        public Object RemoveOverlappingPair(BroadphaseProxy proxy0, BroadphaseProxy proxy1, IDispatcher dispatcher)
        {
            if (!HasDeferredRemoval())
            {
                BroadphasePair findPair = new BroadphasePair(proxy0, proxy1);

                int findIndex = m_overlappingPairArray.IndexOf(findPair);
                if (findIndex >= 0 && findIndex < m_overlappingPairArray.Count)
                {
                    OverlappingPairCacheGlobals.gOverlappingPairs--;
                    BroadphasePair pair = m_overlappingPairArray[findIndex];
                    Object userData = pair.m_internalInfo1;
                    CleanOverlappingPair(pair, dispatcher);
                    if (m_ghostPairCallback != null)
                    {
                        m_ghostPairCallback.RemoveOverlappingPair(proxy0, proxy1, dispatcher);
                    }
                    //BroadphasePair temp = m_overlappingPairArray[findIndex];
                    //m_overlappingPairArray[findIndex] = m_overlappingPairArray[m_overlappingPairArray.Count-1];
                    //m_overlappingPairArray[m_overlappingPairArray.Count-1] = temp;
                    m_overlappingPairArray.RemoveAtQuick(findIndex);
                    return userData;
                }
            }

            return null;
        }
        public override void RemoveOverlappingObjectInternal(BroadphaseProxy otherProxy, IDispatcher dispatcher, BroadphaseProxy thisProxy)
        {
            CollisionObject otherObject = otherProxy.m_clientObject as CollisionObject;
            BroadphaseProxy actualThisProxy = thisProxy != null ? thisProxy : GetBroadphaseHandle();
            Debug.Assert(actualThisProxy != null);

            Debug.Assert(otherObject != null);
            if (m_overlappingObjects.Remove(otherObject))
            {
                m_hashPairCache.RemoveOverlappingPair(actualThisProxy, otherProxy, dispatcher);
            }
        }
Example #34
0
        public BroadphasePair AddOverlappingPair(BroadphaseProxy proxy0, BroadphaseProxy proxy1)
        {
            //don't add overlap with own
            Debug.Assert(proxy0 != proxy1);

            if (!NeedsBroadphaseCollision(proxy0, proxy1))
            {
                return null;
            }
            
            BroadphasePair pair = new BroadphasePair(proxy0, proxy1);
            m_overlappingPairArray.Add(pair);

            OverlappingPairCacheGlobals.gOverlappingPairs++;
            OverlappingPairCacheGlobals.gAddedPairs++;

            if (m_ghostPairCallback != null)
            {
                m_ghostPairCallback.AddOverlappingPair(proxy0, proxy1);
            }
            return pair;
        }
 public virtual Object RemoveOverlappingPair(BroadphaseProxy proxy0, BroadphaseProxy proxy1, IDispatcher dispatcher)
 {
     CollisionObject colObj0 = proxy0.m_clientObject as CollisionObject;
     CollisionObject colObj1 = proxy1.m_clientObject as CollisionObject;
     GhostObject ghost0 = GhostObject.Upcast(colObj0);
     GhostObject ghost1 = GhostObject.Upcast(colObj1);
     if (ghost0 != null)
     {
         ghost0.RemoveOverlappingObjectInternal(proxy1, dispatcher, proxy0);
     }
     if (ghost1 != null)
     {
         ghost1.RemoveOverlappingObjectInternal(proxy0, dispatcher, proxy1);
     }
     return null;
 }
Example #36
0
        public BroadphasePair FindPair(BroadphaseProxy proxy0, BroadphaseProxy proxy1)
        {
            if (!NeedsBroadphaseCollision(proxy0, proxy1))
            {
                return null;
            }

            BroadphasePair tmpPair = new BroadphasePair(proxy0, proxy1);
            int index = m_overlappingPairArray.IndexOf(tmpPair);
            if (index != -1)
            {
                return m_overlappingPairArray[index];
            }
            return null;
        }
 ///this method is mainly for expert/internal use only.
 public virtual void AddOverlappingObjectInternal(BroadphaseProxy otherProxy, BroadphaseProxy thisProxy)
 {
     CollisionObject otherObject = otherProxy.m_clientObject as CollisionObject;
     Debug.Assert(otherObject != null);
     ///if this linearSearch becomes too slow (too many overlapping objects) we should add a more appropriate data structure
     if (!m_overlappingObjects.Contains(otherObject))
     {
         //not found
         m_overlappingObjects.Add(otherObject);
     }
 }
Example #38
0
 public void CleanProxyFromPairs(BroadphaseProxy proxy, IDispatcher dispatcher)
 {
     CleanPairCallback cleanPairs = new CleanPairCallback(proxy, this, dispatcher);
     ProcessAllOverlappingPairs(cleanPairs, dispatcher);
 }
Example #39
0
        public override bool Process(BroadphaseProxy proxy)
        {
            ///terminate further convex sweep tests, once the closestHitFraction reached zero
            if (MathUtil.FuzzyZero(m_resultCallback.m_closestHitFraction))
            {
                return false;
            }
            CollisionObject collisionObject = proxy.m_clientObject as CollisionObject;

            //only perform raycast if filterMask matches
            if (m_resultCallback.NeedsCollision(collisionObject.GetBroadphaseHandle()))
            {
                //RigidcollisionObject* collisionObject = ctrl.GetRigidcollisionObject();
                IndexedMatrix temp = collisionObject.GetWorldTransform();
                CollisionWorld.ObjectQuerySingle(m_castShape, ref m_convexFromTrans, ref m_convexToTrans,
                        collisionObject,
                            collisionObject.GetCollisionShape(),
                            ref temp,
                            m_resultCallback,
                            m_allowedCcdPenetration);
            }

            return true;
        }
Example #40
0
 public bool NeedsBroadphaseCollision(BroadphaseProxy proxy0, BroadphaseProxy proxy1)
 {
     if (m_overlapFilterCallback != null)
     {
         return m_overlapFilterCallback.NeedBroadphaseCollision(proxy0, proxy1);
     }
     bool collides = (proxy0.m_collisionFilterGroup & proxy1.m_collisionFilterMask) != 0;
     collides = collides && ((proxy1.m_collisionFilterGroup & proxy0.m_collisionFilterMask) != 0);
     return collides;
 }
Example #41
0
 public override bool NeedsCollision(BroadphaseProxy proxy0)
 {
     return m_userCallback.NeedsCollision(proxy0);
 }
Example #42
0
        public virtual void CleanProxyFromPairs(BroadphaseProxy proxy, IDispatcher dispatcher)
        {

        }
Example #43
0
 public void SetBroadphaseHandle(BroadphaseProxy handle)
 {
     m_broadphaseHandle = handle;
 }
Example #44
0
 public abstract BroadphasePair addOverlappingPair(BroadphaseProxy proxy0, BroadphaseProxy proxy1);