[Tizen] Fix logical error for dli animation duration 95/296895/4
authorEunki Hong <eunkiki.hong@samsung.com>
Fri, 9 Jun 2023 15:58:14 +0000 (00:58 +0900)
committerseungho baek <sbsh.baek@samsung.com>
Wed, 23 Aug 2023 04:50:39 +0000 (13:50 +0900)
There was some code mistakes for dli loader parsing of animation duration.

Change-Id: I877cb44369a5f72b2a1064c7b8ea816bdbe806f1
Signed-off-by: Eunki Hong <eunkiki.hong@samsung.com>
automated-tests/src/dali-scene3d-internal/utc-Dali-DliLoaderImpl.cpp
dali-scene3d/internal/loader/dli-loader-impl.cpp

index d2f0406..ef2013b 100644 (file)
@@ -321,6 +321,7 @@ int UtcDaliDliLoaderLoadSceneMorph(void)
   DALI_TEST_EQUAL(ctx.cameraParameters.size(), 1u);
   DALI_TEST_EQUAL(ctx.lights.size(), 1u);
   DALI_TEST_EQUAL(ctx.animations.size(), 1u);
+  DALI_TEST_EQUAL(ctx.animations[0].GetDuration(), 1.0f);
   DALI_TEST_EQUAL(ctx.animGroups.size(), 0u);
 
   DALI_TEST_EQUAL(metadata.size(), 4u);
index d684548..8197904 100644 (file)
@@ -1456,16 +1456,18 @@ void DliLoaderImpl::Impl::ParseAnimations(const TreeNode* tnAnimations, LoadPara
     // be expressed as a multiple of; 0 won't work. This is small enough (i.e. shorter
     // than our frame delay) to not be restrictive WRT replaying. If anything needs
     // to occur more frequently, then Animations are likely not your solution anyway.
-    animDef.SetDuration(AnimationDefinition::MIN_DURATION_SECONDS);
-    float animationDuration;
+    float animationDuration = 0.0f;
     if(!ReadFloat(tnAnim.GetChild("duration"), animationDuration))
     {
-      animDef.SetDuration(animationDuration);
-      mOnError(FormatString("Animation '%s' fails to define '%s', defaulting to %f.",
+      mOnError(FormatString("Animation '%s' fails to define '%s'.",
                             animDef.GetName().c_str(),
-                            "duration",
-                            animDef.GetDuration()));
+                            "duration"));
     }
+    if(animationDuration < AnimationDefinition::MIN_DURATION_SECONDS)
+    {
+      animationDuration = AnimationDefinition::MIN_DURATION_SECONDS;
+    }
+    animDef.SetDuration(animationDuration);
 
     // Get loop count - # of playbacks. Default is once. 0 means repeat indefinitely.
     int32_t animationLoopCount = 1;