summaryrefslogtreecommitdiff
path: root/slideshow
diff options
context:
space:
mode:
authorSarper Akdemir <q.sarperakdemir@gmail.com>2020-08-30 20:44:02 +0300
committerThorsten Behrens <Thorsten.Behrens@CIB.de>2020-08-31 12:31:05 +0200
commit943aaf6c61d9594ec229984b5d5801afe5d89024 (patch)
treee09649a2717826fd98d4ffd882612058b8029078 /slideshow
parent6915d69a125417a62e4b795c7c97faac6088f94e (diff)
tdf#136301: fix parallel physics animations over-stepping during lock transfer
introducing mbAlreadyStepped flag to make physics animation effects aware that the lock was just obtained from another physics animation which already stepped the time interval meant to be stepped through. Change-Id: Id7c01c96e302d7da7aae785f56c09a9ddfe4bdf1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/101665 Tested-by: Jenkins Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
Diffstat (limited to 'slideshow')
-rw-r--r--slideshow/source/engine/box2dtools.cxx21
-rw-r--r--slideshow/source/inc/box2dtools.hxx3
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>