[Libreoffice-commits] core.git: slideshow/source
Sarper Akdemir (via logerrit)
logerrit at kemper.freedesktop.org
Mon Aug 31 10:31:42 UTC 2020
slideshow/source/engine/box2dtools.cxx | 21 +++++++++++++++++++--
slideshow/source/inc/box2dtools.hxx | 3 +++
2 files changed, 22 insertions(+), 2 deletions(-)
New commits:
commit 943aaf6c61d9594ec229984b5d5801afe5d89024
Author: Sarper Akdemir <q.sarperakdemir at gmail.com>
AuthorDate: Sun Aug 30 20:44:02 2020 +0300
Commit: Thorsten Behrens <Thorsten.Behrens at CIB.de>
CommitDate: Mon Aug 31 12:31:05 2020 +0200
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 at CIB.de>
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>
More information about the Libreoffice-commits
mailing list