Skip to content

Commit

Permalink
Add "repeatCount" to allowed properties on default clip in animation …
Browse files Browse the repository at this point in the history
…files. Clone default clip on animation cloning.
  • Loading branch information
germinator committed Jan 28, 2013
1 parent 7870f24 commit 46244a2
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 4 deletions.
9 changes: 7 additions & 2 deletions gameplay/src/Animation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#include "Transform.h"
#include "Properties.h"

#define ANIMATION_INDEFINITE_STR "INDEFINITE"
#define ANIMATION_DEFAULT_CLIP 0
#define ANIMATION_ROTATE_OFFSET 0
#define ANIMATION_SRT_OFFSET 3
Expand Down Expand Up @@ -256,7 +255,7 @@ void Animation::createClips(Properties* animationProperties, unsigned int frameC

AnimationClip* clip = createClip(pClip->getId(), ((float) begin / frameCount) * _duration, ((float) end / frameCount) * _duration);

const char* repeat = pClip->getString("repeatCount");
const char* repeat = pClip->getString(ANIMATION_REPEAT_COUNT_STR);
if (repeat)
{
if (strcmp(repeat, ANIMATION_INDEFINITE_STR) == 0)
Expand Down Expand Up @@ -453,6 +452,12 @@ Animation* Animation::clone(Channel* channel, AnimationTarget* target)
GP_ASSERT(animation->getRefCount() == 1);

// Clone the clips

if (_defaultClip)
{
animation->_defaultClip = _defaultClip->clone(animation);
}

if (_clips)
{
for (std::vector<AnimationClip*>::iterator it = _clips->begin(); it != _clips->end(); ++it)
Expand Down
3 changes: 3 additions & 0 deletions gameplay/src/Animation.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
#include "Properties.h"
#include "Curve.h"

#define ANIMATION_INDEFINITE_STR "INDEFINITE"
#define ANIMATION_REPEAT_COUNT_STR "repeatCount"

namespace gameplay
{

Expand Down
1 change: 0 additions & 1 deletion gameplay/src/AnimationClip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,6 @@ AnimationClip* AnimationClip::clone(Animation* animation) const
{
// Don't clone the elapsed time, listeners or crossfade information.
AnimationClip* newClip = new AnimationClip(getId(), animation, getStartTime(), getEndTime());
newClip->setRepeatCount(getRepeatCount());
newClip->setSpeed(getSpeed());
newClip->setRepeatCount(getRepeatCount());
newClip->setBlendWeight(getBlendWeight());
Expand Down
17 changes: 16 additions & 1 deletion gameplay/src/AnimationTarget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,21 @@ Animation* AnimationTarget::createAnimation(const char* id, Properties* animatio
animation = createAnimation(id, propertyId, keyCount, keyTimes, keyValues, (Curve::InterpolationType) curve);
}

const char* repeat = animationProperties->getString(ANIMATION_REPEAT_COUNT_STR);
if (repeat)
{
if (strcmp(repeat, ANIMATION_INDEFINITE_STR) == 0)
{
animation->getClip()->setRepeatCount(AnimationClip::REPEAT_INDEFINITE);
}
else
{
float value;
sscanf(repeat, "%f", &value);
animation->getClip()->setRepeatCount(value);
}
}

SAFE_DELETE_ARRAY(keyOut);
SAFE_DELETE_ARRAY(keyIn);
SAFE_DELETE_ARRAY(keyValues);
Expand All @@ -277,7 +292,7 @@ Animation* AnimationTarget::createAnimation(const char* id, Properties* animatio
}
animation->createClips(animationProperties, (unsigned int) frameCount);
}

return animation;
}

Expand Down

0 comments on commit 46244a2

Please sign in to comment.