Skip to content

Commit

Permalink
Merge pull request #292 from rich-earth/master
Browse files Browse the repository at this point in the history
fix #290
  • Loading branch information
ivanpopelyshev authored Apr 8, 2019
2 parents 7ccbd1d + faf9fbf commit 78172c2
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 15 deletions.
5 changes: 5 additions & 0 deletions src/Spine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,11 @@ namespace pixi_spine {

this.state.update(dt);
this.state.apply(this.skeleton);

//check we haven't been destroyed via a spine event callback in state update
if(!this.skeleton)
return;

this.skeleton.updateWorldTransform();

let slots = this.skeleton.slots;
Expand Down
26 changes: 11 additions & 15 deletions src/core/Bone.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,13 @@ namespace pixi_spine.core {
let m = this.matrix;

let sx = this.skeleton.scaleX;
let sy = this.skeleton.scaleY;
let sy = Bone.yDown? -this.skeleton.scaleY : this.skeleton.scaleY;

if (parent == null) { // Root bone.
if(Bone.yDown){
rotation = -rotation;
this.arotation = rotation;
}
let skeleton = this.skeleton;
let rotationY = rotation + 90 + shearY;
m.a = MathUtils.cosDeg(rotation + shearX) * scaleX * sx;
Expand All @@ -111,11 +115,6 @@ namespace pixi_spine.core {
m.d = MathUtils.sinDeg(rotationY) * scaleY * sy;
m.tx = x * sx + skeleton.x;
m.ty = y * sy + skeleton.y;

if (Bone.yDown) {
m.b = -m.b;
m.d = -m.d;
}
return;
}

Expand Down Expand Up @@ -179,17 +178,19 @@ namespace pixi_spine.core {
za *= s;
zc *= s;
s = Math.sqrt(za * za + zc * zc);
if (
this.data.transformMode == TransformMode.NoScale
&& (pa * pd - pb * pc < 0) != (Bone.yDown?
(this.skeleton.scaleX < 0 != this.skeleton.scaleY > 0) :
(this.skeleton.scaleX < 0 != this.skeleton.scaleY < 0))
) s = -s;
let r = Math.PI / 2 + Math.atan2(zc, za);
let zb = Math.cos(r) * s;
let zd = Math.sin(r) * s;
let la = MathUtils.cosDeg(shearX) * scaleX;
let lb = MathUtils.cosDeg(90 + shearY) * scaleY;
let lc = MathUtils.sinDeg(shearX) * scaleX;
let ld = MathUtils.sinDeg(90 + shearY) * scaleY;
if (this.data.transformMode != core.TransformMode.NoScaleOrReflection ? pa * pd - pb * pc < 0 : ((this.skeleton.flipX != this.skeleton.flipY) != Bone.yDown)) {
zb = -zb;
zd = -zd;
}
m.a = za * la + zb * lc;
m.c = za * lb + zb * ld;
m.b = zc * la + zd * lc;
Expand All @@ -201,11 +202,6 @@ namespace pixi_spine.core {
m.c *= sx;
m.b *= sy;
m.d *= sy;

if (Bone.yDown) {
m.b = -m.b;
m.d = -m.d;
}
}

setToSetupPose() {
Expand Down

0 comments on commit 78172c2

Please sign in to comment.