Extract condition function to check the animation has initial value or not 94/297894/1
authorseungho baek <sbsh.baek@samsung.com>
Mon, 28 Aug 2023 06:47:49 +0000 (15:47 +0900)
committerseungho baek <sbsh.baek@samsung.com>
Mon, 28 Aug 2023 06:47:49 +0000 (15:47 +0900)
 - 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 <sbsh.baek@samsung.com>
dali-scene3d/internal/loader/gltf2-util.cpp

index 4f426b1..ef3f0ce 100644 (file)
@@ -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<float>& inputBuffer)
+{
+  return (inputCount > 0 && !Dali::EqualsZero(inputBuffer[0]));
+}
+
 template<typename T>
 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<T>(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]);
     }