Make sure to register blendshape weight properties for all the nodes with blendshapes 02/277202/1
authorRichard Huang <r.huang@samsung.com>
Fri, 1 Jul 2022 13:03:09 +0000 (14:03 +0100)
committerRichard Huang <r.huang@samsung.com>
Fri, 1 Jul 2022 13:03:09 +0000 (14:03 +0100)
Change-Id: Ia78fe48a91ed98b5313bf90f14a2a98fe6d461ed

dali-scene-loader/public-api/blend-shape-details.cpp
dali-scene-loader/public-api/scene-definition.cpp

index 9e76924..8607b15 100644 (file)
@@ -52,7 +52,7 @@ void BlendShapes::ConfigureProperties(const std::pair<MeshDefinition, MeshGeomet
     std::string weightName{weightNameBuffer};
     actor.RegisterProperty(weightName, blendShape.weight);
 
-    if(mesh.first.mBlendShapeVersion == Version::VERSION_1_0)
+    if(shader && mesh.first.mBlendShapeVersion == Version::VERSION_1_0)
     {
       snprintf(pFactorName, sizeof(unnormalizeFactorNameBuffer) - (pFactorName - unnormalizeFactorNameBuffer), "[%d]", index);
       std::string factorName{unnormalizeFactorNameBuffer};
@@ -62,22 +62,25 @@ void BlendShapes::ConfigureProperties(const std::pair<MeshDefinition, MeshGeomet
     ++index;
   }
 
-  if(Version::VERSION_2_0 == mesh.first.mBlendShapeVersion)
+  if(shader)
   {
-    shader.RegisterProperty(UNNORMALIZE_FACTOR, mesh.second.blendShapeUnnormalizeFactor[0u]);
-  }
+    if(Version::VERSION_2_0 == mesh.first.mBlendShapeVersion)
+    {
+      shader.RegisterProperty(UNNORMALIZE_FACTOR, mesh.second.blendShapeUnnormalizeFactor[0u]);
+    }
 
-  shader.RegisterProperty(NUMBER_OF_BLEND_SHAPES, Property::Value(static_cast<int>(index)));
-  shader.RegisterProperty(COMPONENT_SIZE, Property::Value(static_cast<int>(mesh.second.blendShapeBufferOffset)));
+    shader.RegisterProperty(NUMBER_OF_BLEND_SHAPES, Property::Value(static_cast<int>(index)));
+    shader.RegisterProperty(COMPONENT_SIZE, Property::Value(static_cast<int>(mesh.second.blendShapeBufferOffset)));
 
-  // Create a read only property to preserve the components of the blend shape.
-  int32_t components = 0x0;
-  for(auto& bs : mesh.first.mBlendShapes)
-  {
-    components |= (bs.deltas.IsDefined() * Component::POSITIONS) |
-                  (bs.normals.IsDefined() * Component::NORMALS) | (bs.tangents.IsDefined() * Component::TANGENTS);
+    // Create a read only property to preserve the components of the blend shape.
+    int32_t components = 0x0;
+    for(auto& bs : mesh.first.mBlendShapes)
+    {
+      components |= (bs.deltas.IsDefined() * Component::POSITIONS) |
+                    (bs.normals.IsDefined() * Component::NORMALS) | (bs.tangents.IsDefined() * Component::TANGENTS);
+    }
+    shader.RegisterProperty(COMPONENTS, components, Property::AccessMode::READ_ONLY);
   }
-  shader.RegisterProperty(COMPONENTS, components, Property::AccessMode::READ_ONLY);
 }
 
 } // namespace SceneLoader
index 9da16fc..ff8bdfa 100644 (file)
@@ -1097,11 +1097,6 @@ bool SceneDefinition::ConfigureBlendshapeShaders(const ResourceBundle&
     ++i;
   } while(true);
 
-  requests.erase(std::remove_if(requests.begin(), requests.end(), [](const BlendshapeShaderConfigurationRequest& bscr) {
-                   return !bscr.mShader;
-                 }),
-                 requests.end());
-
   // Configure the rest.
   bool ok = true;