Add warning when cloth paint is incorrect size

This commit is contained in:
Wojtek Figat
2025-03-11 23:09:47 +01:00
parent 477c979cdd
commit 5d32bb962f
4 changed files with 12 additions and 1 deletions

View File

@@ -9,6 +9,11 @@ ModelInstanceActor::ModelInstanceActor(const SpawnParams& params)
{
}
String ModelInstanceActor::MeshReference::ToString() const
{
return String::Format(TEXT("Actor={},LOD={},Mesh={}"), Actor ? Actor->GetNamePath() : String::Empty, LODIndex, MeshIndex);
}
void ModelInstanceActor::SetEntries(const Array<ModelInstanceEntry>& value)
{
WaitForModelLoad();

View File

@@ -27,6 +27,8 @@ API_CLASS(Abstract) class FLAXENGINE_API ModelInstanceActor : public Actor
API_FIELD() int32 LODIndex = 0;
// Index of the mesh (within the LOD).
API_FIELD() int32 MeshIndex = 0;
String ToString() const;
};
protected:

View File

@@ -644,6 +644,7 @@ void Cloth::CalculateInvMasses(Array<float>& invMasses)
if (_paint.Count() != verticesCount)
{
// Fix incorrect paint data
LOG(Warning, "Incorrect cloth '{}' paint size {} for mesh '{}' that has {} vertices", GetNamePath(), _paint.Count(), mesh.ToString(), verticesCount);
int32 countBefore = _paint.Count();
_paint.Resize(verticesCount);
for (int32 i = countBefore; i < verticesCount; i++)
@@ -781,7 +782,10 @@ bool Cloth::OnPreUpdate()
if (mesh.Actor->GetMeshData(mesh, MeshBufferType::Vertex0, verticesData, verticesCount))
return false;
if (verticesCount != _paint.Count())
{
LOG(Warning, "Incorrect cloth '{}' paint size {} for mesh '{}' that has {} vertices", GetNamePath(), _paint.Count(), mesh.ToString(), verticesCount);
return false;
}
PROFILE_CPU_NAMED("Skinned Pose");
auto vbStride = (uint32)verticesData.Length() / verticesCount;
ASSERT(vbStride == sizeof(VB0SkinnedElementType));

View File

@@ -185,7 +185,7 @@ Ray JsonTools::GetRay(const Value& value)
{
return Ray(
GetVector3(value, "Position", Vector3::Zero),
GetVector3(value, "Direction", Vector3::One)
GetVector3(value, "Direction", Vector3::Forward)
);
}