|
|
@@ -84,7 +84,7 @@ unsigned long AnimationClip::getEndTime() const
|
|
|
return _endTime;
|
|
|
}
|
|
|
|
|
|
-unsigned long AnimationClip::getElaspedTime() const
|
|
|
+float AnimationClip::getElaspedTime() const
|
|
|
{
|
|
|
return _elapsedTime;
|
|
|
}
|
|
|
@@ -120,7 +120,7 @@ void AnimationClip::setActiveDuration(unsigned long duration)
|
|
|
else
|
|
|
{
|
|
|
_activeDuration = _duration;
|
|
|
- _repeatCount = (float) _activeDuration / (float) _duration;
|
|
|
+ _repeatCount = (float)_activeDuration / (float)_duration;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -242,7 +242,7 @@ void AnimationClip::crossFade(AnimationClip* clip, unsigned long duration)
|
|
|
// Set and intiliaze this clip to fade out
|
|
|
setClipStateBit(CLIP_IS_FADING_OUT_STARTED_BIT);
|
|
|
setClipStateBit(CLIP_IS_FADING_OUT_BIT);
|
|
|
- _crossFadeOutElapsed = 0L;
|
|
|
+ _crossFadeOutElapsed = 0.0f;
|
|
|
_crossFadeOutDuration = duration;
|
|
|
|
|
|
// If this clip is currently not playing, we should start playing it.
|
|
|
@@ -282,7 +282,7 @@ void AnimationClip::addListener(AnimationClip::Listener* listener, unsigned long
|
|
|
// otherwise, it will just be set the next time the clip gets played.
|
|
|
if (isClipStateBitSet(CLIP_IS_PLAYING_BIT))
|
|
|
{
|
|
|
- unsigned long currentTime = _elapsedTime % _duration;
|
|
|
+ float currentTime = fmodf(_elapsedTime, (float)_duration);
|
|
|
GP_ASSERT(**_listenerItr || *_listenerItr == _listeners->end());
|
|
|
if ((_speed >= 0.0f && currentTime < eventTime && (*_listenerItr == _listeners->end() || eventTime < (**_listenerItr)->_eventTime)) ||
|
|
|
(_speed <= 0 && currentTime > eventTime && (*_listenerItr == _listeners->begin() || eventTime > (**_listenerItr)->_eventTime)))
|
|
|
@@ -313,7 +313,7 @@ void AnimationClip::addEndListener(AnimationClip::Listener* listener)
|
|
|
_endListeners->push_back(listener);
|
|
|
}
|
|
|
|
|
|
-bool AnimationClip::update(unsigned long elapsedTime)
|
|
|
+bool AnimationClip::update(float elapsedTime)
|
|
|
{
|
|
|
if (isClipStateBitSet(CLIP_IS_PAUSED_BIT))
|
|
|
{
|
|
|
@@ -338,9 +338,9 @@ bool AnimationClip::update(unsigned long elapsedTime)
|
|
|
_elapsedTime = _activeDuration + _elapsedTime;
|
|
|
}
|
|
|
|
|
|
- unsigned long currentTime = 0L;
|
|
|
+ float currentTime = 0.0f;
|
|
|
// Check to see if clip is complete.
|
|
|
- if (_repeatCount != REPEAT_INDEFINITE && ((_speed >= 0.0f && _elapsedTime >= (long) _activeDuration) || (_speed <= 0.0f && _elapsedTime <= 0L)))
|
|
|
+ if (_repeatCount != REPEAT_INDEFINITE && ((_speed >= 0.0f && _elapsedTime >= _activeDuration) || (_speed <= 0.0f && _elapsedTime <= 0.0f)))
|
|
|
{
|
|
|
resetClipStateBit(CLIP_IS_STARTED_BIT);
|
|
|
|
|
|
@@ -349,27 +349,27 @@ bool AnimationClip::update(unsigned long elapsedTime)
|
|
|
// If _duration == 0, we have a "pose". Just set currentTime to 0.
|
|
|
if (_duration == 0)
|
|
|
{
|
|
|
- currentTime = 0L;
|
|
|
+ currentTime = 0.0f;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- currentTime = _activeDuration % _duration; // Get's the fractional part of the final repeat.
|
|
|
- if (currentTime == 0L)
|
|
|
+ currentTime = (float)(_activeDuration % _duration); // Get's the fractional part of the final repeat.
|
|
|
+ if (currentTime == 0.0f)
|
|
|
currentTime = _duration;
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- currentTime = 0L; // If we are negative speed, the end value should be 0.
|
|
|
+ currentTime = 0.0f; // If we are negative speed, the end value should be 0.
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
// If _duration == 0, we have a "pose". Just set currentTime to 0.
|
|
|
if (_duration == 0)
|
|
|
- currentTime = 0L;
|
|
|
+ currentTime = 0.0f;
|
|
|
else // Gets portion/fraction of the repeat.
|
|
|
- currentTime = _elapsedTime % _duration;
|
|
|
+ currentTime = fmodf(_elapsedTime, _duration);
|
|
|
}
|
|
|
|
|
|
// Notify any listeners of Animation events.
|
|
|
@@ -406,7 +406,7 @@ bool AnimationClip::update(unsigned long elapsedTime)
|
|
|
// Add back in start time, and divide by the total animation's duration to get the actual percentage complete
|
|
|
GP_ASSERT(_animation);
|
|
|
GP_ASSERT(_animation->_duration > 0);
|
|
|
- float percentComplete = (float)(_startTime + currentTime) / (float) _animation->_duration;
|
|
|
+ float percentComplete = ((float)_startTime + currentTime) / (float)_animation->_duration;
|
|
|
|
|
|
if (isClipStateBitSet(CLIP_IS_FADING_OUT_BIT))
|
|
|
{
|
|
|
@@ -428,7 +428,7 @@ bool AnimationClip::update(unsigned long elapsedTime)
|
|
|
if (_crossFadeOutElapsed < _crossFadeOutDuration)
|
|
|
{
|
|
|
// Calculate this clip's blend weight.
|
|
|
- float tempBlendWeight = (float) (_crossFadeOutDuration - _crossFadeOutElapsed) / (float) _crossFadeOutDuration;
|
|
|
+ float tempBlendWeight = ((float)_crossFadeOutDuration - _crossFadeOutElapsed) / (float)_crossFadeOutDuration;
|
|
|
|
|
|
// If this clip is fading in, adjust the crossfade clip's weight to be a percentage of your current blend weight
|
|
|
if (isClipStateBitSet(CLIP_IS_FADING_IN_BIT))
|