Ignore invalid attributes on export

This commit is contained in:
ackwell 2024-01-27 14:08:56 +11:00
parent 6693a1e0ba
commit 72775a80bf

View file

@ -230,10 +230,19 @@ public class MeshExporter
{ "targetNames", shapeNames },
});
var attributes = Enumerable.Range(0, 32)
.Where(index => ((attributeMask >> index) & 1) == 1)
.Select(index => _mdl.Attributes[index])
.ToArray();
string[] attributes = [];
var maxAttribute = 31 - BitOperations.LeadingZeroCount(attributeMask);
if (maxAttribute < _mdl.Attributes.Length)
{
attributes = Enumerable.Range(0, 32)
.Where(index => ((attributeMask >> index) & 1) == 1)
.Select(index => _mdl.Attributes[index])
.ToArray();
}
else
{
_notifier.Warning($"Invalid attribute data, ignoring.");
}
return new MeshData
{