jeremyfa/spine-hx

Softness broken due to rounding

Closed this issue · 2 comments

After investigating an issue with IK Softness, I traced it to the following line:

var p:Float = MathUtils.min(1, Std.int(sd / (softness * 2))) - 1;

This rounds to zero in most cases, breaking IKs, if softness is applied.

The rounding isn't present in the official libgdx runtime (link), so my guess is it's added during the conversion. Changing the code to this:
var p:Float = MathUtils.min(1.0, sd / (softness * 2)) - 1;
fixes the issue. Note that the first param needs to be 1.0 for the Haxe compiler to accept Float as the second param. My guess this is the issue that lead to the rounding being added at some point.

I didn't create a PR, as this seems to be an issue with converting from libgdx and I am not able to get this to properly work on my end. The same conversion/rounding issue may be present in other places. A quick search showed potential issues in AnimationState.hx, but I don't have a test case to confirm:

alpha = alphaHold * MathUtils.max(0, Std.int(1 - holdMix.mixTime / holdMix.mixDuration));

current.interruptAlpha *= MathUtils.min(1, Std.int(from.mixTime / from.mixDuration));

Indeed that’s an issue with the converter. I’ll take a look at the converter and see why it does that as soon as I have the bandwidth for that.

Thanks for investigating!

The converter is now fixed and should output the same as what you manually fixed!