[ts] Port of commit 877e705dd. Fix NaN in IKConstraint due to fp precision.

This commit is contained in:
Davide Tantillo 2024-08-07 08:36:46 +02:00
parent 877e705ddb
commit e4df0c0dff

View File

@ -270,8 +270,9 @@ export class IkConstraint implements Updatable {
q = -(c1 + q) * 0.5;
let r0 = q / c2, r1 = c / q;
let r = Math.abs(r0) < Math.abs(r1) ? r0 : r1;
if (r * r <= dd) {
y = Math.sqrt(dd - r * r) * bendDir;
r0 = dd - r * r;
if (r0 >= 0) {
y = Math.sqrt(r0) * bendDir;
a1 = ta - Math.atan2(y, r);
a2 = Math.atan2(y / psy, (r - l1) / psx);
break outer;