From eacb9221407f0f7f51e5c6dd43d108f44e3ee94c Mon Sep 17 00:00:00 2001 From: Davide Tantillo Date: Tue, 15 Jul 2025 09:54:41 +0200 Subject: [PATCH] [haxe] 4.3 porting (a012479f, 92723279). --- spine-haxe/spine-haxe/spine/BonePose.hx | 22 ++++++++--------- .../spine/attachments/RegionAttachment.hx | 24 ++++++++----------- 2 files changed, 20 insertions(+), 26 deletions(-) diff --git a/spine-haxe/spine-haxe/spine/BonePose.hx b/spine-haxe/spine-haxe/spine/BonePose.hx index 881ce4eb3..8bde03c36 100644 --- a/spine-haxe/spine-haxe/spine/BonePose.hx +++ b/spine-haxe/spine-haxe/spine/BonePose.hx @@ -139,9 +139,7 @@ class BonePose extends BoneLocal implements Update { c = pc * la + pd * lc; d = pc * lb + pd * ld; case Inherit.noScale, Inherit.noScaleOrReflection: - rotation *= MathUtils.degRad; - var cos = Math.cos(rotation); - var sin = Math.sin(rotation); + var r = rotation * MathUtils.degRad, cos = Math.cos(r), sin = Math.sin(r); var za = (pa * cos + pb * sin) / skeleton.scaleX; var zc = (pc * cos + pd * sin) / skeleton.scaleY; var s = Math.sqrt(za * za + zc * zc); @@ -150,15 +148,15 @@ class BonePose extends BoneLocal implements Update { zc *= s; s = Math.sqrt(za * za + zc * zc); if (inherit == Inherit.noScale && ((pa * pd - pb * pc < 0) != ((skeleton.scaleX < 0) != (skeleton.scaleY < 0)))) s = -s; - rotation = Math.PI / 2 + Math.atan2(zc, za); - var zb:Float = Math.cos(rotation) * s; - var zd:Float = Math.sin(rotation) * s; - shearX *= MathUtils.degRad; - shearY = (90 + shearY) * MathUtils.degRad; - var la = Math.cos(shearX) * scaleX; - var lb = Math.cos(shearY) * scaleY; - var lc = Math.sin(shearX) * scaleX; - var ld = Math.sin(shearY) * scaleY; + r = Math.PI / 2 + Math.atan2(zc, za); + var zb:Float = Math.cos(r) * s; + var zd:Float = Math.sin(r) * s; + var rx = MathUtils.degRad; + var ry = (90 + shearY) * MathUtils.degRad; + var la = Math.cos(rx) * scaleX; + var lb = Math.cos(ry) * scaleY; + var lc = Math.sin(rx) * scaleX; + var ld = Math.sin(ry) * scaleY; a = za * la + zb * lc; b = za * lb + zb * ld; c = zc * la + zd * lc; diff --git a/spine-haxe/spine-haxe/spine/attachments/RegionAttachment.hx b/spine-haxe/spine-haxe/spine/attachments/RegionAttachment.hx index 331312865..cb1a867e1 100644 --- a/spine-haxe/spine-haxe/spine/attachments/RegionAttachment.hx +++ b/spine-haxe/spine-haxe/spine/attachments/RegionAttachment.hx @@ -84,19 +84,6 @@ class RegionAttachment extends Attachment implements HasTextureRegion { /** Calculates the RegionAttachment.offsets and RegionAttachment.uvs using the region and the attachment's transform. Must be called if the * region, the region's properties, or the transform are changed. */ public function updateRegion():Void { - if (region == null) { - throw new SpineException("Region not set."); - uvs[0] = 0; - uvs[1] = 0; - uvs[2] = 0; - uvs[3] = 1; - uvs[4] = 1; - uvs[5] = 1; - uvs[6] = 1; - uvs[7] = 0; - return; - } - var regionScaleX = width / region.originalWidth * scaleX; var regionScaleY = height / region.originalHeight * scaleY; var localX = -width / 2 * scaleX + region.offsetX * regionScaleX; @@ -125,7 +112,16 @@ class RegionAttachment extends Attachment implements HasTextureRegion { offset[6] = localX2Cos - localYSin; offset[7] = localYCos + localX2Sin; - if (region.degrees == 90) { + if (region == null) { + uvs[0] = 0; + uvs[1] = 0; + uvs[2] = 0; + uvs[3] = 1; + uvs[4] = 1; + uvs[5] = 1; + uvs[6] = 1; + uvs[7] = 0; + } else if (region.degrees == 90) { uvs[0] = region.u2; uvs[1] = region.v2; uvs[2] = region.u;