mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2025-12-21 09:46:02 +08:00
Merge branch '4.1' into 4.2-beta
This commit is contained in:
commit
954ab69bce
@ -61,14 +61,14 @@ f84ae17615c506bf98c575bb800d2cf3b793df4d
|
|||||||
# 2014-01-11 Updated license to version 2.
|
# 2014-01-11 Updated license to version 2.
|
||||||
d520addb9bfdf552881cb6871d70159a80e1ff6b
|
d520addb9bfdf552881cb6871d70159a80e1ff6b
|
||||||
|
|
||||||
# 2013-10-03 9a347d5eb8ad095c5e739d959de485b6add7f0b3
|
# 2013-10-03 Updated license.
|
||||||
Updated license.
|
9a347d5eb8ad095c5e739d959de485b6add7f0b3
|
||||||
|
|
||||||
# 2013-10-01 Minor update to the license to include education.
|
# 2013-10-01 Minor update to the license to include education.
|
||||||
47ce2a40c18b8ea471e6004f7e2c6cbf5b36af76
|
47ce2a40c18b8ea471e6004f7e2c6cbf5b36af76
|
||||||
|
|
||||||
# 2013-09-20 e2fccf72d6541c598172a538d4d497e6d13340cc
|
# 2013-09-20 License update.
|
||||||
License update.
|
e2fccf72d6541c598172a538d4d497e6d13340cc
|
||||||
|
|
||||||
# 2013 License headers.
|
# 2013 License headers.
|
||||||
4edc23ac2f1c00782b4f637fb2543d784bd8dda9
|
4edc23ac2f1c00782b4f637fb2543d784bd8dda9
|
||||||
|
|||||||
@ -84,7 +84,7 @@ void spIkConstraint_apply1(spBone *bone, float targetX, float targetY, int /*boo
|
|||||||
ty = targetY - bone->worldY;
|
ty = targetY - bone->worldY;
|
||||||
break;
|
break;
|
||||||
case SP_TRANSFORMMODE_NOROTATIONORREFLECTION: {
|
case SP_TRANSFORMMODE_NOROTATIONORREFLECTION: {
|
||||||
s = ABS(pa * pd - pb * pc) / (pa * pa + pc * pc);
|
s = ABS(pa * pd - pb * pc) / MAX(0.0001f, pa * pa + pc * pc);
|
||||||
sa = pa / bone->skeleton->scaleX;
|
sa = pa / bone->skeleton->scaleX;
|
||||||
sc = pc / bone->skeleton->scaleY;
|
sc = pc / bone->skeleton->scaleY;
|
||||||
pb = -sc * s * bone->skeleton->scaleX;
|
pb = -sc * s * bone->skeleton->scaleX;
|
||||||
@ -94,10 +94,15 @@ void spIkConstraint_apply1(spBone *bone, float targetX, float targetY, int /*boo
|
|||||||
default: {
|
default: {
|
||||||
float x = targetX - p->worldX, y = targetY - p->worldY;
|
float x = targetX - p->worldX, y = targetY - p->worldY;
|
||||||
float d = pa * pd - pb * pc;
|
float d = pa * pd - pb * pc;
|
||||||
|
if (ABS(d) <= 0.0001f) {
|
||||||
|
tx = 0;
|
||||||
|
ty = 0;
|
||||||
|
} else {
|
||||||
tx = (x * pd - y * pb) / d - bone->ax;
|
tx = (x * pd - y * pb) / d - bone->ax;
|
||||||
ty = (y * pa - x * pc) / d - bone->ay;
|
ty = (y * pa - x * pc) / d - bone->ay;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
rotationIK += ATAN2(ty, tx) * RAD_DEG;
|
rotationIK += ATAN2(ty, tx) * RAD_DEG;
|
||||||
|
|
||||||
if (bone->ascaleX < 0) rotationIK += 180;
|
if (bone->ascaleX < 0) rotationIK += 180;
|
||||||
@ -177,7 +182,8 @@ void spIkConstraint_apply2(spBone *parent, spBone *child, float targetX, float t
|
|||||||
b = pp->b;
|
b = pp->b;
|
||||||
c = pp->c;
|
c = pp->c;
|
||||||
d = pp->d;
|
d = pp->d;
|
||||||
id = 1 / (a * d - b * c);
|
id = a * d - b * c;
|
||||||
|
id = ABS(id) <= 0.0001f ? 0 : 1 / id;
|
||||||
x = cwx - pp->worldX;
|
x = cwx - pp->worldX;
|
||||||
y = cwy - pp->worldY;
|
y = cwy - pp->worldY;
|
||||||
dx = (x * d - y * b) * id - px;
|
dx = (x * d - y * b) * id - px;
|
||||||
|
|||||||
@ -51,7 +51,7 @@ void IkConstraint::apply(Bone &bone, float targetX, float targetY, bool compress
|
|||||||
ty = targetY - bone._worldY;
|
ty = targetY - bone._worldY;
|
||||||
break;
|
break;
|
||||||
case TransformMode_NoRotationOrReflection: {
|
case TransformMode_NoRotationOrReflection: {
|
||||||
float s = MathUtil::abs(pa * pd - pb * pc) / (pa * pa + pc * pc);
|
float s = MathUtil::abs(pa * pd - pb * pc) / MathUtil::max(0.0001f, pa * pa + pc * pc);
|
||||||
float sa = pa / bone._skeleton.getScaleX();
|
float sa = pa / bone._skeleton.getScaleX();
|
||||||
float sc = pc / bone._skeleton.getScaleY();
|
float sc = pc / bone._skeleton.getScaleY();
|
||||||
pb = -sc * s * bone._skeleton.getScaleX();
|
pb = -sc * s * bone._skeleton.getScaleX();
|
||||||
@ -61,9 +61,14 @@ void IkConstraint::apply(Bone &bone, float targetX, float targetY, bool compress
|
|||||||
default:
|
default:
|
||||||
float x = targetX - p->_worldX, y = targetY - p->_worldY;
|
float x = targetX - p->_worldX, y = targetY - p->_worldY;
|
||||||
float d = pa * pd - pb * pc;
|
float d = pa * pd - pb * pc;
|
||||||
|
if (MathUtil::abs(d) <= 0.0001f) {
|
||||||
|
tx = 0;
|
||||||
|
ty = 0;
|
||||||
|
} else {
|
||||||
tx = (x * pd - y * pb) / d - bone._ax;
|
tx = (x * pd - y * pb) / d - bone._ax;
|
||||||
ty = (y * pa - x * pc) / d - bone._ay;
|
ty = (y * pa - x * pc) / d - bone._ay;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
rotationIK += MathUtil::atan2(ty, tx) * MathUtil::Rad_Deg;
|
rotationIK += MathUtil::atan2(ty, tx) * MathUtil::Rad_Deg;
|
||||||
if (bone._ascaleX < 0) rotationIK += 180;
|
if (bone._ascaleX < 0) rotationIK += 180;
|
||||||
if (rotationIK > 180) rotationIK -= 360;
|
if (rotationIK > 180) rotationIK -= 360;
|
||||||
@ -140,7 +145,8 @@ void IkConstraint::apply(Bone &parent, Bone &child, float targetX, float targetY
|
|||||||
b = pp->_b;
|
b = pp->_b;
|
||||||
c = pp->_c;
|
c = pp->_c;
|
||||||
d = pp->_d;
|
d = pp->_d;
|
||||||
id = 1 / (a * d - b * c);
|
id = a * d - b * c;
|
||||||
|
id = MathUtil::abs(id) <= 0.0001f ? 0 : 1 / id;
|
||||||
x = cwx - pp->_worldX;
|
x = cwx - pp->_worldX;
|
||||||
y = cwy - pp->_worldY;
|
y = cwy - pp->_worldY;
|
||||||
dx = (x * d - y * b) * id - px;
|
dx = (x * d - y * b) * id - px;
|
||||||
|
|||||||
@ -164,7 +164,6 @@ void Skin::addSkin(Skin *other) {
|
|||||||
AttachmentMap::Entries entries = other->getAttachments();
|
AttachmentMap::Entries entries = other->getAttachments();
|
||||||
while (entries.hasNext()) {
|
while (entries.hasNext()) {
|
||||||
AttachmentMap::Entry &entry = entries.next();
|
AttachmentMap::Entry &entry = entries.next();
|
||||||
entry._attachment->reference();
|
|
||||||
setAttachment(entry._slotIndex, entry._name, entry._attachment);
|
setAttachment(entry._slotIndex, entry._name, entry._attachment);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -172,7 +172,7 @@ namespace Spine {
|
|||||||
ty = targetY - bone.worldY;
|
ty = targetY - bone.worldY;
|
||||||
break;
|
break;
|
||||||
case TransformMode.NoRotationOrReflection: {
|
case TransformMode.NoRotationOrReflection: {
|
||||||
float s = Math.Abs(pa * pd - pb * pc) / (pa * pa + pc * pc);
|
float s = Math.Abs(pa * pd - pb * pc) / Math.Max(0.0001f, pa * pa + pc * pc);
|
||||||
float sa = pa / bone.skeleton.scaleX;
|
float sa = pa / bone.skeleton.scaleX;
|
||||||
float sc = pc / bone.skeleton.scaleY;
|
float sc = pc / bone.skeleton.scaleY;
|
||||||
pb = -sc * s * bone.skeleton.scaleX;
|
pb = -sc * s * bone.skeleton.scaleX;
|
||||||
@ -183,8 +183,13 @@ namespace Spine {
|
|||||||
default: {
|
default: {
|
||||||
float x = targetX - p.worldX, y = targetY - p.worldY;
|
float x = targetX - p.worldX, y = targetY - p.worldY;
|
||||||
float d = pa * pd - pb * pc;
|
float d = pa * pd - pb * pc;
|
||||||
|
if (Math.Abs(d) <= 0.0001f) {
|
||||||
|
tx = 0;
|
||||||
|
ty = 0;
|
||||||
|
} else {
|
||||||
tx = (x * pd - y * pb) / d - bone.ax;
|
tx = (x * pd - y * pb) / d - bone.ax;
|
||||||
ty = (y * pa - x * pc) / d - bone.ay;
|
ty = (y * pa - x * pc) / d - bone.ay;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -256,7 +261,8 @@ namespace Spine {
|
|||||||
b = pp.b;
|
b = pp.b;
|
||||||
c = pp.c;
|
c = pp.c;
|
||||||
d = pp.d;
|
d = pp.d;
|
||||||
float id = 1 / (a * d - b * c), x = cwx - pp.worldX, y = cwy - pp.worldY;
|
float id = a * d - b * c, x = cwx - pp.worldX, y = cwy - pp.worldY;
|
||||||
|
id = Math.Abs(id) <= 0.0001f ? 0 : 1 / id;
|
||||||
float dx = (x * d - y * b) * id - px, dy = (y * a - x * c) * id - py;
|
float dx = (x * d - y * b) * id - px, dy = (y * a - x * c) * id - py;
|
||||||
float l1 = (float)Math.Sqrt(dx * dx + dy * dy), l2 = child.data.length * csx, a1, a2;
|
float l1 = (float)Math.Sqrt(dx * dx + dy * dy), l2 = child.data.length * csx, a1, a2;
|
||||||
if (l1 < 0.0001f) {
|
if (l1 < 0.0001f) {
|
||||||
|
|||||||
@ -195,7 +195,7 @@ public class IkConstraint implements Updatable {
|
|||||||
ty = targetY - bone.worldY;
|
ty = targetY - bone.worldY;
|
||||||
break;
|
break;
|
||||||
case noRotationOrReflection:
|
case noRotationOrReflection:
|
||||||
float s = Math.abs(pa * pd - pb * pc) / (pa * pa + pc * pc);
|
float s = Math.abs(pa * pd - pb * pc) / Math.max(0.0001f, pa * pa + pc * pc);
|
||||||
float sa = pa / bone.skeleton.scaleX;
|
float sa = pa / bone.skeleton.scaleX;
|
||||||
float sc = pc / bone.skeleton.scaleY;
|
float sc = pc / bone.skeleton.scaleY;
|
||||||
pb = -sc * s * bone.skeleton.scaleX;
|
pb = -sc * s * bone.skeleton.scaleX;
|
||||||
@ -205,9 +205,14 @@ public class IkConstraint implements Updatable {
|
|||||||
default:
|
default:
|
||||||
float x = targetX - p.worldX, y = targetY - p.worldY;
|
float x = targetX - p.worldX, y = targetY - p.worldY;
|
||||||
float d = pa * pd - pb * pc;
|
float d = pa * pd - pb * pc;
|
||||||
|
if (Math.abs(d) <= 0.0001f) {
|
||||||
|
tx = 0;
|
||||||
|
ty = 0;
|
||||||
|
} else {
|
||||||
tx = (x * pd - y * pb) / d - bone.ax;
|
tx = (x * pd - y * pb) / d - bone.ax;
|
||||||
ty = (y * pa - x * pc) / d - bone.ay;
|
ty = (y * pa - x * pc) / d - bone.ay;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
rotationIK += atan2Deg(ty, tx);
|
rotationIK += atan2Deg(ty, tx);
|
||||||
if (bone.ascaleX < 0) rotationIK += 180;
|
if (bone.ascaleX < 0) rotationIK += 180;
|
||||||
if (rotationIK > 180)
|
if (rotationIK > 180)
|
||||||
@ -276,7 +281,8 @@ public class IkConstraint implements Updatable {
|
|||||||
b = pp.b;
|
b = pp.b;
|
||||||
c = pp.c;
|
c = pp.c;
|
||||||
d = pp.d;
|
d = pp.d;
|
||||||
float id = 1 / (a * d - b * c), x = cwx - pp.worldX, y = cwy - pp.worldY;
|
float id = a * d - b * c, x = cwx - pp.worldX, y = cwy - pp.worldY;
|
||||||
|
id = Math.abs(id) <= 0.0001f ? 0 : 1 / id;
|
||||||
float dx = (x * d - y * b) * id - px, dy = (y * a - x * c) * id - py;
|
float dx = (x * d - y * b) * id - px, dy = (y * a - x * c) * id - py;
|
||||||
float l1 = (float)Math.sqrt(dx * dx + dy * dy), l2 = child.data.length * csx, a1, a2;
|
float l1 = (float)Math.sqrt(dx * dx + dy * dy), l2 = child.data.length * csx, a1, a2;
|
||||||
if (l1 < 0.0001f) {
|
if (l1 < 0.0001f) {
|
||||||
|
|||||||
@ -18,7 +18,7 @@
|
|||||||
</ul>
|
</ul>
|
||||||
<li>Phaser</li>
|
<li>Phaser</li>
|
||||||
<ul>
|
<ul>
|
||||||
<li><a href="/spine-phaser/example/index.html">Example</a></li>
|
<li><a href="/spine-phaser/example/index.html">Examples</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
<li>Player</li>
|
<li>Player</li>
|
||||||
<ul>
|
<ul>
|
||||||
|
|||||||
@ -117,7 +117,7 @@ export class IkConstraint implements Updatable {
|
|||||||
ty = targetY - bone.worldY;
|
ty = targetY - bone.worldY;
|
||||||
break;
|
break;
|
||||||
case TransformMode.NoRotationOrReflection:
|
case TransformMode.NoRotationOrReflection:
|
||||||
let s = Math.abs(pa * pd - pb * pc) / (pa * pa + pc * pc);
|
let s = Math.abs(pa * pd - pb * pc) / Math.max(0.0001, pa * pa + pc * pc);
|
||||||
let sa = pa / bone.skeleton.scaleX;
|
let sa = pa / bone.skeleton.scaleX;
|
||||||
let sc = pc / bone.skeleton.scaleY;
|
let sc = pc / bone.skeleton.scaleY;
|
||||||
pb = -sc * s * bone.skeleton.scaleX;
|
pb = -sc * s * bone.skeleton.scaleX;
|
||||||
@ -127,9 +127,14 @@ export class IkConstraint implements Updatable {
|
|||||||
default:
|
default:
|
||||||
let x = targetX - p.worldX, y = targetY - p.worldY;
|
let x = targetX - p.worldX, y = targetY - p.worldY;
|
||||||
let d = pa * pd - pb * pc;
|
let d = pa * pd - pb * pc;
|
||||||
|
if (Math.abs(d) <= 0.0001) {
|
||||||
|
tx = 0;
|
||||||
|
ty = 0;
|
||||||
|
} else {
|
||||||
tx = (x * pd - y * pb) / d - bone.ax;
|
tx = (x * pd - y * pb) / d - bone.ax;
|
||||||
ty = (y * pa - x * pc) / d - bone.ay;
|
ty = (y * pa - x * pc) / d - bone.ay;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
rotationIK += Math.atan2(ty, tx) * MathUtils.radDeg;
|
rotationIK += Math.atan2(ty, tx) * MathUtils.radDeg;
|
||||||
if (bone.ascaleX < 0) rotationIK += 180;
|
if (bone.ascaleX < 0) rotationIK += 180;
|
||||||
if (rotationIK > 180)
|
if (rotationIK > 180)
|
||||||
@ -194,7 +199,8 @@ export class IkConstraint implements Updatable {
|
|||||||
b = pp.b;
|
b = pp.b;
|
||||||
c = pp.c;
|
c = pp.c;
|
||||||
d = pp.d;
|
d = pp.d;
|
||||||
let id = 1 / (a * d - b * c), x = cwx - pp.worldX, y = cwy - pp.worldY;
|
let id = a * d - b * c, x = cwx - pp.worldX, y = cwy - pp.worldY;
|
||||||
|
id = Math.abs(id) <= 0.0001 ? 0 : 1 / id;
|
||||||
let dx = (x * d - y * b) * id - px, dy = (y * a - x * c) * id - py;
|
let dx = (x * d - y * b) * id - px, dy = (y * a - x * c) * id - py;
|
||||||
let l1 = Math.sqrt(dx * dx + dy * dy), l2 = child.data.length * csx, a1, a2;
|
let l1 = Math.sqrt(dx * dx + dy * dy), l2 = child.data.length * csx, a1, a2;
|
||||||
if (l1 < 0.0001) {
|
if (l1 < 0.0001) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user