예제 #1
0
void Animation::UpdateAnimators( BufferIndex bufferIndex, bool bake, bool animationFinished )
{
  float elapsedSecondsClamped = Clamp( mElapsedSeconds, mPlayRange.x * mDurationSeconds,mPlayRange.y * mDurationSeconds );

  //Loop through all animators
  bool applied(true);
  for ( AnimatorIter iter = mAnimators.Begin(); iter != mAnimators.End(); )
  {
    AnimatorBase *animator = *iter;

    if( animator->Orphan() )
    {
      //Remove animators whose PropertyOwner has been destroyed
      iter = mAnimators.Erase(iter);
    }
    else
    {
      if( animator->IsEnabled() )
      {
        const float initialDelay(animator->GetInitialDelay());
        if (elapsedSecondsClamped >= initialDelay || mSpeedFactor < 0.0f )
        {
          // 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 - initialDelay) / animatorDuration, 0.0f , 1.0f );
          }
          animator->Update(bufferIndex, progress, bake);
        }
        applied = true;
      }
      else
      {
        applied = false;
      }

      if ( animationFinished )
      {
        animator->SetActive( false );
      }

      if (applied)
      {
        INCREASE_COUNTER(PerformanceMonitor::ANIMATORS_APPLIED);
      }

      ++iter;
    }
  }

}
예제 #2
0
void Animation::UpdateAnimators(BufferIndex bufferIndex, bool bake)
{
  for ( AnimatorIter iter = mAnimators.Begin(); iter != mAnimators.End(); )
  {
    // If an animator is not successfully applied, then it has been orphaned
    bool applied(true);

    AnimatorBase *animator = *iter;
    const float initialDelay(animator->GetInitialDelay());

    if (mElapsedSeconds >= initialDelay)
    {
      // 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 = min(1.0f, (mElapsedSeconds - initialDelay) / animatorDuration);
      }

      applied = animator->Update(bufferIndex, progress, bake);
    }

    // Animators are automatically removed, when orphaned from animatable scene objects.
    if (!applied)
    {
      iter = mAnimators.Erase(iter);
    }
    else
    {
      ++iter;

      INCREASE_COUNTER(PerformanceMonitor::ANIMATORS_APPLIED);
    }
  }
}