Пример #1
0
 public override void DumpDebugInfo(StringBuilder stringBuilder)
 {
     base.DumpDebugInfo(stringBuilder);
     stringBuilder.AppendFormat("BulletXNAObject type[{0}] actiState[{1}] mask[{2}] flags[{3}]", RigidBody != null?"RB":"G", CollisionObject.GetActivationState(), CollisionMask, CollisionGroups);
     GameComponentHelper.PrintVector3(stringBuilder, "LinVel", LinearVelocity);
     if (CollisionObject.GetBroadphaseHandle() != null)
     {
         GameComponentHelper.PrintVector3(stringBuilder, "aaBMin", CollisionObject.GetBroadphaseHandle().m_aabbMin);
         GameComponentHelper.PrintVector3(stringBuilder, "aaBMax", CollisionObject.GetBroadphaseHandle().m_aabbMax);
     }
 }
Пример #2
0
        public override bool NeedsCollision(BroadphaseProxy proxy0)
        {
            //don't collide with itself
            if (proxy0.m_clientObject == m_me)
            {
                return(false);
            }

            ///don't do CCD when the collision filters are not matching
            if (!base.NeedsCollision(proxy0))
            {
                return(false);
            }

            CollisionObject otherObj = proxy0.m_clientObject as CollisionObject;

            //call needsResponse, see http://code.google.com/p/bullet/issues/detail?id=179
            if (m_dispatcher.NeedsResponse(m_me, otherObj))
            {
#if false
                ///don't do CCD when there are already contact points (touching contact/penetration)
                PersistentManifoldArray manifoldArray = new PersistentManifoldArray();
                BroadphasePair          collisionPair = m_pairCache.FindPair(m_me.GetBroadphaseHandle(), proxy0);
                if (collisionPair != null)
                {
                    if (collisionPair.m_algorithm != null)
                    {
                        collisionPair.m_algorithm.GetAllContactManifolds(manifoldArray);
                        int length = manifoldArray.Count;
                        for (int i = 0; i < length; ++i)
                        {
                            if (manifoldArray[i].GetNumContacts() > 0)
                            {
                                return(false);
                            }
                        }
                    }
                }
#endif
                return(true);
            }
            return(false);
        }
Пример #3
0
        //----------------------------------------------------------------------------------------------

        public override void ClientResetScene()
        {
            //#ifdef SHOW_NUM_DEEP_PENETRATIONS
            gNumDeepPenetrationChecks = 0;
            gNumGjkChecks             = 0;
            //#endif //SHOW_NUM_DEEP_PENETRATIONS

            gNumClampedCcdMotions = 0;
            int numObjects = 0;

            foreach (DiscreteDynamicsWorld world in m_worlds)
            {
                // Prefer a better place for this...
                world.SetDebugDrawer(m_debugDraw);
                numObjects = world.GetNumCollisionObjects();

                IList <CollisionObject> copyArray = world.GetCollisionObjectArray();

                for (int i = 0; i < numObjects; i++)
                {
                    CollisionObject colObj = copyArray[i];
                    RigidBody       body   = RigidBody.Upcast(colObj);
                    if (body != null)
                    {
                        if (body.GetMotionState() != null)
                        {
                            DefaultMotionState myMotionState = (DefaultMotionState)body.GetMotionState();
                            myMotionState.m_graphicsWorldTrans = myMotionState.m_startWorldTrans;
                            body.SetCenterOfMassTransform(ref myMotionState.m_graphicsWorldTrans);
                            colObj.SetInterpolationWorldTransform(ref myMotionState.m_startWorldTrans);
                            if (colObj.GetActivationState() != ActivationState.DISABLE_DEACTIVATION)
                            {
                                colObj.ForceActivationState(ActivationState.ACTIVE_TAG);
                                colObj.Activate();
                                colObj.SetDeactivationTime(0);
                            }
                            //colObj.setActivationState(WANTS_DEACTIVATION);
                        }
                        //removed cached contact points (this is not necessary if all objects have been removed from the dynamics world)
                        world.GetBroadphase().GetOverlappingPairCache().CleanProxyFromPairs(colObj.GetBroadphaseHandle(), world.GetDispatcher());

                        if (!body.IsStaticObject())
                        {
                            IndexedVector3 zero = IndexedVector3.Zero;
                            body.SetLinearVelocity(ref zero);
                            body.SetAngularVelocity(ref zero);
                        }
                    }
                }
                ///reset some internal cached data in the broadphase
                world.GetBroadphase().ResetPool(world.GetDispatcher());
                world.GetConstraintSolver().Reset();
            }
        }