From 28022cee396715bc4b474ed1571074dc721bbe13 Mon Sep 17 00:00:00 2001 From: Sarper Akdemir Date: Thu, 11 Jun 2020 19:29:38 +0300 Subject: make physics based animation effects part of the animation engine Wiring up and creating required classes for physics based animation effects to be part of the animation engine. Creating a new animation node AnimationPhysicsNode for physics based animation effects and PhysicsAnimation class that inherits the NumberAnimation in the animation factory. Change-Id: I1f125df5324673e9937b8164c0fc267c9683afa0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/100151 Tested-by: Jenkins Reviewed-by: Thorsten Behrens --- slideshow/source/inc/animationfactory.hxx | 16 ++++++++++- slideshow/source/inc/box2dtools.hxx | 48 +++++++++++++++++++------------ slideshow/source/inc/slideshowcontext.hxx | 7 ++++- 3 files changed, 50 insertions(+), 21 deletions(-) (limited to 'slideshow/source/inc') diff --git a/slideshow/source/inc/animationfactory.hxx b/slideshow/source/inc/animationfactory.hxx index db24dbb55094..af3b9b9a4e49 100644 --- a/slideshow/source/inc/animationfactory.hxx +++ b/slideshow/source/inc/animationfactory.hxx @@ -30,6 +30,8 @@ #include "shapemanager.hxx" +namespace box2d::utils { typedef ::std::shared_ptr< class box2DWorld > Box2DWorldSharedPtr; } + /* Definition of AnimationFactory class */ namespace slideshow::internal @@ -79,18 +81,21 @@ namespace slideshow::internal const AnimatableShapeSharedPtr& rShape, const ShapeManagerSharedPtr& rShapeManager, const ::basegfx::B2DVector& rSlideSize, + const box2d::utils::Box2DWorldSharedPtr& pBox2DWorld, int nFlags=0 ); EnumAnimationSharedPtr createEnumPropertyAnimation( const OUString& rAttrName, const AnimatableShapeSharedPtr& rShape, const ShapeManagerSharedPtr& rShapeManager, const ::basegfx::B2DVector& rSlideSize, + const box2d::utils::Box2DWorldSharedPtr& pBox2DWorld, int nFlags ); ColorAnimationSharedPtr createColorPropertyAnimation( const OUString& rAttrName, const AnimatableShapeSharedPtr& rShape, const ShapeManagerSharedPtr& rShapeManager, const ::basegfx::B2DVector& rSlideSize, + const box2d::utils::Box2DWorldSharedPtr& pBox2DWorld, int nFlags=0 ); /** Create scale or move animation @@ -110,12 +115,14 @@ namespace slideshow::internal const AnimatableShapeSharedPtr& rShape, const ShapeManagerSharedPtr& rShapeManager, const ::basegfx::B2DVector& rSlideSize, + const box2d::utils::Box2DWorldSharedPtr& pBox2DWorld, int nFlags ); BoolAnimationSharedPtr createBoolPropertyAnimation( const OUString& rAttrName, const AnimatableShapeSharedPtr& rShape, const ShapeManagerSharedPtr& rShapeManager, const ::basegfx::B2DVector& rSlideSize, + const box2d::utils::Box2DWorldSharedPtr& pBox2DWorld, int nFlags ); NumberAnimationSharedPtr createPathMotionAnimation( const OUString& rSVGDPath, @@ -123,7 +130,14 @@ namespace slideshow::internal const AnimatableShapeSharedPtr& rShape, const ShapeManagerSharedPtr& rShapeManager, const ::basegfx::B2DVector& rSlideSize, - int nFlags); + const box2d::utils::Box2DWorldSharedPtr& pBox2DWorld, + int nFlags ); + + NumberAnimationSharedPtr createPhysicsAnimation( const box2d::utils::Box2DWorldSharedPtr& pBox2DWorld, + const double fDuration, + const ShapeManagerSharedPtr& rShapeManager, + const ::basegfx::B2DVector& rSlideSize, + int nFlags ); } } diff --git a/slideshow/source/inc/box2dtools.hxx b/slideshow/source/inc/box2dtools.hxx index 0824a3c260c5..dacf24845b45 100644 --- a/slideshow/source/inc/box2dtools.hxx +++ b/slideshow/source/inc/box2dtools.hxx @@ -11,6 +11,7 @@ #include "shape.hxx" #include "shapeattributelayer.hxx" +#include "attributemap.hxx" #include #include @@ -155,6 +156,21 @@ private: void step(const float fTimeStep = 1.0f / 100.0f, const int nVelocityIterations = 6, const int nPositionIterations = 2); + /// Queue a rotation update on the next step of the box2DWorld for the corresponding body + void queueRotationUpdate(const css::uno::Reference& xShape, + const double fAngle); + + /// Queue an angular velocity update for the corresponding body + /// to take place after the next step of the box2DWorld + void + queueAngularVelocityUpdate(const css::uno::Reference& xShape, + const double fAngularVelocity); + + /// Queue an update that changes collision of the corresponding body + /// on the next step of the box2DWorld, used for animations that change visibility + void queueShapeVisibilityUpdate(const css::uno::Reference& xShape, + const bool bVisibility); + public: box2DWorld(const ::basegfx::B2DVector& rSlideSize); ~box2DWorld(); @@ -184,7 +200,7 @@ public: @param pShape Pointer to the shape to alter the corresponding Box2D body of */ - Box2DBodySharedPtr makeShapeDynamic(const slideshow::internal::ShapeSharedPtr pShape); + Box2DBodySharedPtr makeShapeDynamic(const slideshow::internal::ShapeSharedPtr& pShape); /** Make the Box2D body a dynamic one @@ -193,7 +209,7 @@ public: @param pBox2DBody Pointer to the Box2D body */ - Box2DBodySharedPtr makeBodyDynamic(const Box2DBodySharedPtr pBox2DBody); + Box2DBodySharedPtr makeBodyDynamic(const Box2DBodySharedPtr& pBox2DBody); /** Make the Box2D body corresponding to the given shape a static one @@ -202,7 +218,7 @@ public: @param pShape Pointer to the shape to alter the corresponding Box2D body of */ - Box2DBodySharedPtr makeShapeStatic(const slideshow::internal::ShapeSharedPtr pShape); + Box2DBodySharedPtr makeShapeStatic(const slideshow::internal::ShapeSharedPtr& pShape); /** Make the Box2D body a dynamic one @@ -211,7 +227,7 @@ public: @param pBox2DBody Pointer to the Box2D body */ - Box2DBodySharedPtr makeBodyStatic(const Box2DBodySharedPtr pBox2DBody); + Box2DBodySharedPtr makeBodyStatic(const Box2DBodySharedPtr& pBox2DBody); /// Create a static body from the given shape's bounding box Box2DBodySharedPtr @@ -220,7 +236,7 @@ public: /// Initiate all the shapes in the current slide in the box2DWorld as static ones void - initateAllShapesAsStaticBodies(const slideshow::internal::ShapeManagerSharedPtr pShapeManager); + initateAllShapesAsStaticBodies(const slideshow::internal::ShapeManagerSharedPtr& pShapeManager); /// @return whether the box2DWorld has a stepper or not bool hasWorldStepper(); @@ -229,27 +245,21 @@ public: void setHasWorldStepper(const bool bHasWorldStepper); /// Queue a position update the next step of the box2DWorld for the corresponding body - void queuePositionUpdate(css::uno::Reference xShape, + void queuePositionUpdate(const css::uno::Reference& xShape, const ::basegfx::B2DPoint& rOutPos); /// Queue a linear velocity update for the corresponding body /// to take place after the next step of the box2DWorld - void queueLinearVelocityUpdate(css::uno::Reference xShape, + void queueLinearVelocityUpdate(const css::uno::Reference& xShape, const ::basegfx::B2DVector& rVelocity); - /// Queue a rotation update on the next step of the box2DWorld for the corresponding body - void queueRotationUpdate(css::uno::Reference xShape, - const double fAngle); - - /// Queue an angular velocity update for the corresponding body - /// to take place after the next step of the box2DWorld - void queueAngularVelocityUpdate(css::uno::Reference xShape, - const double fAngularVelocity); + void + queueShapeAnimationUpdate(const css::uno::Reference& xShape, + const slideshow::internal::ShapeAttributeLayerSharedPtr& pAttrLayer, + const slideshow::internal::AttributeType eAttrType); - /// Queue an update that changes collision of the corresponding body - /// on the next step of the box2DWorld, used for animations that change visibility - void queueShapeVisibilityUpdate(css::uno::Reference xShape, - const bool bVisibility); + void queueShapeAnimationEndUpdate(const css::uno::Reference& xShape, + const slideshow::internal::AttributeType eAttrType); }; /// Class that manages a single box2D Body diff --git a/slideshow/source/inc/slideshowcontext.hxx b/slideshow/source/inc/slideshowcontext.hxx index 558ee6f037c0..565f0ff411aa 100644 --- a/slideshow/source/inc/slideshowcontext.hxx +++ b/slideshow/source/inc/slideshowcontext.hxx @@ -24,6 +24,9 @@ #include namespace com::sun::star::uno { class XComponentContext; } +namespace box2d::utils { class box2DWorld; + typedef ::std::shared_ptr< box2DWorld > Box2DWorldSharedPtr; } + namespace slideshow::internal @@ -90,7 +93,8 @@ namespace slideshow::internal CursorManager& rCursorManager, MediaFileManager& rMediaFileManager, const UnoViewContainer& rViewContainer, - const css::uno::Reference< css::uno::XComponentContext>& rComponentContext ); + const css::uno::Reference< css::uno::XComponentContext>& rComponentContext, + box2d::utils::Box2DWorldSharedPtr& rBox2DWorldPtr ); void dispose(); std::shared_ptr& mpSubsettableShapeManager; @@ -103,6 +107,7 @@ namespace slideshow::internal MediaFileManager& mrMediaFileManager; const UnoViewContainer& mrViewContainer; css::uno::Reference< css::uno::XComponentContext> mxComponentContext; + box2d::utils::Box2DWorldSharedPtr& mpBox2DWorld; }; } -- cgit