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
        protected virtual void SaveKinematicState(float timeStep)
        {
            ///would like to iterate over m_nonStaticRigidBodies, but unfortunately old API allows
            ///to switch status _after_ adding kinematic objects to the world
            ///fix it for Bullet 3.x release

            int length = m_collisionObjects.Count;

            for (int i = 0; i < length; ++i)
            {
                RigidBody body = RigidBody.Upcast(m_collisionObjects[i]);
                if (body != null && body.GetActivationState() != ActivationState.ISLAND_SLEEPING)
                {
                    if (body.IsKinematicObject())
                    {
                        //to calculate velocities next frame
                        body.SaveKinematicState(timeStep);
                    }
                }
            }
        }