mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2025-12-21 01:36:02 +08:00
[csharp] Fixed errors in IKConstraint.cs.
This commit is contained in:
parent
89d9474e40
commit
89da80d25f
@ -169,17 +169,24 @@ namespace Spine {
|
|||||||
tx = targetX - bone.worldX;
|
tx = targetX - bone.worldX;
|
||||||
ty = targetY - bone.worldY;
|
ty = targetY - bone.worldY;
|
||||||
break;
|
break;
|
||||||
case TransformMode.NoRotationOrReflection:
|
case TransformMode.NoRotationOrReflection: {
|
||||||
rotationIK += Math.Atan2(pc, pa) * MathUtils.radDeg;
|
rotationIK += (float)Math.Atan2(pc, pa) * MathUtils.RadDeg;
|
||||||
float ps = Math.Abs(pa * pd - pb * pc) / (pa * pa + pc * pc);
|
float ps = Math.Abs(pa * pd - pb * pc) / (pa * pa + pc * pc);
|
||||||
pb = -pc * ps;
|
pb = -pc * ps;
|
||||||
pd = pa * ps;
|
pd = pa * ps;
|
||||||
// Fall through
|
float x = targetX - p.worldX, y = targetY - p.worldY;
|
||||||
default:
|
float d = pa * pd - pb * pc;
|
||||||
let x = targetX - p.worldX, y = targetY - p.worldY;
|
tx = (x * pd - y * pb) / d - bone.ax;
|
||||||
let d = pa * pd - pb * pc;
|
ty = (y * pa - x * pc) / d - bone.ay;
|
||||||
tx = (x * pd - y * pb) / d - bone.ax;
|
break;
|
||||||
ty = (y * pa - x * pc) / d - bone.ay;
|
}
|
||||||
|
default: {
|
||||||
|
float x = targetX - p.worldX, y = targetY - p.worldY;
|
||||||
|
float d = pa * pd - pb * pc;
|
||||||
|
tx = (x * pd - y * pb) / d - bone.ax;
|
||||||
|
ty = (y * pa - x * pc) / d - bone.ay;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
rotationIK += (float)Math.Atan2(ty, tx) * MathUtils.RadDeg;
|
rotationIK += (float)Math.Atan2(ty, tx) * MathUtils.RadDeg;
|
||||||
@ -193,9 +200,13 @@ namespace Spine {
|
|||||||
if (compress || stretch) {
|
if (compress || stretch) {
|
||||||
switch (bone.data.transformMode) {
|
switch (bone.data.transformMode) {
|
||||||
case TransformMode.NoScale:
|
case TransformMode.NoScale:
|
||||||
case TransformMode.NoScaleOrReflection:
|
tx = targetX - bone.worldX;
|
||||||
|
ty = targetY - bone.worldY;
|
||||||
|
break;
|
||||||
|
case TransformMode.NoScaleOrReflection:
|
||||||
tx = targetX - bone.worldX;
|
tx = targetX - bone.worldX;
|
||||||
ty = targetY - bone.worldY;
|
ty = targetY - bone.worldY;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
float b = bone.data.length * sx, dd = (float)Math.Sqrt(tx * tx + ty * ty);
|
float b = bone.data.length * sx, dd = (float)Math.Sqrt(tx * tx + ty * ty);
|
||||||
if ((compress && dd < b) || (stretch && dd > b) && b > 0.0001f) {
|
if ((compress && dd < b) || (stretch && dd > b) && b > 0.0001f) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user