Skip to content

Commit

Permalink
[libgdx] Fixed some physics constraint behavior when strength is 0.
Browse files Browse the repository at this point in the history
  • Loading branch information
NathanSweet committed Nov 22, 2023
1 parent 92a9b88 commit 1fcaba8
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -164,11 +164,12 @@ public void update (Physics physics) {
if (y) bone.worldY += yOffset * mix * data.y;
}
if (rotateOrShearX || scaleX) {
float ca = atan2(bone.c, bone.a), c, s;
float ca = atan2(bone.c, bone.a), c, s, mr = 0;
if (rotateOrShearX) {
float dx = cx - bone.worldX, dy = cy - bone.worldY, r = atan2(dy + ty, dx + tx) - ca - rotateOffset * mix;
mr = mix * data.rotate;
float dx = cx - bone.worldX, dy = cy - bone.worldY, r = atan2(dy + ty, dx + tx) - ca - rotateOffset * mr;
rotateOffset += (r - (float)Math.ceil(r * invPI2 - 0.5f) * PI2) * i;
r = rotateOffset * mix + ca;
r = rotateOffset * mr + ca;
c = cos(r);
s = sin(r);
if (scaleX) {
Expand Down Expand Up @@ -197,7 +198,7 @@ public void update (Physics physics) {
rotateOffset += rotateVelocity * step;
rotateVelocity *= d;
if (remaining < step) break;
float r = rotateOffset * mix + ca;
float r = rotateOffset * mr + ca;
c = cos(r);
s = sin(r);
} else if (remaining < step) //
Expand Down

0 comments on commit 1fcaba8

Please sign in to comment.