From 719dc93a10b5878571263d304212f701e12641a6 Mon Sep 17 00:00:00 2001 From: "Eunki, Hong" Date: Wed, 17 Jan 2024 11:54:38 +0900 Subject: [PATCH] (Scene3D) Optimize AnimatedProperty's KeyFrame values after load complete 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 --- automated-tests/src/dali-scene3d/utc-Dali-MotionValue.cpp | 4 ++-- dali-scene3d/internal/model-motion/motion-value-impl.cpp | 2 +- dali-scene3d/public-api/loader/bvh-loader.cpp | 9 +++++++-- dali-scene3d/public-api/loader/facial-animation-loader.cpp | 5 ++++- 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/automated-tests/src/dali-scene3d/utc-Dali-MotionValue.cpp b/automated-tests/src/dali-scene3d/utc-Dali-MotionValue.cpp index 1ac4255..79b6fea 100644 --- a/automated-tests/src/dali-scene3d/utc-Dali-MotionValue.cpp +++ b/automated-tests/src/dali-scene3d/utc-Dali-MotionValue.cpp @@ -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); diff --git a/dali-scene3d/internal/model-motion/motion-value-impl.cpp b/dali-scene3d/internal/model-motion/motion-value-impl.cpp index d8189d1..62d0580 100644 --- a/dali-scene3d/internal/model-motion/motion-value-impl.cpp +++ b/dali-scene3d/internal/model-motion/motion-value-impl.cpp @@ -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. diff --git a/dali-scene3d/public-api/loader/bvh-loader.cpp b/dali-scene3d/public-api/loader/bvh-loader.cpp index b4faf1a..d9bc6f2 100644 --- a/dali-scene3d/public-api/loader/bvh-loader.cpp +++ b/dali-scene3d/public-api/loader/bvh-loader.cpp @@ -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 +#include #include #include @@ -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)); } } diff --git a/dali-scene3d/public-api/loader/facial-animation-loader.cpp b/dali-scene3d/public-api/loader/facial-animation-loader.cpp index 36eff86..4f1d5e1 100644 --- a/dali-scene3d/public-api/loader/facial-animation-loader.cpp +++ b/dali-scene3d/public-api/loader/facial-animation-loader.cpp @@ -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. @@ -19,6 +19,7 @@ #include // EXTERNAL INCLUDES +#include #include // INTERNAL INCLUDES @@ -140,6 +141,8 @@ Dali::Scene3D::Loader::AnimationDefinition LoadFacialAnimationInternal(json::uni const float progress = MILLISECONDS_TO_SECONDS * static_cast(facialAnimation.mTime[timeIndex]) / animationDefinition.GetDuration(); animatedProperty.mKeyFrames.Add(progress, blendShape.mKeys[timeIndex][morphTargetIndex]); } + // Optimize keyframes, for heuristic! + DevelKeyFrames::OptimizeKeyFramesLinear(animatedProperty.mKeyFrames); animationDefinition.SetProperty(targets + morphTargetIndex, std::move(animatedProperty)); } -- 2.7.4