コード例 #1
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());
             }
         }
     }
 }
コード例 #2
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);
                }
            }
        }