Fix crash when creating cloth with all vertices fixed

This commit is contained in:
Wojtek Figat
2023-07-14 14:12:30 +02:00
parent 3141b4fb04
commit 3f9e286279
2 changed files with 15 additions and 5 deletions

View File

@@ -507,6 +507,16 @@ bool Cloth::CreateCloth()
#if WITH_CLOTH
PROFILE_CPU();
// Skip if all vertices are fixed so cloth sim doesn't make sense
if (_paint.HasItems())
{
bool allZero = true;
for (int32 i = 0; i < _paint.Count() && allZero; i++)
allZero = _paint[i] <= ZeroTolerance;
if (allZero)
return false;
}
// Get mesh data
// TODO: consider making it via async task so physics can wait on the cloth setup from mesh data just before next fixed update which gives more time when loading scene
const ModelInstanceActor::MeshReference mesh = GetMesh();