mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2025-12-20 17:26:01 +08:00
[haxe] Port of 139fd84 and 20d5ee6: Add support to skeletons exported with per-skin atlases.
This commit is contained in:
parent
9ae1af6622
commit
54068d9d12
@ -598,7 +598,7 @@ class SkeletonBinary {
|
|||||||
region.height = height * scale;
|
region.height = height * scale;
|
||||||
region.color.setFromRgba8888(color);
|
region.color.setFromRgba8888(color);
|
||||||
region.sequence = sequence;
|
region.sequence = sequence;
|
||||||
if (sequence == null)
|
if (region.region == null)
|
||||||
region.updateRegion();
|
region.updateRegion();
|
||||||
return region;
|
return region;
|
||||||
case AttachmentType.boundingbox:
|
case AttachmentType.boundingbox:
|
||||||
@ -643,7 +643,7 @@ class SkeletonBinary {
|
|||||||
mesh.worldVerticesLength = vertices.length;
|
mesh.worldVerticesLength = vertices.length;
|
||||||
mesh.triangles = triangles;
|
mesh.triangles = triangles;
|
||||||
mesh.regionUVs = uvs;
|
mesh.regionUVs = uvs;
|
||||||
if (sequence == null)
|
if (mesh.region == null)
|
||||||
mesh.updateRegion();
|
mesh.updateRegion();
|
||||||
mesh.hullLength = hullLength << 1;
|
mesh.hullLength = hullLength << 1;
|
||||||
mesh.sequence = sequence;
|
mesh.sequence = sequence;
|
||||||
|
|||||||
@ -40,21 +40,23 @@ import spine.Skin;
|
|||||||
class AtlasAttachmentLoader implements AttachmentLoader {
|
class AtlasAttachmentLoader implements AttachmentLoader {
|
||||||
private var atlas:TextureAtlas;
|
private var atlas:TextureAtlas;
|
||||||
|
|
||||||
public function new(atlas:TextureAtlas) {
|
public var allowMissingRegions:Bool;
|
||||||
|
|
||||||
|
public function new(atlas:TextureAtlas, allowMissingRegions = false) {
|
||||||
if (atlas == null) {
|
if (atlas == null) {
|
||||||
throw new SpineException("atlas cannot be null.");
|
throw new SpineException("atlas cannot be null.");
|
||||||
}
|
}
|
||||||
this.atlas = atlas;
|
this.atlas = atlas;
|
||||||
|
this.allowMissingRegions = allowMissingRegions;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function loadSequence(name:String, basePath:String, sequence:Sequence) {
|
private function loadSequence(name:String, basePath:String, sequence:Sequence) {
|
||||||
var regions = sequence.regions;
|
var regions = sequence.regions;
|
||||||
for (i in 0...regions.length) {
|
for (i in 0...regions.length) {
|
||||||
var path = sequence.getPath(basePath, i);
|
var path = sequence.getPath(basePath, i);
|
||||||
var region = this.atlas.findRegion(path);
|
regions[i] = this.atlas.findRegion(path);
|
||||||
if (region == null)
|
if (regions[i] == null)
|
||||||
throw new SpineException("Region not found in atlas: " + path + " (sequence: " + name + ")");
|
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);
|
this.loadSequence(name, path, sequence);
|
||||||
} else {
|
} else {
|
||||||
var region = this.atlas.findRegion(path);
|
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 + ")");
|
throw new SpineException("Region not found in atlas: " + path + " (region attachment: " + name + ")");
|
||||||
attachment.region = region;
|
attachment.region = region;
|
||||||
}
|
}
|
||||||
@ -83,7 +85,7 @@ class AtlasAttachmentLoader implements AttachmentLoader {
|
|||||||
this.loadSequence(name, path, sequence);
|
this.loadSequence(name, path, sequence);
|
||||||
} else {
|
} else {
|
||||||
var region = atlas.findRegion(path);
|
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 + ")");
|
throw new SpineException("Region not found in atlas: " + path + " (mesh attachment: " + name + ")");
|
||||||
attachment.region = region;
|
attachment.region = region;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user