From: seungho baek Date: Mon, 28 Aug 2023 06:47:49 +0000 (+0900) Subject: Extract condition function to check the animation has initial value or not X-Git-Tag: dali_2.2.42~6 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F94%2F297894%2F1;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git 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 --- 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]); }