rlottie: Fix a issue when shape animation data are not same size
authorSubhransu Mohanty <sub.mohanty@samsung.com>
Wed, 19 Jun 2019 09:02:17 +0000 (18:02 +0900)
committerHermet Park <hermetpark@gmail.com>
Tue, 25 Jun 2019 11:58:30 +0000 (20:58 +0900)
src/lottie/lottiemodel.h

index ac2b4076492640ce4686879b94d0208afc5a2fbc..6e7131fb6b49a1c5434f92f9a88eeac3d653b730 100644 (file)
@@ -138,12 +138,12 @@ inline T lerp(const T& start, const T& end, float t)
 
 inline LottieShapeData lerp(const LottieShapeData& start, const LottieShapeData& end, float t)
 {
-    if (start.mPoints.size() != end.mPoints.size())
-       return LottieShapeData();
-
+    // Usal case both start and end path has same size
+    // In case its different then truncate the larger path and do the interpolation.
     LottieShapeData result;
-    result.reserve(start.mPoints.size());
-    for (unsigned int i = 0 ; i < start.mPoints.size(); i++) {
+    auto size = std::min(start.mPoints.size(), end.mPoints.size());
+    result.reserve(size);
+    for (unsigned int i = 0 ; i < size; i++) {
        result.mPoints.push_back(start.mPoints[i] + t * (end.mPoints[i] - start.mPoints[i]));
     }
    return result;