Problem statement
1) I tried to load a .skel file with spine-c, 2) I'd expect it to be loaded and play like it does with the java runtime, and 3) It failed with
Region not found: empty
Runtime information
My program is built with spine-c tagged 4.1 from github, and I tested the java runtime by building the skeleton viewer from the same revision.
I also tested with SkeletonViewer 4.1.24 jar from the site, the asset loads and plays.
It appears with the Java Runtime, findRegion will return a fake
AtlasRegion
, when it failed to find the region with a given name, therefore RuntimeException("Region not found in atlas... will never be thrown by the loader.
Whereas with spine-c, it'll set the error message "Region not found: <name>" and abort loading.
Why is the difference? Is it a mistake/bug or by design? If it's by design then it's a bug in design which makes the SkeletonViewer quite useless as a tool for reference.
public AtlasRegion findRegion (String name) {
AtlasRegion region = super.findRegion(name);
if (region == null) {
// Look for separate image file.
FileHandle file = viewer.skeletonFile.sibling(name + ".png");
if (file.exists()) {
Texture texture = new Texture(file);
texture.setFilter(TextureFilter.Linear, TextureFilter.Linear);
region = new AtlasRegion(texture, 0, 0, texture.getWidth(), texture.getHeight());
region.name = name;
}
}
return region != null ? region : fake;
}
...
AtlasRegion region = atlas.findRegion(path);
if (region == null)
throw new RuntimeException("Region not found in atlas: " + path + " (region attachment: " + name + ")"); // It never throws!?
attachment.setRegion(region);
spAtlasRegion *spAtlas_findRegion(const spAtlas *self, const char *name) {
spAtlasRegion *region = self->regions;
while (region) {
if (strcmp(region->name, name) == 0) return region;
region = region->next;
}
return 0;
}
spAttachment *_spAtlasAttachmentLoader_createAttachment( ...
spAtlasRegion *region = spAtlas_findRegion(self->atlas, path);
if (!region) {
spAttachment_dispose(SUPER(attachment));
_spAttachmentLoader_setError(loader, "Region not found: ", path);
return 0;
}