(Animation) Fix for issue in keyframed animation when only 1 key frame present
authorJulien Heanley <j.heanley@partner.samsung.com>
Mon, 24 Mar 2014 14:11:11 +0000 (14:11 +0000)
committerPaul Wisbey <p.wisbey@samsung.com>
Thu, 3 Apr 2014 15:56:46 +0000 (16:56 +0100)
[Issue#]   N/A
[Problem]  Keyframe was not affecting property value
[Cause]    key frames only affect property if current progress is between first and last key frame (if only 1 key frame then it uses same time for first and last)
[Solution] if progress is greater than last key frame time then set property to last key frame

Signed-off-by: Paul Wisbey <p.wisbey@samsung.com>
dali/internal/event/animation/key-frame-channel.h

index 8f40e9b..4713435 100644 (file)
@@ -90,9 +90,8 @@ bool KeyFrameChannel<V>::IsActive (float progress)
   if(!mValues.empty())
   {
     ProgressValue<V>& first = mValues.front();
-    ProgressValue<V>& last  = mValues.back();
 
-    if (progress >= first.GetProgress() && progress <= last.GetProgress() )
+    if( progress >= first.GetProgress() )
     {
       active = true;
     }
@@ -146,21 +145,17 @@ V KeyFrameChannel<V>::GetValue (float progress) const
   typename std::vector<ProgressValue<V> >::iterator start;
   typename std::vector<ProgressValue<V> >::iterator end;
 
-  V interpolatedV;
-  if(FindInterval(start, end, progress))
+  V interpolatedV = firstPV.GetValue();
+  if(progress >= mValues.back().GetProgress() )
+  {
+    interpolatedV = mValues.back().GetValue(); // This should probably be last value...
+  }
+  else if(FindInterval(start, end, progress))
   {
     float frameProgress = (progress - start->GetProgress()) / (end->GetProgress() - start->GetProgress());
 
     interpolatedV = Interpolate(*start, *end, frameProgress);
   }
-  else if(progress <= firstPV.GetProgress())
-  {
-    interpolatedV = firstPV.GetValue(); // This should probably be initial value...
-  }
-  else
-  {
-    interpolatedV = mValues.back().GetValue(); // Sticks at end value
-  }
 
   return interpolatedV;
 }