Update the cloth rule to look for optimized meshes (#2737)

The cloth rule stores the name of a mesh node that is used to retrieve
cloth data from. However, at asset processing time, the model builder
switches things to look for the optimized version of a mesh. The cloth
rule was not doing this, so it would return the cloth data for the
unoptimized mesh. This resulted in the final mesh having some data from
the optimized mesh and cloth data from the non-optimized mesh.

This changes the cloth rule to use the optimized version of a mesh, if
it exists, and fall back to the unoptimized mesh when it does not exist.

This closes issue 2454.

Signed-off-by: Chris Burel <burelc@amazon.com>
This commit is contained in:
Chris Burel
2021-08-03 14:52:53 -07:00
committed by GitHub
parent a0f3379999
commit 24740b3f86
2 changed files with 10 additions and 2 deletions
@@ -109,7 +109,7 @@ namespace AZ
if (auto* serialize = azrtti_cast<SerializeContext*>(context))
{
serialize->Class<ModelAssetBuilderComponent, SceneAPI::SceneCore::ExportingComponent>()
->Version(29); // (updated to separate material slot ID from default material asset)
->Version(30); // (updated to separate material slot ID from default material asset)
}
}
@@ -37,7 +37,15 @@ namespace NvCloth
const AZ::SceneAPI::Containers::SceneGraph& graph,
const size_t numVertices) const
{
const auto meshNodeIndex = graph.Find(GetMeshNodeName());
const AZ::SceneAPI::Containers::SceneGraph::NodeIndex meshNodeIndex = [this, &graph]()
{
if (const auto index = graph.Find(GetMeshNodeName() + AZStd::string(AZ::SceneAPI::Utilities::OptimizedMeshSuffix)); index.IsValid())
{
return index;
}
return graph.Find(GetMeshNodeName());
}();
if (!meshNodeIndex.IsValid())
{
return {};