[dali_2.3.24] Merge branch 'devel/master'
[platform/core/uifw/dali-toolkit.git] / dali-scene3d / internal / loader / dli-loader-impl.cpp
index f111856..6cdb1c4 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.
@@ -667,6 +667,11 @@ void DliLoaderImpl::Impl::ParseShaders(const TreeNode* shaders, Dali::Scene3D::L
     auto&            node = (*i0).second;
     ShaderDefinition shaderDef;
     ReadStringVector(node.GetChild("defines"), shaderDef.mDefines);
+    auto sssIter = std::find_if(shaderDef.mDefines.begin(), shaderDef.mDefines.end(), [](std::string& item) { return (item == "SSS"); });
+    if(sssIter != shaderDef.mDefines.end())
+    {
+      shaderDef.mDefines.erase(sssIter);
+    }
 
     // Read shader hints. Possible values are:
     //                         Don't define for No hints.
@@ -837,10 +842,13 @@ void DliLoaderImpl::Impl::ParseMeshes(const TreeNode* meshes, Dali::Scene3D::Loa
         mOnError(FormatString("mesh %d: Failed to read %s.", resources.mMeshes.size(), "normals"));
       }
 
-      if(MaskMatch(attributes, MeshDefinition::TEX_COORDS) &&
-         !ReadAttribAccessor(node.GetChild("textures"), meshDef.mTexCoords))
+      if(MaskMatch(attributes, MeshDefinition::TEX_COORDS))
       {
-        mOnError(FormatString("mesh %d: Failed to read %s.", resources.mMeshes.size(), "textures"));
+        meshDef.mTexCoords.emplace_back(MeshDefinition::Accessor{});
+        if(!ReadAttribAccessor(node.GetChild("textures"), meshDef.mTexCoords[0]))
+        {
+          mOnError(FormatString("mesh %d: Failed to read %s.", resources.mMeshes.size(), "textures"));
+        }
       }
 
       if(MaskMatch(attributes, MeshDefinition::TANGENTS) &&
@@ -858,11 +866,16 @@ void DliLoaderImpl::Impl::ParseMeshes(const TreeNode* meshes, Dali::Scene3D::Loa
           mOnError(FormatString("mesh %d: Expected joints0 / weights0 attribute(s) missing.",
                                 resources.mMeshes.size()));
         }
-        else if(!ReadAttribAccessor(node.GetChild("joints0"), meshDef.mJoints0) ||
-                !ReadAttribAccessor(node.GetChild("weights0"), meshDef.mWeights0))
+        else
         {
-          mOnError(FormatString("mesh %d: Failed to read skinning information.",
-                                resources.mMeshes.size()));
+          meshDef.mJoints.emplace_back(MeshDefinition::Accessor{});
+          meshDef.mWeights.emplace_back(MeshDefinition::Accessor{});
+          if(!ReadAttribAccessor(node.GetChild("joints0"), meshDef.mJoints[0]) ||
+             !ReadAttribAccessor(node.GetChild("weights0"), meshDef.mWeights[0]))
+          {
+            mOnError(FormatString("mesh %d: Failed to read skinning information.",
+                                  resources.mMeshes.size()));
+          }
         }
       }
 
@@ -1027,14 +1040,17 @@ void DliLoaderImpl::Impl::ParseMaterials(const TreeNode* materials, DliInputPara
       materialDef.mFlags |= semantic;
     }
 
-    if(ReadString(node.GetChild("subsurfaceMap"), texturePath))
-    {
-      ToUnixFileSeparators(texturePath);
-
-      const auto semantic = MaterialDefinition::SUBSURFACE;
-      materialDef.mTextureStages.push_back({semantic, TextureDefinition{std::move(texturePath)}});
-      materialDef.mFlags |= semantic;
-    }
+    /// @TODO : Some dli shader don't implement this subsurfaceMp usage.
+    ///         To make visual test pass, Skip subsurfaceMap texture using
+    ///         until dli shaders are support it.
+    //    if(ReadString(node.GetChild("subsurfaceMap"), texturePath))
+    //    {
+    //      ToUnixFileSeparators(texturePath);
+    //
+    //      const auto semantic = MaterialDefinition::SUBSURFACE;
+    //      materialDef.mTextureStages.push_back({semantic, TextureDefinition{std::move(texturePath)}});
+    //      materialDef.mFlags |= semantic;
+    //    }
 
     if(ReadString(node.GetChild("occlusionMap"), texturePath))
     {
@@ -1438,10 +1454,10 @@ void DliLoaderImpl::Impl::ParseAnimations(const TreeNode* tnAnimations, LoadPara
       iAnim != iAnimEnd;
       ++iAnim)
   {
-    const TreeNode&     tnAnim = (*iAnim).second;
-    uint32_t animationPropertyIndex = 0;
+    const TreeNode&     tnAnim                 = (*iAnim).second;
+    uint32_t            animationPropertyIndex = 0;
     AnimationDefinition animDef;
-    std::string animationName;
+    std::string         animationName;
     ReadString(tnAnim.GetChild(NAME), animationName);
     animDef.SetName(animationName);
 
@@ -1456,16 +1472,18 @@ void DliLoaderImpl::Impl::ParseAnimations(const TreeNode* tnAnimations, LoadPara
     // be expressed as a multiple of; 0 won't work. This is small enough (i.e. shorter
     // than our frame delay) to not be restrictive WRT replaying. If anything needs
     // to occur more frequently, then Animations are likely not your solution anyway.
-    animDef.SetDuration(AnimationDefinition::MIN_DURATION_SECONDS);
-    float animationDuration;
+    float animationDuration = 0.0f;
     if(!ReadFloat(tnAnim.GetChild("duration"), animationDuration))
     {
-      animDef.SetDuration(animationDuration);
-      mOnError(FormatString("Animation '%s' fails to define '%s', defaulting to %f.",
+      mOnError(FormatString("Animation '%s' fails to define '%s'.",
                             animDef.GetName().c_str(),
-                            "duration",
-                            animDef.GetDuration()));
+                            "duration"));
+    }
+    if(animationDuration < AnimationDefinition::MIN_DURATION_SECONDS)
+    {
+      animationDuration = AnimationDefinition::MIN_DURATION_SECONDS;
     }
+    animDef.SetDuration(animationDuration);
 
     // Get loop count - # of playbacks. Default is once. 0 means repeat indefinitely.
     int32_t animationLoopCount = 1;
@@ -1567,7 +1585,7 @@ void DliLoaderImpl::Impl::ParseAnimations(const TreeNode* tnAnimations, LoadPara
           ReadInt(tnKeyFramesBin->GetChild("byteOffset"), byteOffset);
           DALI_ASSERT_ALWAYS(byteOffset >= 0);
 
-          binAniFile.seekg(byteOffset, std::ios::beg);
+          binAniFile.seekg(static_cast<std::streamoff>(byteOffset), std::ios::beg);
 
           int numKeys = 0;
           ReadInt(tnKeyFramesBin->GetChild("numKeys"), numKeys);