Exemple #1
0
        public void NearCallback(BroadphasePair collisionPair, CollisionDispatcher dispatcher, DispatcherInfo dispatchInfo)
        {
            CollisionObject colObj0 = collisionPair.m_pProxy0.GetClientObject() as CollisionObject;
            CollisionObject colObj1 = collisionPair.m_pProxy1.GetClientObject() as CollisionObject;

            if (dispatcher.NeedsCollision(colObj0, colObj1))
            {
                //dispatcher will keep algorithms persistent in the collision pair
                if (collisionPair.m_algorithm == null)
                {
                    collisionPair.m_algorithm = dispatcher.FindAlgorithm(colObj0, colObj1, null);
                }

                if (collisionPair.m_algorithm != null)
                {
                    ManifoldResult contactPointResult = dispatcher.GetNewManifoldResult(colObj0, colObj1);

                    if (dispatchInfo.GetDispatchFunc() == DispatchFunc.DISPATCH_DISCRETE)
                    {
                        //discrete collision detection query
                        collisionPair.m_algorithm.ProcessCollision(colObj0, colObj1, dispatchInfo, contactPointResult);
                    }
                    else
                    {
                        //continuous collision detection query, time of impact (toi)
                        float toi = collisionPair.m_algorithm.CalculateTimeOfImpact(colObj0, colObj1, dispatchInfo, contactPointResult);
                        if (dispatchInfo.GetTimeOfImpact() > toi)
                        {
                            dispatchInfo.SetTimeOfImpact(toi);
                        }
                    }
#if DEBUG
                    if (BulletGlobals.g_streamWriter != null && BulletGlobals.debugDispatcher)
                    {
                        BulletGlobals.g_streamWriter.WriteLine("NearCallback[{0}][{1}][{2}]", contactPointResult.GetBody0Internal().GetUserPointer(), contactPointResult.GetBody1Internal().GetUserPointer(), contactPointResult.GetPersistentManifold().GetNumContacts());
                    }
#endif
                    dispatcher.FreeManifoldResult(contactPointResult);
                }
            }
        }
        public void NearCallback(BroadphasePair collisionPair, CollisionDispatcher dispatcher, DispatcherInfo dispatchInfo)
        {
            CollisionObject colObj0 = collisionPair.m_pProxy0.GetClientObject() as CollisionObject;
            CollisionObject colObj1 = collisionPair.m_pProxy1.GetClientObject() as CollisionObject;

            if (dispatcher.NeedsCollision(colObj0, colObj1))
            {
                //dispatcher will keep algorithms persistent in the collision pair
                if (collisionPair.m_algorithm == null)
                {
                    collisionPair.m_algorithm = dispatcher.FindAlgorithm(colObj0, colObj1, null);
                }

                if (collisionPair.m_algorithm != null)
                {
                    ManifoldResult contactPointResult = dispatcher.GetNewManifoldResult(colObj0, colObj1);

                    if (dispatchInfo.GetDispatchFunc() == DispatchFunc.DISPATCH_DISCRETE)
                    {
                        //discrete collision detection query
                        collisionPair.m_algorithm.ProcessCollision(colObj0, colObj1, dispatchInfo, contactPointResult);
                    }
                    else
                    {
                        //continuous collision detection query, time of impact (toi)
                        float toi = collisionPair.m_algorithm.CalculateTimeOfImpact(colObj0, colObj1, dispatchInfo, contactPointResult);
                        if (dispatchInfo.GetTimeOfImpact() > toi)
                        {
                            dispatchInfo.SetTimeOfImpact(toi);
                        }
                    }
#if DEBUG
                    if (BulletGlobals.g_streamWriter != null && BulletGlobals.debugDispatcher)
                    {
                        BulletGlobals.g_streamWriter.WriteLine("NearCallback[{0}][{1}][{2}]", contactPointResult.GetBody0Internal().GetUserPointer(), contactPointResult.GetBody1Internal().GetUserPointer(),contactPointResult.GetPersistentManifold().GetNumContacts());
                    }
#endif
                    dispatcher.FreeManifoldResult(contactPointResult);
                }
            }
        }