Exemplo n.º 1
0
        protected void UpdateActivationState(float timeStep)
        {
            BulletGlobals.StartProfile("updateActivationState");

            int length = m_nonStaticRigidBodies.Count;

            for (int i = 0; i < length; ++i)
            {
                RigidBody body = m_nonStaticRigidBodies[i];
                if (body != null)
                {
                    body.UpdateDeactivation(timeStep);

                    if (body.WantsSleeping())
                    {
                        if (body.IsStaticOrKinematicObject())
                        {
                            body.SetActivationState(ActivationState.ISLAND_SLEEPING);
                        }
                        else
                        {
                            if (body.GetActivationState() == ActivationState.ACTIVE_TAG)
                            {
                                body.SetActivationState(ActivationState.WANTS_DEACTIVATION);
                            }

                            if (body.GetActivationState() == ActivationState.ISLAND_SLEEPING)
                            {
                                IndexedVector3 zero = IndexedVector3.Zero;
                                body.SetAngularVelocity(ref zero);
                                body.SetLinearVelocity(ref zero);
                                if (body.GetMotionState() != null)
                                {
                                    body.GetMotionState().SetWorldTransform(body.GetWorldTransform());
                                }
                            }
                        }
                    }
                    else
                    {
                        if (body.GetActivationState() != ActivationState.DISABLE_DEACTIVATION)
                        {
                            body.SetActivationState(ActivationState.ACTIVE_TAG);
                        }
                    }
                }
            }
            BulletGlobals.StopProfile();
        }
Exemplo n.º 2
0
 public override void SynchronizeMotionStates()
 {
     ///@todo: iterate over awake simulation islands!
     foreach (CollisionObject colObj in m_collisionObjects)
     {
         RigidBody body = RigidBody.Upcast(colObj);
         if (body != null && body.GetMotionState() != null)
         {
             if (body.GetActivationState() != ActivationState.ISLAND_SLEEPING)
             {
                 body.GetMotionState().SetWorldTransform(body.GetWorldTransform());
             }
         }
     }
 }
Exemplo n.º 3
0
 public override void SynchronizeMotionStates()
 {
     ///@todo: iterate over awake simulation islands!
     for (int i = 0; i < m_collisionObjects.Count; i++)
     {
         RigidBody body = RigidBody.Upcast(m_collisionObjects[i]);
         if (body != null && body.GetMotionState() != null)
         {
             if (body.GetActivationState() != ActivationState.ISLAND_SLEEPING)
             {
                 body.GetMotionState().SetWorldTransform(body.GetWorldTransform());
             }
         }
     }
 }
Exemplo n.º 4
0
        ///this can be useful to synchronize a single rigid body . graphics object
        public void SynchronizeSingleMotionState(RigidBody body)
        {
            Debug.Assert(body != null);

            if (body.GetMotionState() != null && !body.IsStaticOrKinematicObject())
            {
                //we need to call the update at least once, even for sleeping objects
                //otherwise the 'graphics' transform never updates properly
                ///@todo: add 'dirty' flag
                //if (body.getActivationState() != ISLAND_SLEEPING)
                {
                    IndexedMatrix interpolatedTransform;
                    TransformUtil.IntegrateTransform(body.GetInterpolationWorldTransform(),
                                                     body.SetInterpolationLinearVelocity(), body.GetInterpolationAngularVelocity(),
                                                     m_localTime * body.GetHitFraction(), out interpolatedTransform);
                    body.GetMotionState().SetWorldTransform(ref interpolatedTransform);
                }
            }
        }