Add skinned model import data checks to run in all build configs

This commit is contained in:
Wojtek Figat
2024-08-04 20:20:51 +02:00
parent 5171c33b72
commit 7fbf75c623

View File

@@ -1024,25 +1024,24 @@ bool ModelTool::ImportModel(const String& path, ModelData& data, Options& option
mesh->BlendIndices.SetAll(indices); mesh->BlendIndices.SetAll(indices);
mesh->BlendWeights.SetAll(weights); mesh->BlendWeights.SetAll(weights);
} }
#if BUILD_DEBUG
else else
{ {
auto& indices = mesh->BlendIndices; auto& indices = mesh->BlendIndices;
for (int32 j = 0; j < indices.Count(); j++) for (int32 j = 0; j < indices.Count(); j++)
{ {
const int32 min = indices[j].MinValue(); const Int4 ij = indices.Get()[j];
const int32 max = indices[j].MaxValue(); const int32 min = ij.MinValue();
const int32 max = ij.MaxValue();
if (min < 0 || max >= data.Skeleton.Bones.Count()) if (min < 0 || max >= data.Skeleton.Bones.Count())
{ {
LOG(Warning, "Imported mesh \'{0}\' has invalid blend indices. It may result in invalid rendering.", mesh->Name); LOG(Warning, "Imported mesh \'{0}\' has invalid blend indices. It may result in invalid rendering.", mesh->Name);
break; break;
} }
} }
auto& weights = mesh->BlendWeights; auto& weights = mesh->BlendWeights;
for (int32 j = 0; j < weights.Count(); j++) for (int32 j = 0; j < weights.Count(); j++)
{ {
const float sum = weights[j].SumValues(); const float sum = weights.Get()[j].SumValues();
if (Math::Abs(sum - 1.0f) > ZeroTolerance) if (Math::Abs(sum - 1.0f) > ZeroTolerance)
{ {
LOG(Warning, "Imported mesh \'{0}\' has invalid blend weights. It may result in invalid rendering.", mesh->Name); LOG(Warning, "Imported mesh \'{0}\' has invalid blend weights. It may result in invalid rendering.", mesh->Name);
@@ -1050,7 +1049,6 @@ bool ModelTool::ImportModel(const String& path, ModelData& data, Options& option
} }
} }
} }
#endif
} }
} }
if (EnumHasAnyFlags(options.ImportTypes, ImportDataTypes::Animations)) if (EnumHasAnyFlags(options.ImportTypes, ImportDataTypes::Animations))