[Tizen] (Scene3D) Optimize AnimatedProperty's KeyFrame values after load complete 62/306262/1
authorEunki, Hong <eunkiki.hong@samsung.com>
Wed, 17 Jan 2024 02:54:38 +0000 (11:54 +0900)
committerEunki, Hong <eunkiki.hong@samsung.com>
Mon, 19 Feb 2024 08:18:26 +0000 (17:18 +0900)
Let we reduce the total key frame of MotionValue what we parse.

Since both json and bvh store the data by framerate.
So, there might be useless values are included.

If the number of keyframe is large, it might give some overhead to core.
So let we reduce useless keyframe for MotionValue and Model's internal animation.

Change-Id: I04b86b0341125cef1f60d3da68150c9367655169
Signed-off-by: Eunki, Hong <eunkiki.hong@samsung.com>
automated-tests/src/dali-scene3d/utc-Dali-MotionValue.cpp
dali-scene3d/internal/model-motion/motion-value-impl.cpp
dali-scene3d/public-api/loader/bvh-loader.cpp
dali-scene3d/public-api/loader/facial-animation-loader.cpp

index 1ac425581a0292a65f2bd162d2f16b7962223ef9..79b6feab34caeba56afa4ed267fcc0b2f56fa646 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2024 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -192,7 +192,7 @@ int UtcDaliMotionValueGetSetValue(void)
   DALI_TEST_CHECK(motionValue.GetValueType() == MotionValue::ValueType::INVALID);
   DALI_TEST_CHECK(motionValue.GetPropertyValue().GetType() == Property::Type::NONE);
   DALI_TEST_CHECK(!motionValue.GetKeyFrames());
-  
+
   motionValue.SetValue(expectKeyFrames);
   DALI_TEST_CHECK(motionValue.GetValueType() == MotionValue::ValueType::KEY_FRAMES);
   DALI_TEST_CHECK(motionValue.GetKeyFrames() == expectKeyFrames);
index d8189d15ec1c548d6e70a0561e771cf406559079..62d0580d9e44d874cf3f7ac52b698c739e18b1ca 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2024 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
index b4faf1ad025ce24f64889d269a13131ae50b2049..d9bc6f2d8df0bd16b1635ccb8c5885e8b1b10888 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2024 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -20,6 +20,7 @@
 
 // EXTERNAL INCLUDES
 #include <dali/devel-api/adaptor-framework/file-stream.h>
+#include <dali/devel-api/animation/key-frames-devel.h>
 #include <dali/integration-api/debug.h>
 
 #include <fstream>
@@ -373,7 +374,7 @@ AnimationDefinition GenerateAnimation(const std::string& animationName, std::sha
   if(!jointList.empty())
   {
     uint32_t animationSize = jointList.size();
-    animationSize = (useRootTranslationOnly) ? (animationSize + 1u) : (animationSize * 2u);
+    animationSize          = (useRootTranslationOnly) ? (animationSize + 1u) : (animationSize * 2u);
     animationDefinition.ReserveSize(animationSize);
     uint32_t animationIndex = 0u;
     for(uint32_t i = 0; i < jointList.size(); ++i)
@@ -403,8 +404,12 @@ AnimationDefinition GenerateAnimation(const std::string& animationName, std::sha
       }
       if(!useRootTranslationOnly || i == 0)
       {
+        // Optimize keyframes, for heuristic!
+        DevelKeyFrames::OptimizeKeyFramesLinear(translationProperty.mKeyFrames);
         animationDefinition.SetProperty(animationIndex++, std::move(translationProperty));
       }
+      // Optimize keyframes, for heuristic!
+      DevelKeyFrames::OptimizeKeyFramesLinear(rotationProperty.mKeyFrames);
       animationDefinition.SetProperty(animationIndex++, std::move(rotationProperty));
     }
   }
index 36eff865940de40241a9cac9033c8da8732696b0..4f1d5e1dc4865a152bfa53dc0be097798544a70c 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright (c) 2023 Samsung Electronics Co., Ltd.\r
+ * Copyright (c) 2024 Samsung Electronics Co., Ltd.\r
  *\r
  * Licensed under the Apache License, Version 2.0 (the "License");\r
  * you may not use this file except in compliance with the License.\r
@@ -19,6 +19,7 @@
 #include <dali-scene3d/public-api/loader/facial-animation-loader.h>\r
 \r
 // EXTERNAL INCLUDES\r
+#include <dali/devel-api/animation/key-frames-devel.h>\r
 #include <sstream>\r
 \r
 // INTERNAL INCLUDES\r
@@ -140,6 +141,8 @@ Dali::Scene3D::Loader::AnimationDefinition LoadFacialAnimationInternal(json::uni
         const float progress = MILLISECONDS_TO_SECONDS * static_cast<float>(facialAnimation.mTime[timeIndex]) / animationDefinition.GetDuration();\r
         animatedProperty.mKeyFrames.Add(progress, blendShape.mKeys[timeIndex][morphTargetIndex]);\r
       }\r
+      // Optimize keyframes, for heuristic!\r
+      DevelKeyFrames::OptimizeKeyFramesLinear(animatedProperty.mKeyFrames);\r
       animationDefinition.SetProperty(targets + morphTargetIndex, std::move(animatedProperty));\r
     }\r
 \r