mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2025-12-21 09:46:02 +08:00
[cpp] Fixed bone disable inherit scale/reflection, see #2888
This commit is contained in:
parent
ed58364b51
commit
d3c0e7ad66
@ -122,25 +122,24 @@ void BonePose::updateWorldTransform(Skeleton &skeleton) {
|
|||||||
}
|
}
|
||||||
case Inherit_NoScale:
|
case Inherit_NoScale:
|
||||||
case Inherit_NoScaleOrReflection: {
|
case Inherit_NoScaleOrReflection: {
|
||||||
float rot = _rotation * MathUtil::Deg_Rad;
|
float r = _rotation * MathUtil::Deg_Rad, cosR = MathUtil::cos(r), sinR = MathUtil::sin(r);
|
||||||
float cosRot = MathUtil::cos(rot), sinRot = MathUtil::sin(rot);
|
float za = (pa * cosR + pb * sinR) / skeleton.getScaleX();
|
||||||
float za = (pa * cosRot + pb * sinRot) / skeleton.getScaleX();
|
float zc = (pc * cosR + pd * sinR) / skeleton.getScaleY();
|
||||||
float zc = (pc * cosRot + pd * sinRot) / skeleton.getScaleY();
|
|
||||||
float s = MathUtil::sqrt(za * za + zc * zc);
|
float s = MathUtil::sqrt(za * za + zc * zc);
|
||||||
if (s > 0.00001f) s = 1 / s;
|
if (s > 0.00001f) s = 1 / s;
|
||||||
za *= s;
|
za *= s;
|
||||||
zc *= s;
|
zc *= s;
|
||||||
s = MathUtil::sqrt(za * za + zc * zc);
|
s = MathUtil::sqrt(za * za + zc * zc);
|
||||||
if (_inherit == Inherit_NoScale && (pa * pd - pb * pc < 0) != (skeleton.getScaleX() < 0 != skeleton.getScaleY() < 0)) s = -s;
|
if (_inherit == Inherit_NoScale && (pa * pd - pb * pc < 0) != (skeleton.getScaleX() < 0 != skeleton.getScaleY() < 0)) s = -s;
|
||||||
rot = MathUtil::Pi / 2 + MathUtil::atan2(zc, za);
|
r = MathUtil::Pi / 2 + MathUtil::atan2(zc, za);
|
||||||
float zb = MathUtil::cos(rot) * s;
|
float zb = MathUtil::cos(r) * s;
|
||||||
float zd = MathUtil::sin(rot) * s;
|
float zd = MathUtil::sin(r) * s;
|
||||||
float _shearXRad = _shearX * MathUtil::Deg_Rad;
|
float rx = _shearX * MathUtil::Deg_Rad;
|
||||||
float _shearYRad = (90 + _shearY) * MathUtil::Deg_Rad;
|
float ry = (90 + _shearY) * MathUtil::Deg_Rad;
|
||||||
float la = MathUtil::cos(_shearXRad) * _scaleX;
|
float la = MathUtil::cos(rx) * _scaleX;
|
||||||
float lb = MathUtil::cos(_shearYRad) * _scaleY;
|
float lb = MathUtil::cos(ry) * _scaleY;
|
||||||
float lc = MathUtil::sin(_shearXRad) * _scaleX;
|
float lc = MathUtil::sin(rx) * _scaleX;
|
||||||
float ld = MathUtil::sin(_shearYRad) * _scaleY;
|
float ld = MathUtil::sin(ry) * _scaleY;
|
||||||
_a = za * la + zb * lc;
|
_a = za * la + zb * lc;
|
||||||
_b = za * lb + zb * ld;
|
_b = za * lb + zb * ld;
|
||||||
_c = zc * la + zd * lc;
|
_c = zc * la + zd * lc;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user