diff --git a/src/SceneGraph/Animable.cpp b/src/SceneGraph/Animable.cpp index ad53b31fe..1087f8371 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 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>; +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>; #endif Debug operator<<(Debug debug, AnimationState value) { diff --git a/src/SceneGraph/Animable.h b/src/SceneGraph/Animable.h index 1ebcdcdfa..daa1870ca 100644 --- a/src/SceneGraph/Animable.h +++ b/src/SceneGraph/Animable.h @@ -25,7 +25,7 @@ */ /** @file - * @brief Class Magnum::SceneGraph::BasicAnimable, typedef Magnum::SceneGraph::Animable2D, Magnum::SceneGraph::Animable3D, enum Magnum::SceneGraph::AnimationState + * @brief Class Magnum::SceneGraph::Animable, alias Magnum::SceneGraph::BasicAnimable2D, Magnum::SceneGraph::BasicAnimable3D, 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 BasicAnimable::setState() +@see Animable::setState() */ enum class AnimationState: UnsignedByte { /** @@ -56,7 +56,7 @@ enum class AnimationState: UnsignedByte { Running }; -/** @debugoperator{Magnum::SceneGraph::BasicAnimable} */ +/** @debugoperator{Magnum::SceneGraph::Animable} */ Debug MAGNUM_SCENEGRAPH_EXPORT operator<<(Debug debug, AnimationState value); /** @@ -90,10 +90,9 @@ class AnimableObject: public Object3D, SceneGraph::Animable3D { @endcode Then add the object to your scene and some animation group. You can also use -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. +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. @code Scene3D scene; SceneGraph::AnimableGroup3D animables; @@ -103,10 +102,10 @@ SceneGraph::AnimableGroup3D animables; // ... @endcode -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. +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. @code Timeline timeline; timeline.start(); @@ -122,11 +121,11 @@ void MyApplication::drawEvent() { @section Animable-performance Using animable groups to improve performance -Animable group is optimized for case when no animation is running - it just +AnimableGroup 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 BasicAnimableGroup::step(), saving precious frame time. +traversed when calling AnimableGroup::step(), saving precious frame time. @section Animable-explicit-specializations Explicit template specializations @@ -135,14 +134,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 BasicAnimable "BasicAnimable<2, Float>", @ref BasicAnimableGroup "BasicAnimableGroup<2, Float>" - - @ref BasicAnimable "BasicAnimable<3, Float>", @ref BasicAnimableGroup "BasicAnimableGroup<3, Float>" + - @ref Animable "Animable<2, Float>", @ref AnimableGroup "AnimableGroup<2, Float>" + - @ref Animable "Animable<3, Float>", @ref AnimableGroup "AnimableGroup<3, Float>" -@see @ref Animable2D, @ref Animable3D, @ref scenegraph, @ref AnimableGroup2D, - @ref AnimableGroup3D +@see @ref scenegraph, @ref BasicAnimable2D, @ref BasicAnimable3D, + @ref Animable2D, @ref Animable3D */ -template class MAGNUM_SCENEGRAPH_EXPORT BasicAnimable: public AbstractBasicGroupedFeature, T> { - friend class BasicAnimableGroup; +template class MAGNUM_SCENEGRAPH_EXPORT Animable: public AbstractBasicGroupedFeature, T> { + friend class AnimableGroup; public: /** @@ -152,11 +151,11 @@ template class MAGNUM_SCENEGRAPH_EXPORT BasicAn * * Creates stopped non-repeating animation with infinite duration, * adds the feature to the object and also to group, if specified. - * @see setDuration(), setState(), setRepeated(), BasicAnimableGroup::add() + * @see setDuration(), setState(), setRepeated(), AnimableGroup::add() */ - explicit BasicAnimable(AbstractObject* object, BasicAnimableGroup* group = nullptr); + explicit Animable(AbstractObject* object, AnimableGroup* group = nullptr); - ~BasicAnimable(); + ~Animable(); /** @brief Animation duration */ Float duration() const { return _duration; } @@ -175,7 +174,7 @@ template class MAGNUM_SCENEGRAPH_EXPORT BasicAn * @see animationStarted(), animationPaused(), animationResumed(), * animationStopped() */ - BasicAnimable* setState(AnimationState state); + Animable* setState(AnimationState state); /** * @brief Whether the animation is repeated @@ -191,7 +190,7 @@ template class MAGNUM_SCENEGRAPH_EXPORT BasicAn * Default is `false`. * @see setRepeatCount() */ - BasicAnimable* setRepeated(bool repeated) { + Animable* setRepeated(bool repeated) { _repeated = repeated; return this; } @@ -211,7 +210,7 @@ template class MAGNUM_SCENEGRAPH_EXPORT BasicAn * infinitely repeated animation. Default is `0`. * @see setRepeated() */ - BasicAnimable* setRepeatCount(UnsignedShort count) { + Animable* setRepeatCount(UnsignedShort count) { _repeatCount = count; return this; } @@ -221,8 +220,8 @@ template class MAGNUM_SCENEGRAPH_EXPORT BasicAn * * If the animable doesn't belong to any group, returns `nullptr`. */ - BasicAnimableGroup* group(); - const BasicAnimableGroup* group() const; /**< @overload */ + AnimableGroup* group(); + const AnimableGroup* group() const; /**< @overload */ protected: /** @@ -233,7 +232,7 @@ template class MAGNUM_SCENEGRAPH_EXPORT BasicAn * infinite non-repeating animation. Default is `0.0f`. */ /* Protected so only animation implementer can change it */ - BasicAnimable* setDuration(Float duration) { + Animable* setDuration(Float duration) { _duration = duration; return this; } @@ -243,8 +242,8 @@ template class MAGNUM_SCENEGRAPH_EXPORT BasicAn * @param time Time from start of the animation * @param delta Time delta for current frame * - * This function is periodically called from BasicAnimableGroup::step() - * if the animation state is set to @ref AnimationState "AnimationState::Running". + * This function is periodically called from AnimableGroup::step() if + * the animation state is set to @ref AnimationState "AnimationState::Running". * After animation duration is exceeded and repeat is not enabled or * repeat count is exceeded, the animation state is set to * @ref AnimationState "AnimationState::Stopped". @@ -262,7 +261,7 @@ template class MAGNUM_SCENEGRAPH_EXPORT BasicAn /** * @brief Action on animation start * - * Called from BasicAnimableGroup::step() when state is changed from + * Called from AnimableGroup::step() when state is changed from * @ref AnimationState "AnimationState::Stopped" to * @ref AnimationState "AnimationState::Running" and before first * animationStep() is called. @@ -276,7 +275,7 @@ template class MAGNUM_SCENEGRAPH_EXPORT BasicAn /** * @brief Action on animation pause * - * Called from BasicAnimableGroup::step() when state changes from + * Called from AnimableGroup::step() when state changes from * @ref AnimationState "AnimationState::Running" to * @ref AnimationState "AnimationState::Paused" and after last * animationStep() is called. @@ -290,7 +289,7 @@ template class MAGNUM_SCENEGRAPH_EXPORT BasicAn /** * @brief Action on animation resume * - * Called from BasicAnimableGroup::step() when state changes from + * Called from AnimableGroup::step() when state changes from * @ref AnimationState "AnimationState::Paused" to * @ref AnimationState "AnimationState::Running" and before first * animationStep() is called. @@ -304,7 +303,7 @@ template class MAGNUM_SCENEGRAPH_EXPORT BasicAn /** * @brief Action on animation stop * - * Called from BasicAnimableGroup::step() when state changes from either + * Called from AnimableGroup::step() when state changes from either * @ref AnimationState "AnimationState::Running" or * @ref AnimationState "AnimationState::Paused" to * @ref AnimationState "AnimationState::Stopped" and after last @@ -328,19 +327,51 @@ template class MAGNUM_SCENEGRAPH_EXPORT BasicAn UnsignedShort repeats; }; +#ifndef CORRADE_GCC46_COMPATIBILITY +/** +@brief %Animable for two-dimensional scenes + +Convenience alternative to %Animable<2, T>. See Animable for more +information. +@note Not available on GCC < 4.7. Use %Animable<2, T> instead. +@see @ref Animable2D, @ref BasicAnimable3D +*/ +template using BasicAnimable2D = Animable<2, T>; +#endif + /** -@brief Animable for two-dimensional float scenes +@brief %Animable for two-dimensional float scenes @see @ref Animable3D */ -typedef BasicAnimable<2, Float> Animable2D; +#ifndef CORRADE_GCC46_COMPATIBILITY +typedef BasicAnimable2D Animable2D; +#else +typedef Animable<2, Float> Animable2D; +#endif +#ifndef CORRADE_GCC46_COMPATIBILITY /** -@brief Animable for three-dimensional float scenes +@brief %Animable for three-dimensional 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 @ref Animable3D, @ref BasicAnimable2D +*/ +template using BasicAnimable3D = Animable<3, T>; +#endif + +/** +@brief %Animable for three-dimensional float scenes @see @ref Animable2D */ -typedef BasicAnimable<3, Float> Animable3D; +#ifndef CORRADE_GCC46_COMPATIBILITY +typedef BasicAnimable3D Animable3D; +#else +typedef Animable<3, Float> Animable3D; +#endif }} diff --git a/src/SceneGraph/Animable.hpp b/src/SceneGraph/Animable.hpp index 061e4f836..8e5cf3bdf 100644 --- a/src/SceneGraph/Animable.hpp +++ b/src/SceneGraph/Animable.hpp @@ -35,11 +35,11 @@ namespace Magnum { namespace SceneGraph { -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(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() {} +template Animable::~Animable() {} -template BasicAnimable* BasicAnimable::setState(AnimationState state) { +template Animable* Animable::setState(AnimationState state) { if(currentState == state) return this; /* Not allowed (for sanity) */ @@ -52,20 +52,20 @@ template BasicAnimable* BasicAni return this; } -template BasicAnimableGroup* BasicAnimable::group() { - return static_cast*>(AbstractBasicGroupedFeature, T>::group()); +template AnimableGroup* Animable::group() { + return static_cast*>(AbstractBasicGroupedFeature, T>::group()); } -template const BasicAnimableGroup* BasicAnimable::group() const { - return static_cast*>(AbstractBasicGroupedFeature, T>::group()); +template const AnimableGroup* Animable::group() const { + return static_cast*>(AbstractBasicGroupedFeature, T>::group()); } -template void BasicAnimableGroup::step(const Float time, const Float delta) { +template void AnimableGroup::step(const Float time, const Float delta) { if(!_runningCount && !wakeUp) return; wakeUp = false; for(std::size_t i = 0; i != this->size(); ++i) { - BasicAnimable* animable = (*this)[i]; + Animable* 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 BasicAnimableGroup /* Animation is still running, perform animation step */ CORRADE_ASSERT(time-animable->startTime >= 0.0f, - "SceneGraph::BasicAnimableGroup::step(): animation was started in future - probably wrong time passed", ); + "SceneGraph::AnimableGroup::step(): animation was started in future - probably wrong time passed", ); CORRADE_ASSERT(delta >= 0.0f, - "SceneGraph::BasicAnimableGroup::step(): negative delta passed", ); + "SceneGraph::AnimableGroup::step(): negative delta passed", ); animable->animationStep(time - animable->startTime, delta); } diff --git a/src/SceneGraph/AnimableGroup.h b/src/SceneGraph/AnimableGroup.h index 835ee4769..cbf47af49 100644 --- a/src/SceneGraph/AnimableGroup.h +++ b/src/SceneGraph/AnimableGroup.h @@ -25,7 +25,7 @@ */ /** @file - * @brief Class Magnum::SceneGraph::BasicAnimableGroup, typedef Magnum::SceneGraph::AnimableGroup2D, Magnum::SceneGraph::AnimableGroup3D + * @brief Class Magnum::SceneGraph::AnimableGroup, alias Magnum::SceneGraph::BasicAnimableGroup2D, Magnum::SceneGraph::BasicAnimableGroup3D, typedef Magnum::SceneGraph::AnimableGroup2D, Magnum::SceneGraph::AnimableGroup3D */ #include "FeatureGroup.h" @@ -37,17 +37,18 @@ namespace Magnum { namespace SceneGraph { /** @brief Group of animables -See BasicAnimable for more information. -@see @ref AnimableGroup2D, @ref AnimableGroup3D, @ref scenegraph +See Animable for more information. +@see @ref scenegraph, @ref BasicAnimableGroup2D, @ref BasicAnimableGroup3D, + @ref AnimableGroup2D, @ref AnimableGroup3D */ -template class MAGNUM_SCENEGRAPH_EXPORT BasicAnimableGroup: public BasicFeatureGroup, T> { - friend class BasicAnimable; +template class MAGNUM_SCENEGRAPH_EXPORT AnimableGroup: public BasicFeatureGroup, T> { + friend class Animable; public: /** * @brief Constructor */ - explicit BasicAnimableGroup(): _runningCount(0), wakeUp(false) {} + explicit AnimableGroup(): _runningCount(0), wakeUp(false) {} /** * @brief Count of running animations @@ -71,19 +72,51 @@ template class MAGNUM_SCENEGRAPH_EXPORT BasicAn bool wakeUp; }; +#ifndef CORRADE_GCC46_COMPATIBILITY /** -@brief Animable group for two-dimensional float scenes +@brief %Animable group for two-dimensional scenes + +Convenience alternative to %AnimableGroup<2, T>. See Animable for +more information. +@note Not available on GCC < 4.7. Use %AnimableGroup<2, T> instead. +@see @ref AnimableGroup2D, @ref BasicAnimableGroup3D +*/ +template using BasicAnimableGroup2D = AnimableGroup<2, T>; +#endif + +/** +@brief %Animable group for two-dimensional float scenes @see @ref AnimableGroup3D */ -typedef BasicAnimableGroup<2, Float> AnimableGroup2D; +#ifndef CORRADE_GCC46_COMPATIBILITY +typedef BasicAnimableGroup2D AnimableGroup2D; +#else +typedef AnimableGroup<2, Float> AnimableGroup2D; +#endif + +#ifndef CORRADE_GCC46_COMPATIBILITY +/** +@brief %Animable group for three-dimensional 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 @ref AnimableGroup3D, @ref BasicAnimableGroup2D +*/ +template using BasicAnimableGroup3D = AnimableGroup<3, T>; +#endif /** -@brief Animable group for three-dimensional float scenes +@brief %Animable group for three-dimensional float scenes @see @ref AnimableGroup2D */ -typedef BasicAnimableGroup<3, Float> AnimableGroup3D; +#ifndef CORRADE_GCC46_COMPATIBILITY +typedef BasicAnimableGroup3D AnimableGroup3D; +#else +typedef AnimableGroup<3, Float> AnimableGroup3D; +#endif }} diff --git a/src/SceneGraph/SceneGraph.h b/src/SceneGraph/SceneGraph.h index 4dfb0a194..d5577b3a6 100644 --- a/src/SceneGraph/SceneGraph.h +++ b/src/SceneGraph/SceneGraph.h @@ -85,15 +85,29 @@ template class AbstractBasicTranslationRotationScaling3D; typedef AbstractBasicTranslationRotationScaling2D AbstractTranslationRotationScaling2D; typedef AbstractBasicTranslationRotationScaling3D AbstractTranslationRotationScaling3D; -template class BasicAnimable; -typedef BasicAnimable<2, Float> Animable2D; -typedef BasicAnimable<3, Float> Animable3D; +template class Animable; +#ifndef CORRADE_GCC46_COMPATIBILITY +template using BasicAnimable2D = Animable<2, T>; +template using BasicAnimable3D = Animable<3, T>; +typedef BasicAnimable2D Animable2D; +typedef BasicAnimable3D Animable3D; +#else +typedef Animable<2, Float> Animable2D; +typedef Animable<3, Float> Animable3D; +#endif enum class AnimationState: UnsignedByte; -template class BasicAnimableGroup; -typedef BasicAnimableGroup<2, Float> AnimableGroup2D; -typedef BasicAnimableGroup<3, Float> AnimableGroup3D; +template class AnimableGroup; +#ifndef CORRADE_GCC46_COMPATIBILITY +template using BasicAnimableGroup2D = AnimableGroup<2, T>; +template using BasicAnimableGroup3D = AnimableGroup<3, T>; +typedef BasicAnimableGroup2D AnimableGroup2D; +typedef BasicAnimableGroup3D AnimableGroup3D; +#else +typedef AnimableGroup<2, Float> AnimableGroup2D; +typedef AnimableGroup<3, Float> AnimableGroup3D; +#endif template class BasicCamera2D; template class BasicCamera3D;