Fixed cloth simulation generating incorrect normals

Fixed cloth simulation generating incorrect normals.
Also added option in Cloth Component to update normals of static particles (disabled by default).
User will want to keep the option disabled when continuity of the normals is important, like in characters, but for environmental cloth the mesh could look better when the normals of static particles are updated too.

Enable 'Update normals of static particles' option on blind slices of  Nvcloth gem

Fix unit tests
This commit is contained in:
Aaron Ruiz Mora
2021-05-17 09:53:14 +01:00
committed by GitHub
parent 8ed8c26864
commit 0b551a0c21
13 changed files with 77 additions and 49 deletions
@@ -187,7 +187,7 @@ namespace NvCloth
m_actorClothSkinning = ActorClothSkinning::Create(
m_entityId,
m_meshNodeInfo,
m_meshClothInfo.m_particles.size(),
m_meshClothInfo.m_particles,
m_cloth->GetParticles().size(),
m_meshRemappedVertices);
m_numberOfClothSkinningUpdates = 0;
@@ -406,7 +406,7 @@ namespace NvCloth
auto& renderData = GetRenderData();
if (m_config.m_removeStaticTriangles && m_actorClothSkinning)
if (m_actorClothSkinning)
{
// Apply skinning to the non-simulated part of the mesh.
m_actorClothSkinning->ApplySkinningOnNonSimulatedVertices(m_meshClothInfo, renderData);
@@ -427,7 +427,15 @@ namespace NvCloth
if (remappedIndex >= 0)
{
renderData.m_particles[index] = particles[remappedIndex];
renderData.m_normals[index] = normals[remappedIndex];
// For static particles only use the updated normal when indicated in the configuration.
const bool useSimulatedClothParticleNormal =
m_meshClothInfo.m_particles[index].GetW() != 0.0f ||
m_config.m_updateNormalsOfStaticParticles;
if (useSimulatedClothParticleNormal)
{
renderData.m_normals[index] = normals[remappedIndex];
}
}
}