const Vector2 playRange( mPlayRange * mDurationSeconds );
float elapsedSecondsClamped = Clamp( mElapsedSeconds, playRange.x, playRange.y );
+ //Remove animators whose PropertyOwner has been destroyed
+ mAnimators.Erase(std::remove_if(mAnimators.begin(),
+ mAnimators.end(),
+ [](auto animator) { return animator->Orphan(); }),
+ mAnimators.end());
+
//Loop through all animators
- bool applied(true);
- for ( auto&& iter = mAnimators.Begin(); iter != mAnimators.End(); )
+ for(auto& animator : mAnimators)
{
- AnimatorBase *animator = *iter;
-
- if( animator->Orphan() )
- {
- //Remove animators whose PropertyOwner has been destroyed
- iter = mAnimators.Erase(iter);
- }
- else
+ bool applied(true);
+ if(animator->IsEnabled())
{
- if( animator->IsEnabled() )
- {
- const float intervalDelay( animator->GetIntervalDelay() );
+ const float intervalDelay(animator->GetIntervalDelay());
- if( elapsedSecondsClamped >= intervalDelay )
+ if(elapsedSecondsClamped >= intervalDelay)
+ {
+ // Calculate a progress specific to each individual animator
+ float progress(1.0f);
+ const float animatorDuration = animator->GetDuration();
+ if(animatorDuration > 0.0f) // animators can be "immediate"
{
- // Calculate a progress specific to each individual animator
- float progress(1.0f);
- const float animatorDuration = animator->GetDuration();
- if (animatorDuration > 0.0f) // animators can be "immediate"
- {
- progress = Clamp((elapsedSecondsClamped - intervalDelay) / animatorDuration, 0.0f , 1.0f );
- }
- animator->Update(bufferIndex, progress, bake);
-
- if (animatorDuration > 0.0f && (elapsedSecondsClamped - intervalDelay) <= animatorDuration)
- {
- mIsActive[bufferIndex] = true;
- }
+ progress = Clamp((elapsedSecondsClamped - intervalDelay) / animatorDuration, 0.0f, 1.0f);
}
- applied = true;
- }
- else
- {
- applied = false;
- }
+ animator->Update(bufferIndex, progress, bake);
- if ( animationFinished )
- {
- animator->SetActive( false );
+ if (animatorDuration > 0.0f && (elapsedSecondsClamped - intervalDelay) <= animatorDuration)
+ {
+ mIsActive[bufferIndex] = true;
+ }
}
+ applied = true;
+ }
+ else
+ {
+ applied = false;
+ }
- if (applied)
- {
- INCREASE_COUNTER(PerformanceMonitor::ANIMATORS_APPLIED);
- }
+ if(animationFinished)
+ {
+ animator->SetActive(false);
+ }
- ++iter;
+ if(applied)
+ {
+ INCREASE_COUNTER(PerformanceMonitor::ANIMATORS_APPLIED);
}
}
-
}
} // namespace SceneGraph