Restore linear and angular velocities of 3d animation physical objects
This commit is contained in:
parent
c09585eaf7
commit
0b480e7a71
@ -360,10 +360,15 @@ void RewindManager::rewindTo(int rewind_ticks, int now_ticks,
|
||||
// Update check line, so the cannon animation can be replayed correctly
|
||||
CheckManager::get()->resetAfterRewind();
|
||||
|
||||
if (exact_rewind_ticks > 0)
|
||||
if (exact_rewind_ticks >= 2)
|
||||
{
|
||||
// Restore all physical objects moved by 3d animation, as it only
|
||||
// set the motion state of physical bodies, it has 1 frame delay
|
||||
// the resetAfterRewind will do the saveKinematicState which needs
|
||||
// the previous frame transforms to calculate current linear and
|
||||
// angular velocities
|
||||
world->setTicksForRewind(exact_rewind_ticks - 2);
|
||||
Track::getCurrentTrack()->getTrackObjectManager()->resetAfterRewind();
|
||||
world->setTicksForRewind(exact_rewind_ticks - 1);
|
||||
Track::getCurrentTrack()->getTrackObjectManager()->resetAfterRewind();
|
||||
world->setTicksForRewind(exact_rewind_ticks);
|
||||
|
@ -565,6 +565,7 @@ void TrackObject::resetAfterRewind()
|
||||
btTransform new_trans;
|
||||
m_physical_object->getMotionState()->getWorldTransform(new_trans);
|
||||
m_physical_object->getBody()->setCenterOfMassTransform(new_trans);
|
||||
m_physical_object->getBody()->saveKinematicState(stk_config->ticks2Time(1));
|
||||
} // resetAfterRewind
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
Loading…
Reference in New Issue
Block a user