mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2025-12-22 02:06:03 +08:00
Merge branch '4.1' into 4.2-beta
This commit is contained in:
commit
4a66ced952
@ -1354,220 +1354,221 @@ spSkeletonData *spSkeletonJson_readSkeletonData(spSkeletonJson *self, const char
|
|||||||
skeletonData->skins[skeletonData->skinsCount++] = skin;
|
skeletonData->skins[skeletonData->skinsCount++] = skin;
|
||||||
if (strcmp(skin->name, "default") == 0) skeletonData->defaultSkin = skin;
|
if (strcmp(skin->name, "default") == 0) skeletonData->defaultSkin = skin;
|
||||||
|
|
||||||
for (attachmentsMap = Json_getItem(skinMap,
|
skinPart = Json_getItem(skinMap, "attachments");
|
||||||
"attachments")
|
if (skinPart) {
|
||||||
->child;
|
for (attachmentsMap = skinPart->child; attachmentsMap; attachmentsMap = attachmentsMap->next) {
|
||||||
attachmentsMap; attachmentsMap = attachmentsMap->next) {
|
spSlotData *slot = spSkeletonData_findSlot(skeletonData, attachmentsMap->name);
|
||||||
spSlotData *slot = spSkeletonData_findSlot(skeletonData, attachmentsMap->name);
|
Json *attachmentMap;
|
||||||
Json *attachmentMap;
|
|
||||||
|
|
||||||
for (attachmentMap = attachmentsMap->child; attachmentMap; attachmentMap = attachmentMap->next) {
|
for (attachmentMap = attachmentsMap->child; attachmentMap; attachmentMap = attachmentMap->next) {
|
||||||
spAttachment *attachment;
|
spAttachment *attachment;
|
||||||
const char *skinAttachmentName = attachmentMap->name;
|
const char *skinAttachmentName = attachmentMap->name;
|
||||||
const char *attachmentName = Json_getString(attachmentMap, "name", skinAttachmentName);
|
const char *attachmentName = Json_getString(attachmentMap, "name", skinAttachmentName);
|
||||||
const char *path = Json_getString(attachmentMap, "path", attachmentName);
|
const char *path = Json_getString(attachmentMap, "path", attachmentName);
|
||||||
const char *color;
|
const char *color;
|
||||||
Json *entry;
|
Json *entry;
|
||||||
spSequence *sequence;
|
spSequence *sequence;
|
||||||
|
|
||||||
const char *typeString = Json_getString(attachmentMap, "type", "region");
|
const char *typeString = Json_getString(attachmentMap, "type", "region");
|
||||||
spAttachmentType type;
|
spAttachmentType type;
|
||||||
if (strcmp(typeString, "region") == 0) type = SP_ATTACHMENT_REGION;
|
if (strcmp(typeString, "region") == 0) type = SP_ATTACHMENT_REGION;
|
||||||
else if (strcmp(typeString, "mesh") == 0)
|
else if (strcmp(typeString, "mesh") == 0)
|
||||||
type = SP_ATTACHMENT_MESH;
|
type = SP_ATTACHMENT_MESH;
|
||||||
else if (strcmp(typeString, "linkedmesh") == 0)
|
else if (strcmp(typeString, "linkedmesh") == 0)
|
||||||
type = SP_ATTACHMENT_LINKED_MESH;
|
type = SP_ATTACHMENT_LINKED_MESH;
|
||||||
else if (strcmp(typeString, "boundingbox") == 0)
|
else if (strcmp(typeString, "boundingbox") == 0)
|
||||||
type = SP_ATTACHMENT_BOUNDING_BOX;
|
type = SP_ATTACHMENT_BOUNDING_BOX;
|
||||||
else if (strcmp(typeString, "path") == 0)
|
else if (strcmp(typeString, "path") == 0)
|
||||||
type = SP_ATTACHMENT_PATH;
|
type = SP_ATTACHMENT_PATH;
|
||||||
else if (strcmp(typeString, "clipping") == 0)
|
else if (strcmp(typeString, "clipping") == 0)
|
||||||
type = SP_ATTACHMENT_CLIPPING;
|
type = SP_ATTACHMENT_CLIPPING;
|
||||||
else if (strcmp(typeString, "point") == 0)
|
else if (strcmp(typeString, "point") == 0)
|
||||||
type = SP_ATTACHMENT_POINT;
|
type = SP_ATTACHMENT_POINT;
|
||||||
else {
|
else {
|
||||||
spSkeletonData_dispose(skeletonData);
|
|
||||||
_spSkeletonJson_setError(self, root, "Unknown attachment type: ", typeString);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
sequence = readSequence(Json_getItem(attachmentMap, "sequence"));
|
|
||||||
attachment = spAttachmentLoader_createAttachment(self->attachmentLoader, skin, type, attachmentName,
|
|
||||||
path, sequence);
|
|
||||||
if (!attachment) {
|
|
||||||
if (self->attachmentLoader->error1) {
|
|
||||||
spSkeletonData_dispose(skeletonData);
|
spSkeletonData_dispose(skeletonData);
|
||||||
_spSkeletonJson_setError(self, root, self->attachmentLoader->error1,
|
_spSkeletonJson_setError(self, root, "Unknown attachment type: ", typeString);
|
||||||
self->attachmentLoader->error2);
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (attachment->type) {
|
sequence = readSequence(Json_getItem(attachmentMap, "sequence"));
|
||||||
case SP_ATTACHMENT_REGION: {
|
attachment = spAttachmentLoader_createAttachment(self->attachmentLoader, skin, type,
|
||||||
spRegionAttachment *region = SUB_CAST(spRegionAttachment, attachment);
|
attachmentName,
|
||||||
if (path) MALLOC_STR(region->path, path);
|
path, sequence);
|
||||||
region->x = Json_getFloat(attachmentMap, "x", 0) * self->scale;
|
if (!attachment) {
|
||||||
region->y = Json_getFloat(attachmentMap, "y", 0) * self->scale;
|
if (self->attachmentLoader->error1) {
|
||||||
region->scaleX = Json_getFloat(attachmentMap, "scaleX", 1);
|
spSkeletonData_dispose(skeletonData);
|
||||||
region->scaleY = Json_getFloat(attachmentMap, "scaleY", 1);
|
_spSkeletonJson_setError(self, root, self->attachmentLoader->error1,
|
||||||
region->rotation = Json_getFloat(attachmentMap, "rotation", 0);
|
self->attachmentLoader->error2);
|
||||||
region->width = Json_getFloat(attachmentMap, "width", 32) * self->scale;
|
return NULL;
|
||||||
region->height = Json_getFloat(attachmentMap, "height", 32) * self->scale;
|
|
||||||
region->sequence = sequence;
|
|
||||||
|
|
||||||
color = Json_getString(attachmentMap, "color", 0);
|
|
||||||
if (color) {
|
|
||||||
spColor_setFromFloats(®ion->color,
|
|
||||||
toColor(color, 0),
|
|
||||||
toColor(color, 1),
|
|
||||||
toColor(color, 2),
|
|
||||||
toColor(color, 3));
|
|
||||||
}
|
}
|
||||||
|
continue;
|
||||||
if (region->region != NULL) spRegionAttachment_updateRegion(region);
|
|
||||||
|
|
||||||
spAttachmentLoader_configureAttachment(self->attachmentLoader, attachment);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
case SP_ATTACHMENT_MESH:
|
|
||||||
case SP_ATTACHMENT_LINKED_MESH: {
|
|
||||||
spMeshAttachment *mesh = SUB_CAST(spMeshAttachment, attachment);
|
|
||||||
|
|
||||||
MALLOC_STR(mesh->path, path);
|
switch (attachment->type) {
|
||||||
|
case SP_ATTACHMENT_REGION: {
|
||||||
|
spRegionAttachment *region = SUB_CAST(spRegionAttachment, attachment);
|
||||||
|
if (path) MALLOC_STR(region->path, path);
|
||||||
|
region->x = Json_getFloat(attachmentMap, "x", 0) * self->scale;
|
||||||
|
region->y = Json_getFloat(attachmentMap, "y", 0) * self->scale;
|
||||||
|
region->scaleX = Json_getFloat(attachmentMap, "scaleX", 1);
|
||||||
|
region->scaleY = Json_getFloat(attachmentMap, "scaleY", 1);
|
||||||
|
region->rotation = Json_getFloat(attachmentMap, "rotation", 0);
|
||||||
|
region->width = Json_getFloat(attachmentMap, "width", 32) * self->scale;
|
||||||
|
region->height = Json_getFloat(attachmentMap, "height", 32) * self->scale;
|
||||||
|
region->sequence = sequence;
|
||||||
|
|
||||||
color = Json_getString(attachmentMap, "color", 0);
|
color = Json_getString(attachmentMap, "color", 0);
|
||||||
if (color) {
|
if (color) {
|
||||||
spColor_setFromFloats(&mesh->color,
|
spColor_setFromFloats(®ion->color,
|
||||||
toColor(color, 0),
|
toColor(color, 0),
|
||||||
toColor(color, 1),
|
toColor(color, 1),
|
||||||
toColor(color, 2),
|
toColor(color, 2),
|
||||||
toColor(color, 3));
|
toColor(color, 3));
|
||||||
}
|
|
||||||
|
|
||||||
mesh->width = Json_getFloat(attachmentMap, "width", 32) * self->scale;
|
|
||||||
mesh->height = Json_getFloat(attachmentMap, "height", 32) * self->scale;
|
|
||||||
mesh->sequence = sequence;
|
|
||||||
|
|
||||||
entry = Json_getItem(attachmentMap, "parent");
|
|
||||||
if (!entry) {
|
|
||||||
int verticesLength;
|
|
||||||
entry = Json_getItem(attachmentMap, "triangles");
|
|
||||||
mesh->trianglesCount = entry->size;
|
|
||||||
mesh->triangles = MALLOC(unsigned short, entry->size);
|
|
||||||
for (entry = entry->child, ii = 0; entry; entry = entry->next, ++ii)
|
|
||||||
mesh->triangles[ii] = (unsigned short) entry->valueInt;
|
|
||||||
|
|
||||||
entry = Json_getItem(attachmentMap, "uvs");
|
|
||||||
verticesLength = entry->size;
|
|
||||||
mesh->regionUVs = MALLOC(float, verticesLength);
|
|
||||||
for (entry = entry->child, ii = 0; entry; entry = entry->next, ++ii)
|
|
||||||
mesh->regionUVs[ii] = entry->valueFloat;
|
|
||||||
|
|
||||||
_readVertices(self, attachmentMap, SUPER(mesh), verticesLength);
|
|
||||||
|
|
||||||
if (mesh->region != NULL) spMeshAttachment_updateRegion(mesh);
|
|
||||||
|
|
||||||
mesh->hullLength = Json_getInt(attachmentMap, "hull", 0);
|
|
||||||
|
|
||||||
entry = Json_getItem(attachmentMap, "edges");
|
|
||||||
if (entry) {
|
|
||||||
mesh->edgesCount = entry->size;
|
|
||||||
mesh->edges = MALLOC(int, entry->size);
|
|
||||||
for (entry = entry->child, ii = 0; entry; entry = entry->next, ++ii)
|
|
||||||
mesh->edges[ii] = entry->valueInt;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (region->region != NULL) spRegionAttachment_updateRegion(region);
|
||||||
|
|
||||||
spAttachmentLoader_configureAttachment(self->attachmentLoader, attachment);
|
spAttachmentLoader_configureAttachment(self->attachmentLoader, attachment);
|
||||||
} else {
|
break;
|
||||||
int inheritTimelines = Json_getInt(attachmentMap, "timelines", 1);
|
|
||||||
_spSkeletonJson_addLinkedMesh(self, SUB_CAST(spMeshAttachment, attachment),
|
|
||||||
Json_getString(attachmentMap, "skin", 0), slot->index,
|
|
||||||
entry->valueString, inheritTimelines);
|
|
||||||
}
|
}
|
||||||
break;
|
case SP_ATTACHMENT_MESH:
|
||||||
}
|
case SP_ATTACHMENT_LINKED_MESH: {
|
||||||
case SP_ATTACHMENT_BOUNDING_BOX: {
|
spMeshAttachment *mesh = SUB_CAST(spMeshAttachment, attachment);
|
||||||
spBoundingBoxAttachment *box = SUB_CAST(spBoundingBoxAttachment, attachment);
|
|
||||||
int vertexCount = Json_getInt(attachmentMap, "vertexCount", 0) << 1;
|
|
||||||
_readVertices(self, attachmentMap, SUPER(box), vertexCount);
|
|
||||||
box->super.verticesCount = vertexCount;
|
|
||||||
color = Json_getString(attachmentMap, "color", 0);
|
|
||||||
if (color) {
|
|
||||||
spColor_setFromFloats(&box->color,
|
|
||||||
toColor(color, 0),
|
|
||||||
toColor(color, 1),
|
|
||||||
toColor(color, 2),
|
|
||||||
toColor(color, 3));
|
|
||||||
}
|
|
||||||
spAttachmentLoader_configureAttachment(self->attachmentLoader, attachment);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case SP_ATTACHMENT_PATH: {
|
|
||||||
spPathAttachment *pathAttachment = SUB_CAST(spPathAttachment, attachment);
|
|
||||||
int vertexCount = 0;
|
|
||||||
pathAttachment->closed = Json_getInt(attachmentMap, "closed", 0);
|
|
||||||
pathAttachment->constantSpeed = Json_getInt(attachmentMap, "constantSpeed", 1);
|
|
||||||
vertexCount = Json_getInt(attachmentMap, "vertexCount", 0);
|
|
||||||
_readVertices(self, attachmentMap, SUPER(pathAttachment), vertexCount << 1);
|
|
||||||
|
|
||||||
pathAttachment->lengthsLength = vertexCount / 3;
|
MALLOC_STR(mesh->path, path);
|
||||||
pathAttachment->lengths = MALLOC(float, pathAttachment->lengthsLength);
|
|
||||||
|
|
||||||
curves = Json_getItem(attachmentMap, "lengths");
|
color = Json_getString(attachmentMap, "color", 0);
|
||||||
for (curves = curves->child, ii = 0; curves; curves = curves->next, ++ii)
|
if (color) {
|
||||||
pathAttachment->lengths[ii] = curves->valueFloat * self->scale;
|
spColor_setFromFloats(&mesh->color,
|
||||||
color = Json_getString(attachmentMap, "color", 0);
|
toColor(color, 0),
|
||||||
if (color) {
|
toColor(color, 1),
|
||||||
spColor_setFromFloats(&pathAttachment->color,
|
toColor(color, 2),
|
||||||
toColor(color, 0),
|
toColor(color, 3));
|
||||||
toColor(color, 1),
|
}
|
||||||
toColor(color, 2),
|
|
||||||
toColor(color, 3));
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case SP_ATTACHMENT_POINT: {
|
|
||||||
spPointAttachment *point = SUB_CAST(spPointAttachment, attachment);
|
|
||||||
point->x = Json_getFloat(attachmentMap, "x", 0) * self->scale;
|
|
||||||
point->y = Json_getFloat(attachmentMap, "y", 0) * self->scale;
|
|
||||||
point->rotation = Json_getFloat(attachmentMap, "rotation", 0);
|
|
||||||
|
|
||||||
color = Json_getString(attachmentMap, "color", 0);
|
mesh->width = Json_getFloat(attachmentMap, "width", 32) * self->scale;
|
||||||
if (color) {
|
mesh->height = Json_getFloat(attachmentMap, "height", 32) * self->scale;
|
||||||
spColor_setFromFloats(&point->color,
|
mesh->sequence = sequence;
|
||||||
toColor(color, 0),
|
|
||||||
toColor(color, 1),
|
entry = Json_getItem(attachmentMap, "parent");
|
||||||
toColor(color, 2),
|
if (!entry) {
|
||||||
toColor(color, 3));
|
int verticesLength;
|
||||||
|
entry = Json_getItem(attachmentMap, "triangles");
|
||||||
|
mesh->trianglesCount = entry->size;
|
||||||
|
mesh->triangles = MALLOC(unsigned short, entry->size);
|
||||||
|
for (entry = entry->child, ii = 0; entry; entry = entry->next, ++ii)
|
||||||
|
mesh->triangles[ii] = (unsigned short) entry->valueInt;
|
||||||
|
|
||||||
|
entry = Json_getItem(attachmentMap, "uvs");
|
||||||
|
verticesLength = entry->size;
|
||||||
|
mesh->regionUVs = MALLOC(float, verticesLength);
|
||||||
|
for (entry = entry->child, ii = 0; entry; entry = entry->next, ++ii)
|
||||||
|
mesh->regionUVs[ii] = entry->valueFloat;
|
||||||
|
|
||||||
|
_readVertices(self, attachmentMap, SUPER(mesh), verticesLength);
|
||||||
|
|
||||||
|
if (mesh->region != NULL) spMeshAttachment_updateRegion(mesh);
|
||||||
|
|
||||||
|
mesh->hullLength = Json_getInt(attachmentMap, "hull", 0);
|
||||||
|
|
||||||
|
entry = Json_getItem(attachmentMap, "edges");
|
||||||
|
if (entry) {
|
||||||
|
mesh->edgesCount = entry->size;
|
||||||
|
mesh->edges = MALLOC(int, entry->size);
|
||||||
|
for (entry = entry->child, ii = 0; entry; entry = entry->next, ++ii)
|
||||||
|
mesh->edges[ii] = entry->valueInt;
|
||||||
|
}
|
||||||
|
|
||||||
|
spAttachmentLoader_configureAttachment(self->attachmentLoader, attachment);
|
||||||
|
} else {
|
||||||
|
int inheritTimelines = Json_getInt(attachmentMap, "timelines", 1);
|
||||||
|
_spSkeletonJson_addLinkedMesh(self, SUB_CAST(spMeshAttachment, attachment),
|
||||||
|
Json_getString(attachmentMap, "skin", 0), slot->index,
|
||||||
|
entry->valueString, inheritTimelines);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case SP_ATTACHMENT_BOUNDING_BOX: {
|
||||||
|
spBoundingBoxAttachment *box = SUB_CAST(spBoundingBoxAttachment, attachment);
|
||||||
|
int vertexCount = Json_getInt(attachmentMap, "vertexCount", 0) << 1;
|
||||||
|
_readVertices(self, attachmentMap, SUPER(box), vertexCount);
|
||||||
|
box->super.verticesCount = vertexCount;
|
||||||
|
color = Json_getString(attachmentMap, "color", 0);
|
||||||
|
if (color) {
|
||||||
|
spColor_setFromFloats(&box->color,
|
||||||
|
toColor(color, 0),
|
||||||
|
toColor(color, 1),
|
||||||
|
toColor(color, 2),
|
||||||
|
toColor(color, 3));
|
||||||
|
}
|
||||||
|
spAttachmentLoader_configureAttachment(self->attachmentLoader, attachment);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case SP_ATTACHMENT_PATH: {
|
||||||
|
spPathAttachment *pathAttachment = SUB_CAST(spPathAttachment, attachment);
|
||||||
|
int vertexCount = 0;
|
||||||
|
pathAttachment->closed = Json_getInt(attachmentMap, "closed", 0);
|
||||||
|
pathAttachment->constantSpeed = Json_getInt(attachmentMap, "constantSpeed", 1);
|
||||||
|
vertexCount = Json_getInt(attachmentMap, "vertexCount", 0);
|
||||||
|
_readVertices(self, attachmentMap, SUPER(pathAttachment), vertexCount << 1);
|
||||||
|
|
||||||
|
pathAttachment->lengthsLength = vertexCount / 3;
|
||||||
|
pathAttachment->lengths = MALLOC(float, pathAttachment->lengthsLength);
|
||||||
|
|
||||||
|
curves = Json_getItem(attachmentMap, "lengths");
|
||||||
|
for (curves = curves->child, ii = 0; curves; curves = curves->next, ++ii)
|
||||||
|
pathAttachment->lengths[ii] = curves->valueFloat * self->scale;
|
||||||
|
color = Json_getString(attachmentMap, "color", 0);
|
||||||
|
if (color) {
|
||||||
|
spColor_setFromFloats(&pathAttachment->color,
|
||||||
|
toColor(color, 0),
|
||||||
|
toColor(color, 1),
|
||||||
|
toColor(color, 2),
|
||||||
|
toColor(color, 3));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case SP_ATTACHMENT_POINT: {
|
||||||
|
spPointAttachment *point = SUB_CAST(spPointAttachment, attachment);
|
||||||
|
point->x = Json_getFloat(attachmentMap, "x", 0) * self->scale;
|
||||||
|
point->y = Json_getFloat(attachmentMap, "y", 0) * self->scale;
|
||||||
|
point->rotation = Json_getFloat(attachmentMap, "rotation", 0);
|
||||||
|
|
||||||
|
color = Json_getString(attachmentMap, "color", 0);
|
||||||
|
if (color) {
|
||||||
|
spColor_setFromFloats(&point->color,
|
||||||
|
toColor(color, 0),
|
||||||
|
toColor(color, 1),
|
||||||
|
toColor(color, 2),
|
||||||
|
toColor(color, 3));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case SP_ATTACHMENT_CLIPPING: {
|
||||||
|
spClippingAttachment *clip = SUB_CAST(spClippingAttachment, attachment);
|
||||||
|
int vertexCount = 0;
|
||||||
|
const char *end = Json_getString(attachmentMap, "end", 0);
|
||||||
|
if (end) {
|
||||||
|
spSlotData *endSlot = spSkeletonData_findSlot(skeletonData, end);
|
||||||
|
clip->endSlot = endSlot;
|
||||||
|
}
|
||||||
|
vertexCount = Json_getInt(attachmentMap, "vertexCount", 0) << 1;
|
||||||
|
_readVertices(self, attachmentMap, SUPER(clip), vertexCount);
|
||||||
|
color = Json_getString(attachmentMap, "color", 0);
|
||||||
|
if (color) {
|
||||||
|
spColor_setFromFloats(&clip->color,
|
||||||
|
toColor(color, 0),
|
||||||
|
toColor(color, 1),
|
||||||
|
toColor(color, 2),
|
||||||
|
toColor(color, 3));
|
||||||
|
}
|
||||||
|
spAttachmentLoader_configureAttachment(self->attachmentLoader, attachment);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
}
|
|
||||||
case SP_ATTACHMENT_CLIPPING: {
|
|
||||||
spClippingAttachment *clip = SUB_CAST(spClippingAttachment, attachment);
|
|
||||||
int vertexCount = 0;
|
|
||||||
const char *end = Json_getString(attachmentMap, "end", 0);
|
|
||||||
if (end) {
|
|
||||||
spSlotData *endSlot = spSkeletonData_findSlot(skeletonData, end);
|
|
||||||
clip->endSlot = endSlot;
|
|
||||||
}
|
|
||||||
vertexCount = Json_getInt(attachmentMap, "vertexCount", 0) << 1;
|
|
||||||
_readVertices(self, attachmentMap, SUPER(clip), vertexCount);
|
|
||||||
color = Json_getString(attachmentMap, "color", 0);
|
|
||||||
if (color) {
|
|
||||||
spColor_setFromFloats(&clip->color,
|
|
||||||
toColor(color, 0),
|
|
||||||
toColor(color, 1),
|
|
||||||
toColor(color, 2),
|
|
||||||
toColor(color, 3));
|
|
||||||
}
|
|
||||||
spAttachmentLoader_configureAttachment(self->attachmentLoader, attachment);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
spSkin_setAttachment(skin, slot->index, skinAttachmentName, attachment);
|
||||||
}
|
}
|
||||||
|
|
||||||
spSkin_setAttachment(skin, slot->index, skinAttachmentName, attachment);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -28,7 +28,6 @@
|
|||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
#include <spine/MeshAttachment.h>
|
#include <spine/MeshAttachment.h>
|
||||||
#include <spine/HasRendererObject.h>
|
|
||||||
|
|
||||||
using namespace spine;
|
using namespace spine;
|
||||||
|
|
||||||
@ -53,10 +52,13 @@ void MeshAttachment::updateRegion() {
|
|||||||
_uvs.setSize(_regionUVs.size(), 0);
|
_uvs.setSize(_regionUVs.size(), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (_region == nullptr) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
int i = 0, n = (int) _regionUVs.size();
|
int i = 0, n = (int) _regionUVs.size();
|
||||||
float u = _region->u, v = _region->v;
|
float u = _region->u, v = _region->v;
|
||||||
float width = 0, height = 0;
|
float width = 0, height = 0;
|
||||||
|
|
||||||
switch (_region->degrees) {
|
switch (_region->degrees) {
|
||||||
case 90: {
|
case 90: {
|
||||||
float textureWidth = _region->height / (_region->u2 - _region->u);
|
float textureWidth = _region->height / (_region->u2 - _region->u);
|
||||||
|
|||||||
@ -264,7 +264,7 @@ void USpineSkeletonRendererComponent::UpdateMesh(USpineSkeletonComponent *compon
|
|||||||
// ignore regions for which we can't find a material
|
// ignore regions for which we can't find a material
|
||||||
UMaterialInstanceDynamic *material = nullptr;
|
UMaterialInstanceDynamic *material = nullptr;
|
||||||
int foundPageIndex = -1;
|
int foundPageIndex = -1;
|
||||||
for (int pageIndex = 0; i < component->Atlas->atlasPages.Num(); pageIndex++) {
|
for (int pageIndex = 0; pageIndex < component->Atlas->atlasPages.Num(); pageIndex++) {
|
||||||
AtlasPage *page = component->Atlas->GetAtlas()->getPages()[pageIndex];
|
AtlasPage *page = component->Atlas->GetAtlas()->getPages()[pageIndex];
|
||||||
if (attachmentAtlasRegion->page == page) {
|
if (attachmentAtlasRegion->page == page) {
|
||||||
foundPageIndex = pageIndex;
|
foundPageIndex = pageIndex;
|
||||||
@ -277,33 +277,33 @@ void USpineSkeletonRendererComponent::UpdateMesh(USpineSkeletonComponent *compon
|
|||||||
}
|
}
|
||||||
switch (slot->getData().getBlendMode()) {
|
switch (slot->getData().getBlendMode()) {
|
||||||
case BlendMode_Additive:
|
case BlendMode_Additive:
|
||||||
if (i >= atlasAdditiveBlendMaterials.Num()) {
|
if (foundPageIndex >= atlasAdditiveBlendMaterials.Num()) {
|
||||||
clipper.clipEnd(*slot);
|
clipper.clipEnd(*slot);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
material = atlasAdditiveBlendMaterials[i];
|
material = atlasAdditiveBlendMaterials[foundPageIndex];
|
||||||
break;
|
break;
|
||||||
case BlendMode_Multiply:
|
case BlendMode_Multiply:
|
||||||
if (i >= atlasMultiplyBlendMaterials.Num()) {
|
if (foundPageIndex >= atlasMultiplyBlendMaterials.Num()) {
|
||||||
clipper.clipEnd(*slot);
|
clipper.clipEnd(*slot);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
material = atlasMultiplyBlendMaterials[i];
|
material = atlasMultiplyBlendMaterials[foundPageIndex];
|
||||||
break;
|
break;
|
||||||
case BlendMode_Screen:
|
case BlendMode_Screen:
|
||||||
if (i >= atlasScreenBlendMaterials.Num()) {
|
if (foundPageIndex >= atlasScreenBlendMaterials.Num()) {
|
||||||
clipper.clipEnd(*slot);
|
clipper.clipEnd(*slot);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
material = atlasScreenBlendMaterials[i];
|
material = atlasScreenBlendMaterials[foundPageIndex];
|
||||||
break;
|
break;
|
||||||
case BlendMode_Normal:
|
case BlendMode_Normal:
|
||||||
default:
|
default:
|
||||||
if (i >= atlasNormalBlendMaterials.Num()) {
|
if (foundPageIndex >= atlasNormalBlendMaterials.Num()) {
|
||||||
clipper.clipEnd(*slot);
|
clipper.clipEnd(*slot);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
material = atlasNormalBlendMaterials[i];
|
material = atlasNormalBlendMaterials[foundPageIndex];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user