diff --git a/src/SceneGraph/Animable.cpp b/src/SceneGraph/Animable.cpp index 1087f8371..ad53b31fe 100644 --- a/src/SceneGraph/Animable.cpp +++ b/src/SceneGraph/Animable.cpp @@ -27,10 +27,10 @@ namespace Magnum { namespace SceneGraph { #ifndef DOXYGEN_GENERATING_OUTPUT -template class MAGNUM_SCENEGRAPH_EXPORT Animable<2, Float>; -template class MAGNUM_SCENEGRAPH_EXPORT Animable<3, Float>; -template class MAGNUM_SCENEGRAPH_EXPORT AnimableGroup<2, Float>; -template class MAGNUM_SCENEGRAPH_EXPORT AnimableGroup<3, Float>; +template class MAGNUM_SCENEGRAPH_EXPORT BasicAnimable<2, Float>; +template class MAGNUM_SCENEGRAPH_EXPORT BasicAnimable<3, Float>; +template class MAGNUM_SCENEGRAPH_EXPORT BasicAnimableGroup<2, Float>; +template class MAGNUM_SCENEGRAPH_EXPORT BasicAnimableGroup<3, Float>; #endif Debug operator<<(Debug debug, AnimationState value) { diff --git a/src/SceneGraph/Animable.h b/src/SceneGraph/Animable.h index 163e3321f..206b622c9 100644 --- a/src/SceneGraph/Animable.h +++ b/src/SceneGraph/Animable.h @@ -25,7 +25,7 @@ */ /** @file - * @brief Class Magnum::SceneGraph::Animable, enum Magnum::SceneGraph::AnimationState + * @brief Class Magnum::SceneGraph::BasicAnimable, typedef Magnum::SceneGraph::Animable2D, Magnum::SceneGraph::Animable3D, enum Magnum::SceneGraph::AnimationState */ #include "AbstractGroupedFeature.h" @@ -37,7 +37,7 @@ namespace Magnum { namespace SceneGraph { /** @brief Animation state -@see Animable::setState() +@see BasicAnimable::setState() */ enum class AnimationState: UnsignedByte { /** @@ -56,7 +56,7 @@ enum class AnimationState: UnsignedByte { Running }; -/** @debugoperator{Magnum::SceneGraph::Animable} */ +/** @debugoperator{Magnum::SceneGraph::BasicAnimable} */ Debug MAGNUM_SCENEGRAPH_EXPORT operator<<(Debug debug, AnimationState value); /** @@ -76,9 +76,9 @@ time and time delta. Example: typedef SceneGraph::Object> Object3D; typedef SceneGraph::Scene> Scene3D; -class AnimableObject: public Object3D, SceneGraph::Animable3D<> { +class AnimableObject: public Object3D, SceneGraph::Animable3D { public: - AnimableObject(Object* parent = nullptr, SceneGraph::DrawableGroup3D<>* group = nullptr): Object3D(parent), SceneGraph::Animable3D<>(this, group) { + AnimableObject(Object* parent = nullptr, SceneGraph::DrawableGroup3D<>* group = nullptr): Object3D(parent), SceneGraph::Animable3D(this, group) { setDuration(10.0f); // ... } @@ -90,22 +90,23 @@ class AnimableObject: public Object3D, SceneGraph::Animable3D<> { @endcode Then add the object to your scene and some animation group. You can also use -AnimableGroup::add() and AnimableGroup::remove() instead of passing the group -in the constructor. The animation is initially in stopped state and without -repeat, see setState(), setRepeated() and setRepeatCount() for more information. +BasicAnimableGroup::add() and BasicAnimableGroup::remove() instead of passing +the group in the constructor. The animation is initially in stopped state and +without repeat, see setState(), setRepeated() and setRepeatCount() for more +information. @code Scene3D scene; -SceneGraph::AnimableGroup3D<> animables; +SceneGraph::AnimableGroup3D animables; (new AnimableObject(&scene, &animables)) ->setState(SceneGraph::AnimationState::Running); // ... @endcode -Animation step is performed by calling AnimableGroup::step() in your draw event -implementation. The function expects absolute time from relative to some fixed -point in the past and time delta (i.e. duration of the frame). You can use -Timeline for that, see its documentation for more information. +Animation step is performed by calling BasicAnimableGroup::step() in your draw +event implementation. The function expects absolute time from relative to some +fixed point in the past and time delta (i.e. duration of the frame). You can +use Timeline for that, see its documentation for more information. @code Timeline timeline; timeline.start(); @@ -121,11 +122,11 @@ void MyApplication::drawEvent() { @section Animable-performance Using animable groups to improve performance -AnimableGroup is optimized for case when no animation is running - it just +Animable group is optimized for case when no animation is running - it just puts itself to rest and waits until some animation changes its state to @ref AnimationState "AnimationState::Running" again. If you put animations which are not pernamently running to separate group, they will not be always -traversed when calling AnimableGroup::step(), saving precious frame time. +traversed when calling BasicAnimableGroup::step(), saving precious frame time. @section Animable-explicit-specializations Explicit template specializations @@ -134,18 +135,14 @@ For other specializations (e.g. using Double type) you have to use Animable.hpp implementation file to avoid linker errors. See also @ref compilation-speedup-hpp for more information. - - @ref Animable "Animable<2, Float>", @ref AnimableGroup "AnimableGroup<2, Float>" - - @ref Animable "Animable<3, Float>", @ref AnimableGroup "AnimableGroup<3, Float>" + - @ref BasicAnimable "BasicAnimable<2, Float>", @ref BasicAnimableGroup "BasicAnimableGroup<2, Float>" + - @ref BasicAnimable "BasicAnimable<3, Float>", @ref BasicAnimableGroup "BasicAnimableGroup<3, Float>" -@see @ref scenegraph, Animable2D, Animable3D, AnimableGroup2D, AnimableGroup3D +@see @ref Animable2D, @ref Animable3D, @ref scenegraph, @ref AnimableGroup2D, + @ref AnimableGroup3D */ -#ifndef DOXYGEN_GENERATING_OUTPUT -template -#else -template -#endif -class MAGNUM_SCENEGRAPH_EXPORT Animable: public AbstractBasicGroupedFeature, T> { - friend class AnimableGroup; +template class MAGNUM_SCENEGRAPH_EXPORT BasicAnimable: public AbstractBasicGroupedFeature, T> { + friend class BasicAnimableGroup; public: /** @@ -155,11 +152,11 @@ class MAGNUM_SCENEGRAPH_EXPORT Animable: public AbstractBasicGroupedFeature* object, AnimableGroup* group = nullptr); + explicit BasicAnimable(AbstractObject* object, BasicAnimableGroup* group = nullptr); - ~Animable(); + ~BasicAnimable(); /** @brief Animation duration */ Float duration() const { return _duration; } @@ -178,7 +175,7 @@ class MAGNUM_SCENEGRAPH_EXPORT Animable: public AbstractBasicGroupedFeature* setState(AnimationState state); + BasicAnimable* setState(AnimationState state); /** * @brief Whether the animation is repeated @@ -194,7 +191,7 @@ class MAGNUM_SCENEGRAPH_EXPORT Animable: public AbstractBasicGroupedFeature* setRepeated(bool repeated) { + BasicAnimable* setRepeated(bool repeated) { _repeated = repeated; return this; } @@ -214,7 +211,7 @@ class MAGNUM_SCENEGRAPH_EXPORT Animable: public AbstractBasicGroupedFeature* setRepeatCount(UnsignedShort count) { + BasicAnimable* setRepeatCount(UnsignedShort count) { _repeatCount = count; return this; } @@ -224,8 +221,8 @@ class MAGNUM_SCENEGRAPH_EXPORT Animable: public AbstractBasicGroupedFeature* group(); - const AnimableGroup* group() const; /**< @overload */ + BasicAnimableGroup* group(); + const BasicAnimableGroup* group() const; /**< @overload */ protected: /** @@ -236,7 +233,7 @@ class MAGNUM_SCENEGRAPH_EXPORT Animable: public AbstractBasicGroupedFeature* setDuration(Float duration) { + BasicAnimable* setDuration(Float duration) { _duration = duration; return this; } @@ -246,8 +243,8 @@ class MAGNUM_SCENEGRAPH_EXPORT Animable: public AbstractBasicGroupedFeature%Animable<2, T>. See Animable for more -information. -@note Not available on GCC < 4.7. Use %Animable<2, T> instead. -@see Animable3D +@see @ref Animable3D */ -#ifdef DOXYGEN_GENERATING_OUTPUT -template -#else -template -#endif -using Animable2D = Animable<2, T>; +typedef BasicAnimable<2, Float> Animable2D; /** -@brief Three-dimensional animable +@brief Animable for three-dimensional float scenes -Convenience alternative to %Animable<3, T>. See Animable for more -information. -@note Not available on GCC < 4.7. Use %Animable<3, T> instead. -@see Animable2D +@see @ref Animable2D */ -#ifdef DOXYGEN_GENERATING_OUTPUT -template -#else -template -#endif -using Animable3D = Animable<3, T>; -#endif +typedef BasicAnimable<3, Float> Animable3D; }} diff --git a/src/SceneGraph/Animable.hpp b/src/SceneGraph/Animable.hpp index 8e5cf3bdf..061e4f836 100644 --- a/src/SceneGraph/Animable.hpp +++ b/src/SceneGraph/Animable.hpp @@ -35,11 +35,11 @@ namespace Magnum { namespace SceneGraph { -template Animable::Animable(AbstractObject* object, AnimableGroup* group): AbstractBasicGroupedFeature, T>(object, group), _duration(0.0f), startTime(std::numeric_limits::infinity()), pauseTime(-std::numeric_limits::infinity()), previousState(AnimationState::Stopped), currentState(AnimationState::Stopped), _repeated(false), _repeatCount(0), repeats(0) {} +template BasicAnimable::BasicAnimable(AbstractObject* object, BasicAnimableGroup* group): AbstractBasicGroupedFeature, T>(object, group), _duration(0.0f), startTime(std::numeric_limits::infinity()), pauseTime(-std::numeric_limits::infinity()), previousState(AnimationState::Stopped), currentState(AnimationState::Stopped), _repeated(false), _repeatCount(0), repeats(0) {} -template Animable::~Animable() {} +template BasicAnimable::~BasicAnimable() {} -template Animable* Animable::setState(AnimationState state) { +template BasicAnimable* BasicAnimable::setState(AnimationState state) { if(currentState == state) return this; /* Not allowed (for sanity) */ @@ -52,20 +52,20 @@ template Animable* Animable AnimableGroup* Animable::group() { - return static_cast*>(AbstractBasicGroupedFeature, T>::group()); +template BasicAnimableGroup* BasicAnimable::group() { + return static_cast*>(AbstractBasicGroupedFeature, T>::group()); } -template const AnimableGroup* Animable::group() const { - return static_cast*>(AbstractBasicGroupedFeature, T>::group()); +template const BasicAnimableGroup* BasicAnimable::group() const { + return static_cast*>(AbstractBasicGroupedFeature, T>::group()); } -template void AnimableGroup::step(const Float time, const Float delta) { +template void BasicAnimableGroup::step(const Float time, const Float delta) { if(!_runningCount && !wakeUp) return; wakeUp = false; for(std::size_t i = 0; i != this->size(); ++i) { - Animable* animable = (*this)[i]; + BasicAnimable* animable = (*this)[i]; /* The animation was stopped recently, just decrease count of running animations if the animation was running before */ @@ -126,9 +126,9 @@ template void AnimableGroup::ste /* Animation is still running, perform animation step */ CORRADE_ASSERT(time-animable->startTime >= 0.0f, - "SceneGraph::AnimableGroup::step(): animation was started in future - probably wrong time passed", ); + "SceneGraph::BasicAnimableGroup::step(): animation was started in future - probably wrong time passed", ); CORRADE_ASSERT(delta >= 0.0f, - "SceneGraph::AnimableGroup::step(): negative delta passed", ); + "SceneGraph::BasicAnimableGroup::step(): negative delta passed", ); animable->animationStep(time - animable->startTime, delta); } diff --git a/src/SceneGraph/AnimableGroup.h b/src/SceneGraph/AnimableGroup.h index 355a29478..835ee4769 100644 --- a/src/SceneGraph/AnimableGroup.h +++ b/src/SceneGraph/AnimableGroup.h @@ -25,7 +25,7 @@ */ /** @file - * @brief Class Magnum::SceneGraph::AnimableGroup + * @brief Class Magnum::SceneGraph::BasicAnimableGroup, typedef Magnum::SceneGraph::AnimableGroup2D, Magnum::SceneGraph::AnimableGroup3D */ #include "FeatureGroup.h" @@ -37,22 +37,17 @@ namespace Magnum { namespace SceneGraph { /** @brief Group of animables -See Animable for more information. -@see @ref scenegraph, AnimableGroup2D, AnimableGroup3D +See BasicAnimable for more information. +@see @ref AnimableGroup2D, @ref AnimableGroup3D, @ref scenegraph */ -#ifndef DOXYGEN_GENERATING_OUTPUT -template -#else -template -#endif -class MAGNUM_SCENEGRAPH_EXPORT AnimableGroup: public BasicFeatureGroup, T> { - friend class Animable; +template class MAGNUM_SCENEGRAPH_EXPORT BasicAnimableGroup: public BasicFeatureGroup, T> { + friend class BasicAnimable; public: /** * @brief Constructor */ - explicit AnimableGroup(): _runningCount(0), wakeUp(false) {} + explicit BasicAnimableGroup(): _runningCount(0), wakeUp(false) {} /** * @brief Count of running animations @@ -76,37 +71,19 @@ class MAGNUM_SCENEGRAPH_EXPORT AnimableGroup: public BasicFeatureGroup%AnimableGroup<2, T>. See Animable for -more information. -@note Not available on GCC < 4.7. Use %AnimableGroup<2, T> instead. -@see AnimableGroup3D +@see @ref AnimableGroup3D */ -#ifdef DOXYGEN_GENERATING_OUTPUT -template -#else -template -#endif -using AnimableGroup2D = AnimableGroup<2, T>; +typedef BasicAnimableGroup<2, Float> AnimableGroup2D; /** -@brief Three-dimensional animable +@brief Animable group for three-dimensional float scenes -Convenience alternative to %AnimableGroup<3, T>. See Animable for -more information. -@note Not available on GCC < 4.7. Use %AnimableGroup<3, T> instead. -@see AnimableGroup2D +@see @ref AnimableGroup2D */ -#ifdef DOXYGEN_GENERATING_OUTPUT -template -#else -template -#endif -using AnimableGroup3D = AnimableGroup<3, T>; -#endif +typedef BasicAnimableGroup<3, Float> AnimableGroup3D; }} diff --git a/src/SceneGraph/SceneGraph.h b/src/SceneGraph/SceneGraph.h index ff1d965f4..d29010697 100644 --- a/src/SceneGraph/SceneGraph.h +++ b/src/SceneGraph/SceneGraph.h @@ -77,19 +77,15 @@ template class AbstractTranslationRotation3D; template class AbstractTranslationRotationScaling2D; template class AbstractTranslationRotationScaling3D; -template class Animable; -#ifndef CORRADE_GCC46_COMPATIBILITY -template using Animable2D = Animable<2, T>; -template using Animable3D = Animable<3, T>; -#endif +template class BasicAnimable; +typedef BasicAnimable<2, Float> Animable2D; +typedef BasicAnimable<3, Float> Animable3D; enum class AnimationState: UnsignedByte; -template class AnimableGroup; -#ifndef CORRADE_GCC46_COMPATIBILITY -template using AnimableGroup2D = AnimableGroup<2, T>; -template using AnimableGroup3D = AnimableGroup<3, T>; -#endif +template class BasicAnimableGroup; +typedef BasicAnimableGroup<2, Float> AnimableGroup2D; +typedef BasicAnimableGroup<3, Float> AnimableGroup3D; template class BasicCamera2D; template class BasicCamera3D; diff --git a/src/SceneGraph/Test/AnimableTest.cpp b/src/SceneGraph/Test/AnimableTest.cpp index 3f6e02adf..e7a77e2a1 100644 --- a/src/SceneGraph/Test/AnimableTest.cpp +++ b/src/SceneGraph/Test/AnimableTest.cpp @@ -59,9 +59,9 @@ AnimableTest::AnimableTest() { } void AnimableTest::state() { - class StateTrackingAnimable: public SceneGraph::Animable<3> { + class StateTrackingAnimable: public SceneGraph::Animable3D { public: - StateTrackingAnimable(AbstractObject<3>* object, AnimableGroup<3>* group = nullptr): SceneGraph::Animable<3>(object, group) { + StateTrackingAnimable(AbstractObject<3>* object, AnimableGroup3D* group = nullptr): SceneGraph::Animable3D(object, group) { setDuration(1.0f); } @@ -77,7 +77,7 @@ void AnimableTest::state() { }; Object3D object; - AnimableGroup<3> group; + AnimableGroup3D group; CORRADE_COMPARE(group.runningCount(), 0); /* Verify initial state */ @@ -149,9 +149,9 @@ void AnimableTest::state() { CORRADE_COMPARE(group.runningCount(), 2); } -class OneShotAnimable: public SceneGraph::Animable<3> { +class OneShotAnimable: public SceneGraph::Animable3D { public: - OneShotAnimable(AbstractObject<3>* object, AnimableGroup<3>* group = nullptr): SceneGraph::Animable<3>(object, group), time(-1.0f) { + OneShotAnimable(AbstractObject<3>* object, AnimableGroup3D* group = nullptr): SceneGraph::Animable3D(object, group), time(-1.0f) { setDuration(10.0f); setState(AnimationState::Running); } @@ -174,9 +174,9 @@ class OneShotAnimable: public SceneGraph::Animable<3> { }; void AnimableTest::step() { - class InifiniteAnimable: public SceneGraph::Animable<3> { + class InifiniteAnimable: public SceneGraph::Animable3D { public: - InifiniteAnimable(AbstractObject<3>* object, AnimableGroup<3>* group = nullptr): SceneGraph::Animable<3>(object, group), time(-1.0f), delta(0.0f) {} + InifiniteAnimable(AbstractObject<3>* object, AnimableGroup3D* group = nullptr): SceneGraph::Animable3D(object, group), time(-1.0f), delta(0.0f) {} Float time, delta; @@ -188,7 +188,7 @@ void AnimableTest::step() { }; Object3D object; - AnimableGroup<3> group; + AnimableGroup3D group; InifiniteAnimable animable(&object, &group); /* Calling step() if no object is running should do nothing */ @@ -213,7 +213,7 @@ void AnimableTest::step() { void AnimableTest::duration() { Object3D object; - AnimableGroup<3> group; + AnimableGroup3D group; OneShotAnimable animable(&object, &group); CORRADE_VERIFY(!animable.isRepeated()); @@ -233,9 +233,9 @@ void AnimableTest::duration() { } void AnimableTest::repeat() { - class RepeatingAnimable: public SceneGraph::Animable<3> { + class RepeatingAnimable: public SceneGraph::Animable3D { public: - RepeatingAnimable(AbstractObject<3>* object, AnimableGroup<3>* group = nullptr): SceneGraph::Animable<3>(object, group), time(-1.0f) { + RepeatingAnimable(AbstractObject<3>* object, AnimableGroup3D* group = nullptr): SceneGraph::Animable3D(object, group), time(-1.0f) { setDuration(10.0f); setState(AnimationState::Running); setRepeated(true); @@ -250,7 +250,7 @@ void AnimableTest::repeat() { }; Object3D object; - AnimableGroup<3> group; + AnimableGroup3D group; RepeatingAnimable animable(&object, &group); CORRADE_COMPARE(animable.repeatCount(), 0); @@ -295,7 +295,7 @@ void AnimableTest::repeat() { void AnimableTest::stop() { Object3D object; - AnimableGroup<3> group; + AnimableGroup3D group; OneShotAnimable animable(&object, &group); CORRADE_COMPARE(animable.repeatCount(), 0); @@ -320,7 +320,7 @@ void AnimableTest::stop() { void AnimableTest::pause() { Object3D object; - AnimableGroup<3> group; + AnimableGroup3D group; OneShotAnimable animable(&object, &group); /* First two steps, animation is running */