Skip blend shapes that influence multiple meshes (#3009)

Signed-off-by: Benjamin Jillich <jillich@amazon.com>
This commit is contained in:
Benjamin Jillich
2021-08-11 00:45:47 -07:00
committed by GitHub
parent 6a5a7740ad
commit 5c90bc0d58
2 changed files with 12 additions and 5 deletions
@@ -159,9 +159,14 @@ namespace AZ::RPI
// Determine the vertex index range for the morph target.
const uint32_t numVertices = blendShapeData->GetVertexCount();
AZ_Assert(blendShapeData->GetVertexCount() == sourceMesh.m_meshData->GetVertexCount(),
"Blend shape (%s) contains more/less vertices (%d) than the neutral mesh (%d).",
blendShapeName.c_str(), numVertices, sourceMesh.m_meshData->GetVertexCount());
if (blendShapeData->GetVertexCount() != sourceMesh.m_meshData->GetVertexCount())
{
AZ_Error(ModelAssetBuilderComponent::s_builderName, false,
"Skipping blend shape (%s) as it contains more/less vertices (%d) than the neutral mesh (%d). "
"The blend shape is most likely influencing multiple meshes, which is currently not supported.",
blendShapeName.c_str(), numVertices, sourceMesh.m_meshData->GetVertexCount());
return;
}
// The start index is after any previously added deltas
metaData.m_startIndex = aznumeric_cast<uint32_t>(packedCompressedMorphTargetVertexData.size());
@@ -379,10 +379,12 @@ namespace AZ::SceneGenerationComponents
auto [optimizedMesh, optimizedUVs, optimizedTangents, optimizedBitangents, optimizedVertexColors, optimizedSkinWeights] = OptimizeMesh(mesh, mesh, uvDatas, tangentDatas, bitangentDatas, colorDatas, skinWeightDatas, meshGroup, hasBlendShapes);
AZ_TracePrintf(AZ::SceneAPI::Utilities::LogWindow, "Base mesh: %zu vertices, optimized mesh: %zu vertices, %0.02f%% of the original",
AZ_TracePrintf(AZ::SceneAPI::Utilities::LogWindow, "Optimized mesh '%s': Original: %zu vertices -> optimized: %zu vertices, %0.02f%% of the original (hasBlendShapes=%s)",
graph.GetNodeName(nodeIndex).GetName(),
mesh->GetUsedControlPointCount(),
optimizedMesh->GetUsedControlPointCount(),
((float)optimizedMesh->GetUsedControlPointCount() / (float)mesh->GetUsedControlPointCount()) * 100.0f
((float)optimizedMesh->GetUsedControlPointCount() / (float)mesh->GetUsedControlPointCount()) * 100.0f,
hasBlendShapes ? "Yes" : "No"
);
const NodeIndex optimizedMeshNodeIndex = graph.AddChild(graph.GetNodeParent(nodeIndex), name.c_str(), AZStd::move(optimizedMesh));