diff options
Diffstat (limited to 'slideshow/source')
-rw-r--r-- | slideshow/source/engine/box2dtools.cxx | 21 | ||||
-rw-r--r-- | slideshow/source/inc/box2dtools.hxx | 3 |
2 files changed, 22 insertions, 2 deletions
diff --git a/slideshow/source/engine/box2dtools.cxx b/slideshow/source/engine/box2dtools.cxx index 3c7c3deb657c..1cc69b53632a 100644 --- a/slideshow/source/engine/box2dtools.cxx +++ b/slideshow/source/engine/box2dtools.cxx @@ -225,6 +225,7 @@ box2DWorld::box2DWorld(const ::basegfx::B2DVector& rSlideSize) , mfScaleFactor(calculateScaleFactor(rSlideSize)) , mbShapesInitialized(false) , mbHasWorldStepper(false) + , mbAlreadyStepped(false) , mnPhysicsAnimationCounter(0) , mpXShapeToBodyMap() , maShapeParallelUpdateQueue() @@ -574,6 +575,13 @@ void box2DWorld::alertPhysicsAnimationEnd(const slideshow::internal::ShapeShared // destroyed if there's nothing else that owns them mpXShapeToBodyMap.clear(); } + else + { + // the physics animation that will take over the lock after this one + // shouldn't step the world for an update cycle - since it was already + // stepped. + mbAlreadyStepped = true; + } } void box2DWorld::alertPhysicsAnimationStart( @@ -609,9 +617,18 @@ double box2DWorld::stepAmount(const double fPassedTime, const float fTimeStep, // do the updates required to simulate other animaton effects going in parallel processUpdateQueue(fTimeSteppedThrough); - for (unsigned int nStepCounter = 0; nStepCounter < nStepAmount; nStepCounter++) + if (!mbAlreadyStepped) + { + for (unsigned int nStepCounter = 0; nStepCounter < nStepAmount; nStepCounter++) + { + step(fTimeStep, nVelocityIterations, nPositionIterations); + } + } + else { - step(fTimeStep, nVelocityIterations, nPositionIterations); + // just got the step lock from another physics animation + // so skipping stepping the world for an update cycle + mbAlreadyStepped = false; } return fTimeSteppedThrough; diff --git a/slideshow/source/inc/box2dtools.hxx b/slideshow/source/inc/box2dtools.hxx index a71af1d34bef..0f6707fbd7c6 100644 --- a/slideshow/source/inc/box2dtools.hxx +++ b/slideshow/source/inc/box2dtools.hxx @@ -85,6 +85,9 @@ private: /// Holds whether or not there is a PhysicsAnimation that /// is stepping the Box2D World. Used to create a lock mechanism bool mbHasWorldStepper; + /// Flag used to stop overstepping that occurs when a physics + /// animation effect transfers step-lock to another one. + bool mbAlreadyStepped; /// Number of Physics Animations going on int mnPhysicsAnimationCounter; std::unordered_map<css::uno::Reference<css::drawing::XShape>, Box2DBodySharedPtr> |