mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-03-02 21:59:09 +08:00
[libgdx] Scale physics wind and gravity for translation, scale rotation for shear X.
This commit is contained in:
parent
831ec8f622
commit
008541ef8e
@ -121,12 +121,12 @@ public class PhysicsConstraint implements Updatable {
|
|||||||
while (remaining >= step) {
|
while (remaining >= step) {
|
||||||
remaining -= step;
|
remaining -= step;
|
||||||
if (x) {
|
if (x) {
|
||||||
xVelocity += (wind - xOffset * strength - friction * xVelocity) * mass;
|
xVelocity += (wind * 500 - xOffset * strength - xVelocity * friction) * mass;
|
||||||
xOffset += xVelocity * step;
|
xOffset += xVelocity * step;
|
||||||
xVelocity *= damping;
|
xVelocity *= damping;
|
||||||
}
|
}
|
||||||
if (y) {
|
if (y) {
|
||||||
yVelocity += (-gravity - yOffset * strength - friction * yVelocity) * mass;
|
yVelocity += (-gravity * 500 - yOffset * strength - yVelocity * friction) * mass;
|
||||||
yOffset += yVelocity * step;
|
yOffset += yVelocity * step;
|
||||||
yVelocity *= damping;
|
yVelocity *= damping;
|
||||||
}
|
}
|
||||||
@ -134,17 +134,17 @@ public class PhysicsConstraint implements Updatable {
|
|||||||
float r = br + rotateOffset * degRad;
|
float r = br + rotateOffset * degRad;
|
||||||
cos = cos(r);
|
cos = cos(r);
|
||||||
sin = sin(r);
|
sin = sin(r);
|
||||||
}
|
if (rotateOrShear) {
|
||||||
if (rotateOrShear) {
|
rotateVelocity += (length * (-wind * sin - gravity * cos) - rotateOffset * strength - rotateVelocity * friction)
|
||||||
rotateVelocity += (length * (-wind * sin - gravity * cos) - rotateOffset * strength - friction * rotateVelocity)
|
* mass;
|
||||||
* mass;
|
rotateOffset += rotateVelocity * step;
|
||||||
rotateOffset += rotateVelocity * step;
|
rotateVelocity *= damping;
|
||||||
rotateVelocity *= damping;
|
}
|
||||||
}
|
if (scaleX) {
|
||||||
if (scaleX) {
|
scaleVelocity += (wind * cos - gravity * sin - scaleOffset * strength - scaleVelocity * friction) * mass;
|
||||||
scaleVelocity += (wind * cos - gravity * sin - scaleOffset * strength - friction * scaleVelocity) * mass;
|
scaleOffset += scaleVelocity * step;
|
||||||
scaleOffset += scaleVelocity * step;
|
scaleVelocity *= damping;
|
||||||
scaleVelocity *= damping;
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -192,16 +192,12 @@ public class PhysicsConstraint implements Updatable {
|
|||||||
|
|
||||||
if (rotateOrShear) {
|
if (rotateOrShear) {
|
||||||
float r = rotateOffset * mix;
|
float r = rotateOffset * mix;
|
||||||
|
if (data.rotate) bone.rotateWorld(r);
|
||||||
if (data.shearX) {
|
if (data.shearX) {
|
||||||
if (data.rotate) {
|
float t = (float)Math.tan(r * 0.5f * degRad);
|
||||||
r *= 0.5f;
|
|
||||||
bone.rotateWorld(r);
|
|
||||||
}
|
|
||||||
float t = (float)Math.tan(r * degRad);
|
|
||||||
bone.b += bone.a * t;
|
bone.b += bone.a * t;
|
||||||
bone.d += bone.c * t;
|
bone.d += bone.c * t;
|
||||||
} else
|
}
|
||||||
bone.rotateWorld(r);
|
|
||||||
}
|
}
|
||||||
if (scaleX) {
|
if (scaleX) {
|
||||||
float s = 1 + scaleOffset * mix;
|
float s = 1 + scaleOffset * mix;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user