Browse Source

Getting rid of <>, part 4: SceneGraph animable and animable group.

pull/278/head
Vladimír Vondruš 13 years ago
parent
commit
c32c12b387
  1. 8
      src/SceneGraph/Animable.cpp
  2. 107
      src/SceneGraph/Animable.h
  3. 22
      src/SceneGraph/Animable.hpp
  4. 47
      src/SceneGraph/AnimableGroup.h
  5. 16
      src/SceneGraph/SceneGraph.h
  6. 28
      src/SceneGraph/Test/AnimableTest.cpp

8
src/SceneGraph/Animable.cpp

@ -27,10 +27,10 @@
namespace Magnum { namespace SceneGraph { namespace Magnum { namespace SceneGraph {
#ifndef DOXYGEN_GENERATING_OUTPUT #ifndef DOXYGEN_GENERATING_OUTPUT
template class MAGNUM_SCENEGRAPH_EXPORT Animable<2, Float>; template class MAGNUM_SCENEGRAPH_EXPORT BasicAnimable<2, Float>;
template class MAGNUM_SCENEGRAPH_EXPORT Animable<3, Float>; template class MAGNUM_SCENEGRAPH_EXPORT BasicAnimable<3, Float>;
template class MAGNUM_SCENEGRAPH_EXPORT AnimableGroup<2, Float>; template class MAGNUM_SCENEGRAPH_EXPORT BasicAnimableGroup<2, Float>;
template class MAGNUM_SCENEGRAPH_EXPORT AnimableGroup<3, Float>; template class MAGNUM_SCENEGRAPH_EXPORT BasicAnimableGroup<3, Float>;
#endif #endif
Debug operator<<(Debug debug, AnimationState value) { Debug operator<<(Debug debug, AnimationState value) {

107
src/SceneGraph/Animable.h

@ -25,7 +25,7 @@
*/ */
/** @file /** @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" #include "AbstractGroupedFeature.h"
@ -37,7 +37,7 @@ namespace Magnum { namespace SceneGraph {
/** /**
@brief Animation state @brief Animation state
@see Animable::setState() @see BasicAnimable::setState()
*/ */
enum class AnimationState: UnsignedByte { enum class AnimationState: UnsignedByte {
/** /**
@ -56,7 +56,7 @@ enum class AnimationState: UnsignedByte {
Running Running
}; };
/** @debugoperator{Magnum::SceneGraph::Animable} */ /** @debugoperator{Magnum::SceneGraph::BasicAnimable} */
Debug MAGNUM_SCENEGRAPH_EXPORT operator<<(Debug debug, AnimationState value); Debug MAGNUM_SCENEGRAPH_EXPORT operator<<(Debug debug, AnimationState value);
/** /**
@ -76,9 +76,9 @@ time and time delta. Example:
typedef SceneGraph::Object<SceneGraph::MatrixTransformation3D<>> Object3D; typedef SceneGraph::Object<SceneGraph::MatrixTransformation3D<>> Object3D;
typedef SceneGraph::Scene<SceneGraph::MatrixTransformation3D<>> Scene3D; typedef SceneGraph::Scene<SceneGraph::MatrixTransformation3D<>> Scene3D;
class AnimableObject: public Object3D, SceneGraph::Animable3D<> { class AnimableObject: public Object3D, SceneGraph::Animable3D {
public: 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); setDuration(10.0f);
// ... // ...
} }
@ -90,22 +90,23 @@ class AnimableObject: public Object3D, SceneGraph::Animable3D<> {
@endcode @endcode
Then add the object to your scene and some animation group. You can also use 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 BasicAnimableGroup::add() and BasicAnimableGroup::remove() instead of passing
in the constructor. The animation is initially in stopped state and without the group in the constructor. The animation is initially in stopped state and
repeat, see setState(), setRepeated() and setRepeatCount() for more information. without repeat, see setState(), setRepeated() and setRepeatCount() for more
information.
@code @code
Scene3D scene; Scene3D scene;
SceneGraph::AnimableGroup3D<> animables; SceneGraph::AnimableGroup3D animables;
(new AnimableObject(&scene, &animables)) (new AnimableObject(&scene, &animables))
->setState(SceneGraph::AnimationState::Running); ->setState(SceneGraph::AnimationState::Running);
// ... // ...
@endcode @endcode
Animation step is performed by calling AnimableGroup::step() in your draw event Animation step is performed by calling BasicAnimableGroup::step() in your draw
implementation. The function expects absolute time from relative to some fixed event implementation. The function expects absolute time from relative to some
point in the past and time delta (i.e. duration of the frame). You can use fixed point in the past and time delta (i.e. duration of the frame). You can
Timeline for that, see its documentation for more information. use Timeline for that, see its documentation for more information.
@code @code
Timeline timeline; Timeline timeline;
timeline.start(); timeline.start();
@ -121,11 +122,11 @@ void MyApplication::drawEvent() {
@section Animable-performance Using animable groups to improve performance @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 puts itself to rest and waits until some animation changes its state to
@ref AnimationState "AnimationState::Running" again. If you put animations @ref AnimationState "AnimationState::Running" again. If you put animations
which are not pernamently running to separate group, they will not be always 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 @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 Animable.hpp implementation file to avoid linker errors. See also
@ref compilation-speedup-hpp for more information. @ref compilation-speedup-hpp for more information.
- @ref Animable "Animable<2, Float>", @ref AnimableGroup "AnimableGroup<2, Float>" - @ref BasicAnimable "BasicAnimable<2, Float>", @ref BasicAnimableGroup "BasicAnimableGroup<2, Float>"
- @ref Animable "Animable<3, Float>", @ref AnimableGroup "AnimableGroup<3, 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<UnsignedInt dimensions, class T> class MAGNUM_SCENEGRAPH_EXPORT BasicAnimable: public AbstractBasicGroupedFeature<dimensions, BasicAnimable<dimensions, T>, T> {
template<UnsignedInt dimensions, class T> friend class BasicAnimableGroup<dimensions, T>;
#else
template<UnsignedInt dimensions, class T = Float>
#endif
class MAGNUM_SCENEGRAPH_EXPORT Animable: public AbstractBasicGroupedFeature<dimensions, Animable<dimensions, T>, T> {
friend class AnimableGroup<dimensions, T>;
public: public:
/** /**
@ -155,11 +152,11 @@ class MAGNUM_SCENEGRAPH_EXPORT Animable: public AbstractBasicGroupedFeature<dime
* *
* Creates stopped non-repeating animation with infinite duration, * Creates stopped non-repeating animation with infinite duration,
* adds the feature to the object and also to group, if specified. * adds the feature to the object and also to group, if specified.
* @see setDuration(), setState(), setRepeated(), AnimableGroup::add() * @see setDuration(), setState(), setRepeated(), BasicAnimableGroup::add()
*/ */
explicit Animable(AbstractObject<dimensions, T>* object, AnimableGroup<dimensions, T>* group = nullptr); explicit BasicAnimable(AbstractObject<dimensions, T>* object, BasicAnimableGroup<dimensions, T>* group = nullptr);
~Animable(); ~BasicAnimable();
/** @brief Animation duration */ /** @brief Animation duration */
Float duration() const { return _duration; } Float duration() const { return _duration; }
@ -178,7 +175,7 @@ class MAGNUM_SCENEGRAPH_EXPORT Animable: public AbstractBasicGroupedFeature<dime
* @see animationStarted(), animationPaused(), animationResumed(), * @see animationStarted(), animationPaused(), animationResumed(),
* animationStopped() * animationStopped()
*/ */
Animable<dimensions, T>* setState(AnimationState state); BasicAnimable<dimensions, T>* setState(AnimationState state);
/** /**
* @brief Whether the animation is repeated * @brief Whether the animation is repeated
@ -194,7 +191,7 @@ class MAGNUM_SCENEGRAPH_EXPORT Animable: public AbstractBasicGroupedFeature<dime
* Default is `false`. * Default is `false`.
* @see setRepeatCount() * @see setRepeatCount()
*/ */
Animable<dimensions, T>* setRepeated(bool repeated) { BasicAnimable<dimensions, T>* setRepeated(bool repeated) {
_repeated = repeated; _repeated = repeated;
return this; return this;
} }
@ -214,7 +211,7 @@ class MAGNUM_SCENEGRAPH_EXPORT Animable: public AbstractBasicGroupedFeature<dime
* infinitely repeated animation. Default is `0`. * infinitely repeated animation. Default is `0`.
* @see setRepeated() * @see setRepeated()
*/ */
Animable<dimensions, T>* setRepeatCount(UnsignedShort count) { BasicAnimable<dimensions, T>* setRepeatCount(UnsignedShort count) {
_repeatCount = count; _repeatCount = count;
return this; return this;
} }
@ -224,8 +221,8 @@ class MAGNUM_SCENEGRAPH_EXPORT Animable: public AbstractBasicGroupedFeature<dime
* *
* If the animable doesn't belong to any group, returns `nullptr`. * If the animable doesn't belong to any group, returns `nullptr`.
*/ */
AnimableGroup<dimensions, T>* group(); BasicAnimableGroup<dimensions, T>* group();
const AnimableGroup<dimensions, T>* group() const; /**< @overload */ const BasicAnimableGroup<dimensions, T>* group() const; /**< @overload */
protected: protected:
/** /**
@ -236,7 +233,7 @@ class MAGNUM_SCENEGRAPH_EXPORT Animable: public AbstractBasicGroupedFeature<dime
* infinite non-repeating animation. Default is `0.0f`. * infinite non-repeating animation. Default is `0.0f`.
*/ */
/* Protected so only animation implementer can change it */ /* Protected so only animation implementer can change it */
Animable<dimensions, T>* setDuration(Float duration) { BasicAnimable<dimensions, T>* setDuration(Float duration) {
_duration = duration; _duration = duration;
return this; return this;
} }
@ -246,8 +243,8 @@ class MAGNUM_SCENEGRAPH_EXPORT Animable: public AbstractBasicGroupedFeature<dime
* @param time Time from start of the animation * @param time Time from start of the animation
* @param delta Time delta for current frame * @param delta Time delta for current frame
* *
* This function is periodically called from AnimableGroup::step() if * This function is periodically called from BasicAnimableGroup::step()
* the animation state is set to @ref AnimationState "AnimationState::Running". * if the animation state is set to @ref AnimationState "AnimationState::Running".
* After animation duration is exceeded and repeat is not enabled or * After animation duration is exceeded and repeat is not enabled or
* repeat count is exceeded, the animation state is set to * repeat count is exceeded, the animation state is set to
* @ref AnimationState "AnimationState::Stopped". * @ref AnimationState "AnimationState::Stopped".
@ -265,7 +262,7 @@ class MAGNUM_SCENEGRAPH_EXPORT Animable: public AbstractBasicGroupedFeature<dime
/** /**
* @brief Action on animation start * @brief Action on animation start
* *
* Called from AnimableGroup::step() when state is changed from * Called from BasicAnimableGroup::step() when state is changed from
* @ref AnimationState "AnimationState::Stopped" to * @ref AnimationState "AnimationState::Stopped" to
* @ref AnimationState "AnimationState::Running" and before first * @ref AnimationState "AnimationState::Running" and before first
* animationStep() is called. * animationStep() is called.
@ -279,7 +276,7 @@ class MAGNUM_SCENEGRAPH_EXPORT Animable: public AbstractBasicGroupedFeature<dime
/** /**
* @brief Action on animation pause * @brief Action on animation pause
* *
* Called from AnimableGroup::step() when state changes from * Called from BasicAnimableGroup::step() when state changes from
* @ref AnimationState "AnimationState::Running" to * @ref AnimationState "AnimationState::Running" to
* @ref AnimationState "AnimationState::Paused" and after last * @ref AnimationState "AnimationState::Paused" and after last
* animationStep() is called. * animationStep() is called.
@ -293,7 +290,7 @@ class MAGNUM_SCENEGRAPH_EXPORT Animable: public AbstractBasicGroupedFeature<dime
/** /**
* @brief Action on animation resume * @brief Action on animation resume
* *
* Called from AnimableGroup::step() when state changes from * Called from BasicAnimableGroup::step() when state changes from
* @ref AnimationState "AnimationState::Paused" to * @ref AnimationState "AnimationState::Paused" to
* @ref AnimationState "AnimationState::Running" and before first * @ref AnimationState "AnimationState::Running" and before first
* animationStep() is called. * animationStep() is called.
@ -307,7 +304,7 @@ class MAGNUM_SCENEGRAPH_EXPORT Animable: public AbstractBasicGroupedFeature<dime
/** /**
* @brief Action on animation stop * @brief Action on animation stop
* *
* Called from AnimableGroup::step() when state changes from either * Called from BasicAnimableGroup::step() when state changes from either
* @ref AnimationState "AnimationState::Running" or * @ref AnimationState "AnimationState::Running" or
* @ref AnimationState "AnimationState::Paused" to * @ref AnimationState "AnimationState::Paused" to
* @ref AnimationState "AnimationState::Stopped" and after last * @ref AnimationState "AnimationState::Stopped" and after last
@ -331,37 +328,19 @@ class MAGNUM_SCENEGRAPH_EXPORT Animable: public AbstractBasicGroupedFeature<dime
UnsignedShort repeats; UnsignedShort repeats;
}; };
#ifndef CORRADE_GCC46_COMPATIBILITY
/** /**
@brief Two-dimensional drawable @brief Animable for two-dimensional float scenes
Convenience alternative to <tt>%Animable<2, T></tt>. See Animable for more @see @ref Animable3D
information.
@note Not available on GCC < 4.7. Use <tt>%Animable<2, T></tt> instead.
@see Animable3D
*/ */
#ifdef DOXYGEN_GENERATING_OUTPUT typedef BasicAnimable<2, Float> Animable2D;
template<class T = Float>
#else
template<class T>
#endif
using Animable2D = Animable<2, T>;
/** /**
@brief Three-dimensional animable @brief Animable for three-dimensional float scenes
Convenience alternative to <tt>%Animable<3, T></tt>. See Animable for more @see @ref Animable2D
information.
@note Not available on GCC < 4.7. Use <tt>%Animable<3, T></tt> instead.
@see Animable2D
*/ */
#ifdef DOXYGEN_GENERATING_OUTPUT typedef BasicAnimable<3, Float> Animable3D;
template<class T = Float>
#else
template<class T>
#endif
using Animable3D = Animable<3, T>;
#endif
}} }}

22
src/SceneGraph/Animable.hpp

@ -35,11 +35,11 @@
namespace Magnum { namespace SceneGraph { namespace Magnum { namespace SceneGraph {
template<UnsignedInt dimensions, class T> Animable<dimensions, T>::Animable(AbstractObject<dimensions, T>* object, AnimableGroup<dimensions, T>* group): AbstractBasicGroupedFeature<dimensions, Animable<dimensions, T>, T>(object, group), _duration(0.0f), startTime(std::numeric_limits<Float>::infinity()), pauseTime(-std::numeric_limits<Float>::infinity()), previousState(AnimationState::Stopped), currentState(AnimationState::Stopped), _repeated(false), _repeatCount(0), repeats(0) {} template<UnsignedInt dimensions, class T> BasicAnimable<dimensions, T>::BasicAnimable(AbstractObject<dimensions, T>* object, BasicAnimableGroup<dimensions, T>* group): AbstractBasicGroupedFeature<dimensions, BasicAnimable<dimensions, T>, T>(object, group), _duration(0.0f), startTime(std::numeric_limits<Float>::infinity()), pauseTime(-std::numeric_limits<Float>::infinity()), previousState(AnimationState::Stopped), currentState(AnimationState::Stopped), _repeated(false), _repeatCount(0), repeats(0) {}
template<UnsignedInt dimensions, class T> Animable<dimensions, T>::~Animable() {} template<UnsignedInt dimensions, class T> BasicAnimable<dimensions, T>::~BasicAnimable() {}
template<UnsignedInt dimensions, class T> Animable<dimensions, T>* Animable<dimensions, T>::setState(AnimationState state) { template<UnsignedInt dimensions, class T> BasicAnimable<dimensions, T>* BasicAnimable<dimensions, T>::setState(AnimationState state) {
if(currentState == state) return this; if(currentState == state) return this;
/* Not allowed (for sanity) */ /* Not allowed (for sanity) */
@ -52,20 +52,20 @@ template<UnsignedInt dimensions, class T> Animable<dimensions, T>* Animable<dime
return this; return this;
} }
template<UnsignedInt dimensions, class T> AnimableGroup<dimensions, T>* Animable<dimensions, T>::group() { template<UnsignedInt dimensions, class T> BasicAnimableGroup<dimensions, T>* BasicAnimable<dimensions, T>::group() {
return static_cast<AnimableGroup<dimensions, T>*>(AbstractBasicGroupedFeature<dimensions, Animable<dimensions, T>, T>::group()); return static_cast<BasicAnimableGroup<dimensions, T>*>(AbstractBasicGroupedFeature<dimensions, BasicAnimable<dimensions, T>, T>::group());
} }
template<UnsignedInt dimensions, class T> const AnimableGroup<dimensions, T>* Animable<dimensions, T>::group() const { template<UnsignedInt dimensions, class T> const BasicAnimableGroup<dimensions, T>* BasicAnimable<dimensions, T>::group() const {
return static_cast<const AnimableGroup<dimensions, T>*>(AbstractBasicGroupedFeature<dimensions, Animable<dimensions, T>, T>::group()); return static_cast<const BasicAnimableGroup<dimensions, T>*>(AbstractBasicGroupedFeature<dimensions, BasicAnimable<dimensions, T>, T>::group());
} }
template<UnsignedInt dimensions, class T> void AnimableGroup<dimensions, T>::step(const Float time, const Float delta) { template<UnsignedInt dimensions, class T> void BasicAnimableGroup<dimensions, T>::step(const Float time, const Float delta) {
if(!_runningCount && !wakeUp) return; if(!_runningCount && !wakeUp) return;
wakeUp = false; wakeUp = false;
for(std::size_t i = 0; i != this->size(); ++i) { for(std::size_t i = 0; i != this->size(); ++i) {
Animable<dimensions, T>* animable = (*this)[i]; BasicAnimable<dimensions, T>* animable = (*this)[i];
/* The animation was stopped recently, just decrease count of running /* The animation was stopped recently, just decrease count of running
animations if the animation was running before */ animations if the animation was running before */
@ -126,9 +126,9 @@ template<UnsignedInt dimensions, class T> void AnimableGroup<dimensions, T>::ste
/* Animation is still running, perform animation step */ /* Animation is still running, perform animation step */
CORRADE_ASSERT(time-animable->startTime >= 0.0f, 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, CORRADE_ASSERT(delta >= 0.0f,
"SceneGraph::AnimableGroup::step(): negative delta passed", ); "SceneGraph::BasicAnimableGroup::step(): negative delta passed", );
animable->animationStep(time - animable->startTime, delta); animable->animationStep(time - animable->startTime, delta);
} }

47
src/SceneGraph/AnimableGroup.h

@ -25,7 +25,7 @@
*/ */
/** @file /** @file
* @brief Class Magnum::SceneGraph::AnimableGroup * @brief Class Magnum::SceneGraph::BasicAnimableGroup, typedef Magnum::SceneGraph::AnimableGroup2D, Magnum::SceneGraph::AnimableGroup3D
*/ */
#include "FeatureGroup.h" #include "FeatureGroup.h"
@ -37,22 +37,17 @@ namespace Magnum { namespace SceneGraph {
/** /**
@brief Group of animables @brief Group of animables
See Animable for more information. See BasicAnimable for more information.
@see @ref scenegraph, AnimableGroup2D, AnimableGroup3D @see @ref AnimableGroup2D, @ref AnimableGroup3D, @ref scenegraph
*/ */
#ifndef DOXYGEN_GENERATING_OUTPUT template<UnsignedInt dimensions, class T> class MAGNUM_SCENEGRAPH_EXPORT BasicAnimableGroup: public BasicFeatureGroup<dimensions, BasicAnimable<dimensions, T>, T> {
template<UnsignedInt dimensions, class T> friend class BasicAnimable<dimensions, T>;
#else
template<UnsignedInt dimensions, class T = Float>
#endif
class MAGNUM_SCENEGRAPH_EXPORT AnimableGroup: public BasicFeatureGroup<dimensions, Animable<dimensions, T>, T> {
friend class Animable<dimensions, T>;
public: public:
/** /**
* @brief Constructor * @brief Constructor
*/ */
explicit AnimableGroup(): _runningCount(0), wakeUp(false) {} explicit BasicAnimableGroup(): _runningCount(0), wakeUp(false) {}
/** /**
* @brief Count of running animations * @brief Count of running animations
@ -76,37 +71,19 @@ class MAGNUM_SCENEGRAPH_EXPORT AnimableGroup: public BasicFeatureGroup<dimension
bool wakeUp; bool wakeUp;
}; };
#ifndef CORRADE_GCC46_COMPATIBILITY
/** /**
@brief Two-dimensional drawable @brief Animable group for two-dimensional float scenes
Convenience alternative to <tt>%AnimableGroup<2, T></tt>. See Animable for @see @ref AnimableGroup3D
more information.
@note Not available on GCC < 4.7. Use <tt>%AnimableGroup<2, T></tt> instead.
@see AnimableGroup3D
*/ */
#ifdef DOXYGEN_GENERATING_OUTPUT typedef BasicAnimableGroup<2, Float> AnimableGroup2D;
template<class T = Float>
#else
template<class T>
#endif
using AnimableGroup2D = AnimableGroup<2, T>;
/** /**
@brief Three-dimensional animable @brief Animable group for three-dimensional float scenes
Convenience alternative to <tt>%AnimableGroup<3, T></tt>. See Animable for @see @ref AnimableGroup2D
more information.
@note Not available on GCC < 4.7. Use <tt>%AnimableGroup<3, T></tt> instead.
@see AnimableGroup2D
*/ */
#ifdef DOXYGEN_GENERATING_OUTPUT typedef BasicAnimableGroup<3, Float> AnimableGroup3D;
template<class T = Float>
#else
template<class T>
#endif
using AnimableGroup3D = AnimableGroup<3, T>;
#endif
}} }}

16
src/SceneGraph/SceneGraph.h

@ -77,19 +77,15 @@ template<class T = Float> class AbstractTranslationRotation3D;
template<class T = Float> class AbstractTranslationRotationScaling2D; template<class T = Float> class AbstractTranslationRotationScaling2D;
template<class T = Float> class AbstractTranslationRotationScaling3D; template<class T = Float> class AbstractTranslationRotationScaling3D;
template<UnsignedInt dimensions, class T = Float> class Animable; template<UnsignedInt, class> class BasicAnimable;
#ifndef CORRADE_GCC46_COMPATIBILITY typedef BasicAnimable<2, Float> Animable2D;
template<class T = Float> using Animable2D = Animable<2, T>; typedef BasicAnimable<3, Float> Animable3D;
template<class T = Float> using Animable3D = Animable<3, T>;
#endif
enum class AnimationState: UnsignedByte; enum class AnimationState: UnsignedByte;
template<UnsignedInt dimensions, class T = Float> class AnimableGroup; template<UnsignedInt, class> class BasicAnimableGroup;
#ifndef CORRADE_GCC46_COMPATIBILITY typedef BasicAnimableGroup<2, Float> AnimableGroup2D;
template<class T = Float> using AnimableGroup2D = AnimableGroup<2, T>; typedef BasicAnimableGroup<3, Float> AnimableGroup3D;
template<class T = Float> using AnimableGroup3D = AnimableGroup<3, T>;
#endif
template<class> class BasicCamera2D; template<class> class BasicCamera2D;
template<class> class BasicCamera3D; template<class> class BasicCamera3D;

28
src/SceneGraph/Test/AnimableTest.cpp

@ -59,9 +59,9 @@ AnimableTest::AnimableTest() {
} }
void AnimableTest::state() { void AnimableTest::state() {
class StateTrackingAnimable: public SceneGraph::Animable<3> { class StateTrackingAnimable: public SceneGraph::Animable3D {
public: 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); setDuration(1.0f);
} }
@ -77,7 +77,7 @@ void AnimableTest::state() {
}; };
Object3D object; Object3D object;
AnimableGroup<3> group; AnimableGroup3D group;
CORRADE_COMPARE(group.runningCount(), 0); CORRADE_COMPARE(group.runningCount(), 0);
/* Verify initial state */ /* Verify initial state */
@ -149,9 +149,9 @@ void AnimableTest::state() {
CORRADE_COMPARE(group.runningCount(), 2); CORRADE_COMPARE(group.runningCount(), 2);
} }
class OneShotAnimable: public SceneGraph::Animable<3> { class OneShotAnimable: public SceneGraph::Animable3D {
public: 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); setDuration(10.0f);
setState(AnimationState::Running); setState(AnimationState::Running);
} }
@ -174,9 +174,9 @@ class OneShotAnimable: public SceneGraph::Animable<3> {
}; };
void AnimableTest::step() { void AnimableTest::step() {
class InifiniteAnimable: public SceneGraph::Animable<3> { class InifiniteAnimable: public SceneGraph::Animable3D {
public: 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; Float time, delta;
@ -188,7 +188,7 @@ void AnimableTest::step() {
}; };
Object3D object; Object3D object;
AnimableGroup<3> group; AnimableGroup3D group;
InifiniteAnimable animable(&object, &group); InifiniteAnimable animable(&object, &group);
/* Calling step() if no object is running should do nothing */ /* Calling step() if no object is running should do nothing */
@ -213,7 +213,7 @@ void AnimableTest::step() {
void AnimableTest::duration() { void AnimableTest::duration() {
Object3D object; Object3D object;
AnimableGroup<3> group; AnimableGroup3D group;
OneShotAnimable animable(&object, &group); OneShotAnimable animable(&object, &group);
CORRADE_VERIFY(!animable.isRepeated()); CORRADE_VERIFY(!animable.isRepeated());
@ -233,9 +233,9 @@ void AnimableTest::duration() {
} }
void AnimableTest::repeat() { void AnimableTest::repeat() {
class RepeatingAnimable: public SceneGraph::Animable<3> { class RepeatingAnimable: public SceneGraph::Animable3D {
public: 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); setDuration(10.0f);
setState(AnimationState::Running); setState(AnimationState::Running);
setRepeated(true); setRepeated(true);
@ -250,7 +250,7 @@ void AnimableTest::repeat() {
}; };
Object3D object; Object3D object;
AnimableGroup<3> group; AnimableGroup3D group;
RepeatingAnimable animable(&object, &group); RepeatingAnimable animable(&object, &group);
CORRADE_COMPARE(animable.repeatCount(), 0); CORRADE_COMPARE(animable.repeatCount(), 0);
@ -295,7 +295,7 @@ void AnimableTest::repeat() {
void AnimableTest::stop() { void AnimableTest::stop() {
Object3D object; Object3D object;
AnimableGroup<3> group; AnimableGroup3D group;
OneShotAnimable animable(&object, &group); OneShotAnimable animable(&object, &group);
CORRADE_COMPARE(animable.repeatCount(), 0); CORRADE_COMPARE(animable.repeatCount(), 0);
@ -320,7 +320,7 @@ void AnimableTest::stop() {
void AnimableTest::pause() { void AnimableTest::pause() {
Object3D object; Object3D object;
AnimableGroup<3> group; AnimableGroup3D group;
OneShotAnimable animable(&object, &group); OneShotAnimable animable(&object, &group);
/* First two steps, animation is running */ /* First two steps, animation is running */

Loading…
Cancel
Save