From 1b1f76d93ce2e9bd87c34ab67559020d5768da9a Mon Sep 17 00:00:00 2001 From: Rich Date: Fri, 5 Apr 2019 18:16:33 +0100 Subject: [PATCH 1/3] handle a spine event callback potentially destroying the spine while updating --- src/Spine.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Spine.ts b/src/Spine.ts index 9feff05c..56e17258 100644 --- a/src/Spine.ts +++ b/src/Spine.ts @@ -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; From b02464834c2846195b0f9f629b16ace145800312 Mon Sep 17 00:00:00 2001 From: Rich Date: Fri, 5 Apr 2019 18:20:19 +0100 Subject: [PATCH 2/3] revert 1.5.21 changes, root rotation fix, remove disable inherit scale fix (causing unwanted flipping in noScale bones) --- src/core/Bone.ts | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/src/core/Bone.ts b/src/core/Bone.ts index 03b56a08..92541303 100644 --- a/src/core/Bone.ts +++ b/src/core/Bone.ts @@ -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; @@ -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; } @@ -186,10 +185,6 @@ namespace pixi_spine.core { 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; @@ -201,11 +196,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() { From faf9fbfa379cbbccd03fe332ccb8b57a1f14e9c7 Mon Sep 17 00:00:00 2001 From: Rich Date: Fri, 5 Apr 2019 20:27:46 +0100 Subject: [PATCH 3/3] tweaked 'disable inherit scale' check --- src/core/Bone.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/core/Bone.ts b/src/core/Bone.ts index 92541303..5a5fe052 100644 --- a/src/core/Bone.ts +++ b/src/core/Bone.ts @@ -178,6 +178,12 @@ 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;