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.sarperakde...@gmail.com>
AuthorDate: Sun Aug 30 20:44:02 2020 +0300
Commit:     Thorsten Behrens <thorsten.behr...@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.behr...@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>
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to