From 6927995767897474434c8a0c531176061ef4be7f Mon Sep 17 00:00:00 2001 From: Davide Tantillo Date: Tue, 29 Jul 2025 18:05:18 +0200 Subject: [PATCH] [haxe] Removed lime dependency from Skeleton.hx --- spine-haxe/spine-haxe/spine/Skeleton.hx | 4 +-- .../spine-haxe/spine/flixel/SkeletonSprite.hx | 20 ++++++------ .../spine/starling/SkeletonSprite.hx | 31 +++++++++++-------- 3 files changed, 30 insertions(+), 25 deletions(-) diff --git a/spine-haxe/spine-haxe/spine/Skeleton.hx b/spine-haxe/spine-haxe/spine/Skeleton.hx index 8e4a4a93c..b40a8dde9 100644 --- a/spine-haxe/spine-haxe/spine/Skeleton.hx +++ b/spine-haxe/spine-haxe/spine/Skeleton.hx @@ -29,12 +29,10 @@ package spine; -import lime.math.Rectangle; -import haxe.ds.StringMap; +import spine.Rectangle; import spine.attachments.Attachment; import spine.attachments.ClippingAttachment; import spine.attachments.MeshAttachment; -import spine.attachments.PathAttachment; import spine.attachments.RegionAttachment; /** Stores the current pose for a skeleton. diff --git a/spine-haxe/spine-haxe/spine/flixel/SkeletonSprite.hx b/spine-haxe/spine-haxe/spine/flixel/SkeletonSprite.hx index 7ee805b57..e75fe107e 100644 --- a/spine-haxe/spine-haxe/spine/flixel/SkeletonSprite.hx +++ b/spine-haxe/spine-haxe/spine/flixel/SkeletonSprite.hx @@ -51,6 +51,7 @@ import flixel.util.FlxColor; import openfl.Vector; import openfl.display.BlendMode; import spine.Bone; +import spine.Rectangle; import spine.Skeleton; import spine.SkeletonData; import spine.Slot; @@ -114,7 +115,7 @@ class SkeletonSprite extends FlxObject { } } - public function getAnimationBounds(animation:Animation, clip:Bool = true):lime.math.Rectangle { + public function getAnimationBounds(animation:Animation, clip:Bool = true):Rectangle { var clipper = clip ? SkeletonSprite.clipper : null; skeleton.setupPose(); @@ -125,22 +126,23 @@ class SkeletonSprite extends FlxObject { minY = 100000000., maxY = -100000000.; - var bounds = new lime.math.Rectangle(); for (i in 0...steps) { animation.apply(skeleton, time, time, false, [], 1, MixBlend.setup, MixDirection.mixIn, false); skeleton.updateWorldTransform(Physics.update); - bounds = skeleton.getBounds(clipper); + var boundsSkel = skeleton.getBounds(clipper); - if (!Math.isNaN(bounds.x) && !Math.isNaN(bounds.y) && !Math.isNaN(bounds.width) && !Math.isNaN(bounds.height)) { - minX = Math.min(bounds.x, minX); - minY = Math.min(bounds.y, minY); - maxX = Math.max(bounds.right, maxX); - maxY = Math.max(bounds.bottom, maxY); + if (!Math.isNaN(boundsSkel.x) && !Math.isNaN(boundsSkel.y) && !Math.isNaN(boundsSkel.width) && !Math.isNaN(boundsSkel.height)) { + minX = Math.min(boundsSkel.x, minX); + minY = Math.min(boundsSkel.y, minY); + maxX = Math.max(boundsSkel.x + boundsSkel.width, maxX); + maxY = Math.max(boundsSkel.y + boundsSkel.height, maxY); } else - trace("ERROR"); + throw new SpineException("Animation bounds are invalid: " + animation.name); time += stepTime; } + + var bounds = new Rectangle(); bounds.x = minX; bounds.y = minY; bounds.width = maxX - minX; diff --git a/spine-haxe/spine-haxe/spine/starling/SkeletonSprite.hx b/spine-haxe/spine-haxe/spine/starling/SkeletonSprite.hx index 0cffae9b2..f0e9b3f70 100644 --- a/spine-haxe/spine-haxe/spine/starling/SkeletonSprite.hx +++ b/spine-haxe/spine-haxe/spine/starling/SkeletonSprite.hx @@ -33,8 +33,9 @@ import spine.animation.Animation; import starling.animation.IAnimatable; import openfl.geom.Matrix; import openfl.geom.Point; -import openfl.geom.Rectangle; +import openfl.geom.Rectangle as OpenFlRectangle; import spine.Bone; +import spine.Rectangle; import spine.Skeleton; import spine.SkeletonClipping; import spine.SkeletonData; @@ -43,7 +44,6 @@ import spine.animation.AnimationState; import spine.animation.AnimationStateData; import spine.animation.MixBlend; import spine.animation.MixDirection; -import spine.attachments.Attachment; import spine.attachments.ClippingAttachment; import spine.attachments.MeshAttachment; import spine.attachments.RegionAttachment; @@ -308,9 +308,9 @@ class SkeletonSprite extends DisplayObject implements IAnimatable { return null; } - override public function getBounds(targetSpace:DisplayObject, resultRect:Rectangle = null):Rectangle { + override public function getBounds(targetSpace:DisplayObject, resultRect:OpenFlRectangle = null):OpenFlRectangle { if (resultRect == null) { - resultRect = new Rectangle(); + resultRect = new OpenFlRectangle(); } if (targetSpace == this) { resultRect.setTo(0, 0, 0, 0); @@ -335,23 +335,28 @@ class SkeletonSprite extends DisplayObject implements IAnimatable { minY = 100000000., maxY = -100000000.; - var bound:lime.math.Rectangle; for (i in 0...steps) { animation.apply(_skeleton, time, time, false, [], 1, MixBlend.setup, MixDirection.mixIn, false); _skeleton.updateWorldTransform(Physics.update); - bound = _skeleton.getBounds(clipper); + var boundsSkel = _skeleton.getBounds(clipper); - if (!Math.isNaN(bound.x) && !Math.isNaN(bound.y) && !Math.isNaN(bound.width) && !Math.isNaN(bound.height)) { - minX = Math.min(bound.x, minX); - minY = Math.min(bound.y, minY); - maxX = Math.max(bound.right, maxX); - maxY = Math.max(bound.bottom, maxY); + if (!Math.isNaN(boundsSkel.x) && !Math.isNaN(boundsSkel.y) && !Math.isNaN(boundsSkel.width) && !Math.isNaN(boundsSkel.height)) { + minX = Math.min(boundsSkel.x, minX); + minY = Math.min(boundsSkel.y, minY); + maxX = Math.max(boundsSkel.x + boundsSkel.width, maxX); + maxY = Math.max(boundsSkel.y + boundsSkel.height, maxY); } else - trace("ERROR"); + throw new SpineException("Animation bounds are invalid: " + animation.name); time += stepTime; } - return new Rectangle(minX, minY, maxX - minX, maxY - minY); + + var bounds = new Rectangle(); + bounds.x = minX; + bounds.y = minY; + bounds.width = maxX - minX; + bounds.height = maxY - minY; + return bounds; } public var skeleton(get, never):Skeleton;