mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-10 17:18:44 +08:00
[csharp] Port of be3aa5f: Scale physics constraint limits with skeleton scale. Includes additional abs(skeleton.ScaleXY) fix. See #2576.
This commit is contained in:
parent
112bea0603
commit
884af914a2
@ -147,6 +147,7 @@ namespace Spine {
|
||||
Reset();
|
||||
goto case Physics.Update; // Fall through.
|
||||
case Physics.Update:
|
||||
Skeleton skeleton = this.skeleton;
|
||||
float delta = Math.Max(skeleton.time - lastTime, 0);
|
||||
remaining += delta;
|
||||
lastTime = skeleton.time;
|
||||
@ -157,16 +158,19 @@ namespace Spine {
|
||||
ux = bx;
|
||||
uy = by;
|
||||
} else {
|
||||
float a = this.remaining, i = inertia, q = data.limit * delta, t = data.step, f = skeleton.data.referenceScale;
|
||||
float a = remaining, i = inertia, t = data.step, f = skeleton.data.referenceScale;
|
||||
float qx = data.limit * delta, qy = qx * Math.Abs(skeleton.ScaleY);
|
||||
qx *= Math.Abs(skeleton.ScaleX);
|
||||
|
||||
if (x || y) {
|
||||
if (x) {
|
||||
float u = (ux - bx) * i;
|
||||
xOffset += u > q ? q : u < -q ? -q : u;
|
||||
xOffset += u > qx ? qx : u < -qx ? -qx : u;
|
||||
ux = bx;
|
||||
}
|
||||
if (y) {
|
||||
float u = (uy - by) * i;
|
||||
yOffset += u > q ? q : u < -q ? -q : u;
|
||||
yOffset += u > qy ? qy : u < -qy ? -qy : u;
|
||||
uy = by;
|
||||
}
|
||||
if (a >= t) {
|
||||
@ -192,14 +196,14 @@ namespace Spine {
|
||||
if (rotateOrShearX || scaleX) {
|
||||
float ca = (float)Math.Atan2(bone.c, bone.a), c, s, mr = 0;
|
||||
float dx = cx - bone.worldX, dy = cy - bone.worldY;
|
||||
if (dx > q)
|
||||
dx = q;
|
||||
else if (dx < -q)
|
||||
dx = -q;
|
||||
if (dy > q)
|
||||
dy = q;
|
||||
else if (dy < -q)
|
||||
dy = -q;
|
||||
if (dx > qx)
|
||||
dx = qx;
|
||||
else if (dx < -qx)
|
||||
dx = -qx;
|
||||
if (dy > qy)
|
||||
dy = qy;
|
||||
else if (dy < -qy)
|
||||
dy = -qy;
|
||||
if (rotateOrShearX) {
|
||||
mr = (data.rotate + data.shearX) * mix;
|
||||
float r = (float)Math.Atan2(dy + ty, dx + tx) - ca - rotateOffset * mr;
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
"name": "com.esotericsoftware.spine.spine-csharp",
|
||||
"displayName": "spine-csharp Runtime",
|
||||
"description": "This plugin provides the spine-csharp core runtime.",
|
||||
"version": "4.2.25",
|
||||
"version": "4.2.26",
|
||||
"unity": "2018.3",
|
||||
"author": {
|
||||
"name": "Esoteric Software",
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user