Merge changes I776588c1,I7292a2fb into devel/master
[platform/core/uifw/dali-toolkit.git] / dali-scene3d / internal / loader / dli-loader-impl.cpp
index 2285940..668a10c 100644 (file)
@@ -667,6 +667,12 @@ 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.
@@ -1027,14 +1033,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))
     {
@@ -1439,51 +1448,58 @@ void DliLoaderImpl::Impl::ParseAnimations(const TreeNode* tnAnimations, LoadPara
       ++iAnim)
   {
     const TreeNode&     tnAnim = (*iAnim).second;
+    uint32_t animationPropertyIndex = 0;
     AnimationDefinition animDef;
-    ReadString(tnAnim.GetChild(NAME), animDef.mName);
+    std::string animationName;
+    ReadString(tnAnim.GetChild(NAME), animationName);
+    animDef.SetName(animationName);
 
-    auto       iFind     = std::lower_bound(definitions.begin(), definitions.end(), animDef, [](const AnimationDefinition& ad0, const AnimationDefinition& ad1) { return ad0.mName < ad1.mName; });
-    const bool overwrite = iFind != definitions.end() && iFind->mName == animDef.mName;
+    auto       iFind     = std::lower_bound(definitions.begin(), definitions.end(), animDef, [](const AnimationDefinition& ad0, const AnimationDefinition& ad1) { return ad0.GetName() < ad1.GetName(); });
+    const bool overwrite = iFind != definitions.end() && iFind->GetName() == animDef.GetName();
     if(overwrite)
     {
-      mOnError(FormatString("Pre-existing animation with name '%s' is being overwritten.", animDef.mName.c_str()));
+      mOnError(FormatString("Pre-existing animation with name '%s' is being overwritten.", animDef.GetName().c_str()));
     }
 
     // Duration -- We need something that animated properties' delay / duration can
     // 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.mDuration = AnimationDefinition::MIN_DURATION_SECONDS;
-    if(!ReadFloat(tnAnim.GetChild("duration"), animDef.mDuration))
+    float animationDuration = 0.0f;
+    if(!ReadFloat(tnAnim.GetChild("duration"), animationDuration))
+    {
+      mOnError(FormatString("Animation '%s' fails to define '%s'.",
+                            animDef.GetName().c_str(),
+                            "duration"));
+    }
+    if(animationDuration < AnimationDefinition::MIN_DURATION_SECONDS)
     {
-      mOnError(FormatString("Animation '%s' fails to define '%s', defaulting to %f.",
-                            animDef.mName.c_str(),
-                            "duration",
-                            animDef.mDuration));
+      animationDuration = AnimationDefinition::MIN_DURATION_SECONDS;
     }
+    animDef.SetDuration(animationDuration);
 
     // Get loop count - # of playbacks. Default is once. 0 means repeat indefinitely.
-    animDef.mLoopCount = 1;
-    if(ReadInt(tnAnim.GetChild("loopCount"), animDef.mLoopCount) &&
-       animDef.mLoopCount < 0)
+    int32_t animationLoopCount = 1;
+    if(ReadInt(tnAnim.GetChild("loopCount"), animationLoopCount) && animationLoopCount < 0)
     {
-      animDef.mLoopCount = 0;
+      animationLoopCount = 0;
     }
+    animDef.SetLoopCount(animationLoopCount);
 
     std::string endAction;
     if(ReadString(tnAnim.GetChild("endAction"), endAction))
     {
       if("BAKE" == endAction)
       {
-        animDef.mEndAction = Animation::BAKE;
+        animDef.SetEndAction(Animation::BAKE);
       }
       else if("DISCARD" == endAction)
       {
-        animDef.mEndAction = Animation::DISCARD;
+        animDef.SetEndAction(Animation::DISCARD);
       }
       else if("BAKE_FINAL" == endAction)
       {
-        animDef.mEndAction = Animation::BAKE_FINAL;
+        animDef.SetEndAction(Animation::BAKE_FINAL);
       }
     }
 
@@ -1491,21 +1507,21 @@ void DliLoaderImpl::Impl::ParseAnimations(const TreeNode* tnAnimations, LoadPara
     {
       if("BAKE" == endAction)
       {
-        animDef.mDisconnectAction = Animation::BAKE;
+        animDef.SetDisconnectAction(Animation::BAKE);
       }
       else if("DISCARD" == endAction)
       {
-        animDef.mDisconnectAction = Animation::DISCARD;
+        animDef.SetDisconnectAction(Animation::DISCARD);
       }
       else if("BAKE_FINAL" == endAction)
       {
-        animDef.mDisconnectAction = Animation::BAKE_FINAL;
+        animDef.SetDisconnectAction(Animation::BAKE_FINAL);
       }
     }
 
     if(const TreeNode* tnProperties = tnAnim.GetChild("properties"))
     {
-      animDef.mProperties.reserve(tnProperties->Size());
+      animDef.ReserveSize(tnProperties->Size());
       for(TreeNode::ConstIterator iProperty = tnProperties->CBegin(), iPropertyEnd = tnProperties->CEnd();
           iProperty != iPropertyEnd;
           ++iProperty)
@@ -1515,24 +1531,24 @@ void DliLoaderImpl::Impl::ParseAnimations(const TreeNode* tnAnimations, LoadPara
         AnimatedProperty animProp;
         if(!ReadString(tnProperty.GetChild("node"), animProp.mNodeName))
         {
-          mOnError(FormatString("Animation '%s': Failed to read the 'node' tag.", animDef.mName.c_str()));
+          mOnError(FormatString("Animation '%s': Failed to read the 'node' tag.", animDef.GetName().c_str()));
           continue;
         }
 
         if(!ReadString(tnProperty.GetChild("property"), animProp.mPropertyName))
         {
-          mOnError(FormatString("Animation '%s': Failed to read the 'property' tag", animDef.mName.c_str()));
+          mOnError(FormatString("Animation '%s': Failed to read the 'property' tag", animDef.GetName().c_str()));
           continue;
         }
 
         // these are the defaults
         animProp.mTimePeriod.delaySeconds    = 0.f;
-        animProp.mTimePeriod.durationSeconds = animDef.mDuration;
+        animProp.mTimePeriod.durationSeconds = animDef.GetDuration();
         if(!ReadTimePeriod(tnProperty.GetChild("timePeriod"), animProp.mTimePeriod))
         {
           mOnError(FormatString("Animation '%s': timePeriod missing in Property #%d: defaulting to %f.",
-                                animDef.mName.c_str(),
-                                animDef.mProperties.size(),
+                                animDef.GetName().c_str(),
+                                animDef.GetPropertyCount(),
                                 animProp.mTimePeriod.durationSeconds));
         }
 
@@ -1668,10 +1684,17 @@ void DliLoaderImpl::Impl::ParseAnimations(const TreeNode* tnAnimations, LoadPara
           }
         }
 
-        animDef.mProperties.push_back(std::move(animProp));
+        animDef.SetProperty(animationPropertyIndex++, std::move(animProp));
       }
     }
 
+    if(auto proc = params.input->mAnimationPropertyProcessor) // optional processing
+    {
+      Property::Map map;
+      ParseProperties(tnAnim, map);
+      proc(animDef, std::move(map), mOnError);
+    }
+
     if(overwrite)
     {
       *iFind = std::move(animDef);
@@ -1680,13 +1703,6 @@ void DliLoaderImpl::Impl::ParseAnimations(const TreeNode* tnAnimations, LoadPara
     {
       iFind = definitions.insert(iFind, std::move(animDef));
     }
-
-    if(auto proc = params.input->mAnimationPropertyProcessor) // optional processing
-    {
-      Property::Map map;
-      ParseProperties(tnAnim, map);
-      proc(animDef, std::move(map), mOnError);
-    }
   }
 }