[libgdx] One bone IK clean up.

This commit is contained in:
NathanSweet 2019-12-18 18:16:05 +01:00
parent 203a648ae9
commit d94ebeae7a

View File

@ -186,12 +186,9 @@ public class IkConstraint implements Updatable {
break; break;
case noRotationOrReflection: case noRotationOrReflection:
rotationIK += atan2(pc, pa) * radDeg; rotationIK += atan2(pc, pa) * radDeg;
float ps = pa * pa + pc * pc; float ps = Math.abs(pa * pd - pb * pc) / (pa * pa + pc * pc);
if (ps > 0.0001f) { pb = -pc * ps;
ps = Math.abs(pa * pd - pb * pc) / ps; pd = pa * ps;
pb = -pc * ps;
pd = pa * ps;
}
default: default:
float x = targetX - p.worldX, y = targetY - p.worldY; float x = targetX - p.worldX, y = targetY - p.worldY;
float d = pa * pd - pb * pc; float d = pa * pd - pb * pc;