mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-03-08 03:36:52 +08:00
[libgdx] Fixed shear causing physics to explode.
This commit is contained in:
parent
24edbcbf6c
commit
9cd5b3b044
@ -36,8 +36,7 @@ import com.badlogic.gdx.backends.lwjgl3.Lwjgl3Application;
|
|||||||
import com.badlogic.gdx.graphics.GL20;
|
import com.badlogic.gdx.graphics.GL20;
|
||||||
import com.badlogic.gdx.graphics.OrthographicCamera;
|
import com.badlogic.gdx.graphics.OrthographicCamera;
|
||||||
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
|
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.Skeleton.Physics;
|
||||||
import com.esotericsoftware.spine.utils.TwoColorPolygonBatch;
|
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) {
|
public boolean touchDown (int screenX, int screenY, int pointer, int button) {
|
||||||
lastX = screenX;
|
lastX = screenX;
|
||||||
lastY = screenY;
|
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.x += screenX - lastX;
|
||||||
skeleton.y += lastY - screenY;
|
skeleton.y += lastY - screenY;
|
||||||
lastX = screenX;
|
lastX = screenX;
|
||||||
lastY = screenY;
|
lastY = screenY;
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@ -166,7 +166,7 @@ public class PhysicsConstraint implements Updatable {
|
|||||||
if (rotateOrShearX || scaleX) {
|
if (rotateOrShearX || scaleX) {
|
||||||
float ca = atan2(bone.c, bone.a), c, s, mr = 0;
|
float ca = atan2(bone.c, bone.a), c, s, mr = 0;
|
||||||
if (rotateOrShearX) {
|
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;
|
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;
|
rotateOffset += (r - (float)Math.ceil(r * invPI2 - 0.5f) * PI2) * i;
|
||||||
r = rotateOffset * mr + ca;
|
r = rotateOffset * mr + ca;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user