From b244e1796700d6b2858968804a960f122b78de27 Mon Sep 17 00:00:00 2001 From: seungho baek Date: Mon, 28 Aug 2023 15:47:49 +0900 Subject: [PATCH] Extract condition function to check the animation has initial value or not - Currently, gltf2-util.cpp uses long condition with comment to check the animation data contains initial value or not. - The comment has been essential to understand the purpose of the condition. - This patch extracts condition function to check it and uses proper naming instead of comment. Change-Id: Ib2808343215b8ac6fe400911f6a50511da6cd8fb Signed-off-by: seungho baek --- dali-scene3d/internal/loader/gltf2-util.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/dali-scene3d/internal/loader/gltf2-util.cpp b/dali-scene3d/internal/loader/gltf2-util.cpp index 4f426b1..ef3f0ce 100644 --- a/dali-scene3d/internal/loader/gltf2-util.cpp +++ b/dali-scene3d/internal/loader/gltf2-util.cpp @@ -1116,6 +1116,11 @@ float LoadDataFromAccessors(ConversionContext& context, const gltf2::Accessor& i return inputDataBuffer[input.mCount - 1u]; } +bool IsFirstFrameValueEmpty(const uint32_t inputCount, const Vector& inputBuffer) +{ + return (inputCount > 0 && !Dali::EqualsZero(inputBuffer[0])); +} + template float LoadKeyFrames(ConversionContext& context, const gltf2::Animation::Channel& channel, KeyFrames& keyFrames, gltf2::Animation::Channel::Target::Type type) { @@ -1127,8 +1132,7 @@ float LoadKeyFrames(ConversionContext& context, const gltf2::Animation::Channel& const float duration = std::max(LoadDataFromAccessors(context, input, output, inputDataBuffer, outputDataBuffer), AnimationDefinition::MIN_DURATION_SECONDS); - // Set first frame value as first keyframe (gltf animation spec) - if(input.mCount > 0 && !Dali::EqualsZero(inputDataBuffer[0])) + if(IsFirstFrameValueEmpty(input.mCount, inputDataBuffer)) { keyFrames.Add(0.0f, outputDataBuffer[0]); } @@ -1165,8 +1169,7 @@ float LoadBlendShapeKeyFrames(ConversionContext& context, const gltf2::Animation animatedProperty.mKeyFrames = KeyFrames::New(); - // Set first frame value as first keyframe (gltf animation spec) - if(input.mCount > 0 && !Dali::EqualsZero(inputDataBuffer[0])) + if(IsFirstFrameValueEmpty(input.mCount, inputDataBuffer)) { animatedProperty.mKeyFrames.Add(0.0f, outputDataBuffer[weightIndex]); } -- 2.7.4