[libgdx] Fixed shear causing physics to explode.

This commit is contained in:
Nathan Sweet 2023-12-05 14:11:42 -04:00
parent 24edbcbf6c
commit 9cd5b3b044
2 changed files with 5 additions and 7 deletions

View File

@ -36,8 +36,7 @@ import com.badlogic.gdx.backends.lwjgl3.Lwjgl3Application;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.utils.FloatArray;
import com.esotericsoftware.spine.Skeleton.Physics;
import com.esotericsoftware.spine.utils.TwoColorPolygonBatch;
@ -80,16 +79,15 @@ public class PhysicsTest2 extends ApplicationAdapter {
public boolean touchDown (int screenX, int screenY, int pointer, int button) {
lastX = screenX;
lastY = screenY;
return false;
return true;
}
@Override
public boolean touchDragged(int screenX, int screenY, int pointer) {
public boolean touchDragged (int screenX, int screenY, int pointer) {
skeleton.x += screenX - lastX;
skeleton.y += lastY - screenY;
lastX = screenX;
lastY = screenY;
return false;
return true;
}
});
}

View File

@ -166,7 +166,7 @@ public class PhysicsConstraint implements Updatable {
if (rotateOrShearX || scaleX) {
float ca = atan2(bone.c, bone.a), c, s, mr = 0;
if (rotateOrShearX) {
mr = mix * data.rotate;
mr = (data.rotate + data.shearX) * mix;
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 * mr + ca;