[haxe] Port of 139fd84 and 20d5ee6: Add support to skeletons exported with per-skin atlases.

This commit is contained in:
Davide Tantillo 2025-10-15 09:21:11 +02:00
parent 9ae1af6622
commit 54068d9d12
2 changed files with 10 additions and 8 deletions

View File

@ -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;

View File

@ -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;
}