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(); }