Fix blend weight adjustment getting stuck on near-bounds values

This commit is contained in:
ackwell 2024-06-04 12:10:45 +10:00 committed by Ottermandias
parent b63935e81e
commit 87fec7783e

View file

@ -150,6 +150,12 @@ public class VertexAttribute
{
var convertedValues = byteValues.Select(value => value * (1f / 255f)).ToArray();
var closestIndex = Enumerable.Range(0, 4)
.Where(index => {
var byteValue = byteValues[index];
if (adjustment < 0) return byteValue > 0;
if (adjustment > 0) return byteValue < 255;
return true;
})
.Select(index => (index, delta: Math.Abs(originalValues[index] - convertedValues[index])))
.MinBy(x => x.delta)
.index;