From 54068d9d12a1d31959b0259eea04a4831b72a30d Mon Sep 17 00:00:00 2001 From: Davide Tantillo Date: Wed, 15 Oct 2025 09:21:11 +0200 Subject: [PATCH] [haxe] Port of 139fd84 and 20d5ee6: Add support to skeletons exported with per-skin atlases. --- spine-haxe/spine-haxe/spine/SkeletonBinary.hx | 4 ++-- .../spine/attachments/AtlasAttachmentLoader.hx | 14 ++++++++------ 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/spine-haxe/spine-haxe/spine/SkeletonBinary.hx b/spine-haxe/spine-haxe/spine/SkeletonBinary.hx index 3e0acc648..f92b5d829 100644 --- a/spine-haxe/spine-haxe/spine/SkeletonBinary.hx +++ b/spine-haxe/spine-haxe/spine/SkeletonBinary.hx @@ -598,7 +598,7 @@ class SkeletonBinary { region.height = height * scale; region.color.setFromRgba8888(color); region.sequence = sequence; - if (sequence == null) + if (region.region == null) region.updateRegion(); return region; case AttachmentType.boundingbox: @@ -643,7 +643,7 @@ class SkeletonBinary { mesh.worldVerticesLength = vertices.length; mesh.triangles = triangles; mesh.regionUVs = uvs; - if (sequence == null) + if (mesh.region == null) mesh.updateRegion(); mesh.hullLength = hullLength << 1; mesh.sequence = sequence; diff --git a/spine-haxe/spine-haxe/spine/attachments/AtlasAttachmentLoader.hx b/spine-haxe/spine-haxe/spine/attachments/AtlasAttachmentLoader.hx index 047c37924..1bcb058d1 100644 --- a/spine-haxe/spine-haxe/spine/attachments/AtlasAttachmentLoader.hx +++ b/spine-haxe/spine-haxe/spine/attachments/AtlasAttachmentLoader.hx @@ -40,21 +40,23 @@ import spine.Skin; class AtlasAttachmentLoader implements AttachmentLoader { private var atlas:TextureAtlas; - public function new(atlas:TextureAtlas) { + public var allowMissingRegions:Bool; + + public function new(atlas:TextureAtlas, allowMissingRegions = false) { if (atlas == null) { throw new SpineException("atlas cannot be null."); } this.atlas = atlas; + this.allowMissingRegions = allowMissingRegions; } private function loadSequence(name:String, basePath:String, sequence:Sequence) { var regions = sequence.regions; for (i in 0...regions.length) { var path = sequence.getPath(basePath, i); - var region = this.atlas.findRegion(path); - if (region == null) + regions[i] = this.atlas.findRegion(path); + if (regions[i] == null) throw new SpineException("Region not found in atlas: " + path + " (sequence: " + name + ")"); - regions[i] = region; } } @@ -67,7 +69,7 @@ class AtlasAttachmentLoader implements AttachmentLoader { this.loadSequence(name, path, sequence); } else { var region = this.atlas.findRegion(path); - if (region == null) + if (region == null && !this.allowMissingRegions) throw new SpineException("Region not found in atlas: " + path + " (region attachment: " + name + ")"); attachment.region = region; } @@ -83,7 +85,7 @@ class AtlasAttachmentLoader implements AttachmentLoader { this.loadSequence(name, path, sequence); } else { var region = atlas.findRegion(path); - if (region == null) + if (region == null && !this.allowMissingRegions) throw new SpineException("Region not found in atlas: " + path + " (mesh attachment: " + name + ")"); attachment.region = region; }