///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); } } }
protected void PredictUnconstraintMotion(float timeStep) { foreach (CollisionObject colObj in m_collisionObjects) { RigidBody body = RigidBody.Upcast(colObj); if (body != null) { if (!body.IsStaticObject()) { if (body.IsActive()) { body.ApplyGravity(); body.IntegrateVelocities(timeStep); body.ApplyDamping(timeStep); IndexedMatrix temp = body.GetInterpolationWorldTransform(); body.PredictIntegratedTransform(timeStep, out temp); body.SetInterpolationWorldTransform(ref temp); } } } } }