[ue4] Don't render invisible skeletons/slots/attachments.

This commit is contained in:
badlogic 2018-07-18 14:42:57 +02:00
parent 15b93e0dfd
commit 0150cf5e2d
2 changed files with 24 additions and 1 deletions

View File

@ -202,6 +202,9 @@ void USpineSkeletonRendererComponent::UpdateMesh(spSkeleton* Skeleton) {
ClearAllMeshSections();
// Early out if skeleton is invisible
if (Skeleton->color.a == 0) return;
float depthOffset = 0;
unsigned short quadIndices[] = { 0, 1, 2, 0, 2, 3 };
@ -216,12 +219,25 @@ void USpineSkeletonRendererComponent::UpdateMesh(spSkeleton* Skeleton) {
float* attachmentUvs = nullptr;
spSlot* slot = Skeleton->drawOrder[i];
if (Skeleton->color.a == 0) {
spSkeletonClipping_clipEnd(clipper, slot);
continue;
}
spAttachment* attachment = slot->attachment;
if (!attachment) continue;
if (attachment->type != SP_ATTACHMENT_REGION && attachment->type != SP_ATTACHMENT_MESH && attachment->type != SP_ATTACHMENT_CLIPPING) continue;
if (attachment->type == SP_ATTACHMENT_REGION) {
spRegionAttachment* regionAttachment = (spRegionAttachment*)attachment;
// Early out if region is invisible
if (regionAttachment->color.a == 0) {
spSkeletonClipping_clipEnd(clipper, slot);
continue;
}
spColor_setFromColor(&attachmentColor, &regionAttachment->color);
attachmentAtlasRegion = (spAtlasRegion*)regionAttachment->rendererObject;
spRegionAttachment_computeWorldVertices(regionAttachment, slot->bone, attachmentVertices, 0, 2);
@ -231,6 +247,13 @@ void USpineSkeletonRendererComponent::UpdateMesh(spSkeleton* Skeleton) {
numIndices = 6;
} else if (attachment->type == SP_ATTACHMENT_MESH) {
spMeshAttachment* mesh = (spMeshAttachment*)attachment;
// Early out if region is invisible
if (mesh->color.a == 0) {
spSkeletonClipping_clipEnd(clipper, slot);
continue;
}
spColor_setFromColor(&attachmentColor, &mesh->color);
attachmentAtlasRegion = (spAtlasRegion*)mesh->rendererObject;
if (mesh->super.worldVerticesLength > worldVertices->size) spFloatArray_setSize(worldVertices, mesh->super.worldVerticesLength);

View File

@ -1,5 +1,5 @@
# spine-ue4
The spine-ue4 runtime provides functionality to load, manipulate and render [Spine](http://esotericsoftware.com) skeletal animation data using [Unreal Engine 4.15+](https://www.unrealengine.com/). spine-ue4 is based on [spine-c](../spine-c).
The spine-ue4 runtime provides functionality to load, manipulate and render [Spine](http://esotericsoftware.com) skeletal animation data using [Unreal Engine 4.15+](https://www.unrealengine.com/). spine-ue4 is based on [spine-c](../spine-c). Note: the last supported Unreal Engine version of this runtime is 4.18. For UE4 versions higher than 4.18, please use the runtime in the 3.7-beta-cpp branch.
## Licensing