mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-03-26 22:49:01 +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();
|
Reset();
|
||||||
goto case Physics.Update; // Fall through.
|
goto case Physics.Update; // Fall through.
|
||||||
case Physics.Update:
|
case Physics.Update:
|
||||||
|
Skeleton skeleton = this.skeleton;
|
||||||
float delta = Math.Max(skeleton.time - lastTime, 0);
|
float delta = Math.Max(skeleton.time - lastTime, 0);
|
||||||
remaining += delta;
|
remaining += delta;
|
||||||
lastTime = skeleton.time;
|
lastTime = skeleton.time;
|
||||||
@ -157,16 +158,19 @@ namespace Spine {
|
|||||||
ux = bx;
|
ux = bx;
|
||||||
uy = by;
|
uy = by;
|
||||||
} else {
|
} 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 || y) {
|
||||||
if (x) {
|
if (x) {
|
||||||
float u = (ux - bx) * i;
|
float u = (ux - bx) * i;
|
||||||
xOffset += u > q ? q : u < -q ? -q : u;
|
xOffset += u > qx ? qx : u < -qx ? -qx : u;
|
||||||
ux = bx;
|
ux = bx;
|
||||||
}
|
}
|
||||||
if (y) {
|
if (y) {
|
||||||
float u = (uy - by) * i;
|
float u = (uy - by) * i;
|
||||||
yOffset += u > q ? q : u < -q ? -q : u;
|
yOffset += u > qy ? qy : u < -qy ? -qy : u;
|
||||||
uy = by;
|
uy = by;
|
||||||
}
|
}
|
||||||
if (a >= t) {
|
if (a >= t) {
|
||||||
@ -192,14 +196,14 @@ namespace Spine {
|
|||||||
if (rotateOrShearX || scaleX) {
|
if (rotateOrShearX || scaleX) {
|
||||||
float ca = (float)Math.Atan2(bone.c, bone.a), c, s, mr = 0;
|
float ca = (float)Math.Atan2(bone.c, bone.a), c, s, mr = 0;
|
||||||
float dx = cx - bone.worldX, dy = cy - bone.worldY;
|
float dx = cx - bone.worldX, dy = cy - bone.worldY;
|
||||||
if (dx > q)
|
if (dx > qx)
|
||||||
dx = q;
|
dx = qx;
|
||||||
else if (dx < -q)
|
else if (dx < -qx)
|
||||||
dx = -q;
|
dx = -qx;
|
||||||
if (dy > q)
|
if (dy > qy)
|
||||||
dy = q;
|
dy = qy;
|
||||||
else if (dy < -q)
|
else if (dy < -qy)
|
||||||
dy = -q;
|
dy = -qy;
|
||||||
if (rotateOrShearX) {
|
if (rotateOrShearX) {
|
||||||
mr = (data.rotate + data.shearX) * mix;
|
mr = (data.rotate + data.shearX) * mix;
|
||||||
float r = (float)Math.Atan2(dy + ty, dx + tx) - ca - rotateOffset * mr;
|
float r = (float)Math.Atan2(dy + ty, dx + tx) - ca - rotateOffset * mr;
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
"name": "com.esotericsoftware.spine.spine-csharp",
|
"name": "com.esotericsoftware.spine.spine-csharp",
|
||||||
"displayName": "spine-csharp Runtime",
|
"displayName": "spine-csharp Runtime",
|
||||||
"description": "This plugin provides the spine-csharp core runtime.",
|
"description": "This plugin provides the spine-csharp core runtime.",
|
||||||
"version": "4.2.25",
|
"version": "4.2.26",
|
||||||
"unity": "2018.3",
|
"unity": "2018.3",
|
||||||
"author": {
|
"author": {
|
||||||
"name": "Esoteric Software",
|
"name": "Esoteric Software",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user