diff --git a/spine-cpp/spine-cpp/src/spine/MeshAttachment.cpp b/spine-cpp/spine-cpp/src/spine/MeshAttachment.cpp index 57562f508..922130dba 100644 --- a/spine-cpp/spine-cpp/src/spine/MeshAttachment.cpp +++ b/spine-cpp/spine-cpp/src/spine/MeshAttachment.cpp @@ -28,7 +28,6 @@ *****************************************************************************/ #include -#include using namespace spine; @@ -53,10 +52,13 @@ void MeshAttachment::updateRegion() { _uvs.setSize(_regionUVs.size(), 0); } + if (_region == nullptr) { + return; + } + int i = 0, n = (int) _regionUVs.size(); float u = _region->u, v = _region->v; float width = 0, height = 0; - switch (_region->degrees) { case 90: { float textureWidth = _region->height / (_region->u2 - _region->u); diff --git a/spine-ue4/Plugins/SpinePlugin/Source/SpinePlugin/Private/SpineSkeletonRendererComponent.cpp b/spine-ue4/Plugins/SpinePlugin/Source/SpinePlugin/Private/SpineSkeletonRendererComponent.cpp index ac52f4956..f6e43d292 100644 --- a/spine-ue4/Plugins/SpinePlugin/Source/SpinePlugin/Private/SpineSkeletonRendererComponent.cpp +++ b/spine-ue4/Plugins/SpinePlugin/Source/SpinePlugin/Private/SpineSkeletonRendererComponent.cpp @@ -264,7 +264,7 @@ void USpineSkeletonRendererComponent::UpdateMesh(USpineSkeletonComponent *compon // ignore regions for which we can't find a material UMaterialInstanceDynamic *material = nullptr; 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]; if (attachmentAtlasRegion->page == page) { foundPageIndex = pageIndex; @@ -277,33 +277,33 @@ void USpineSkeletonRendererComponent::UpdateMesh(USpineSkeletonComponent *compon } switch (slot->getData().getBlendMode()) { case BlendMode_Additive: - if (i >= atlasAdditiveBlendMaterials.Num()) { + if (foundPageIndex >= atlasAdditiveBlendMaterials.Num()) { clipper.clipEnd(*slot); continue; } - material = atlasAdditiveBlendMaterials[i]; + material = atlasAdditiveBlendMaterials[foundPageIndex]; break; case BlendMode_Multiply: - if (i >= atlasMultiplyBlendMaterials.Num()) { + if (foundPageIndex >= atlasMultiplyBlendMaterials.Num()) { clipper.clipEnd(*slot); continue; } - material = atlasMultiplyBlendMaterials[i]; + material = atlasMultiplyBlendMaterials[foundPageIndex]; break; case BlendMode_Screen: - if (i >= atlasScreenBlendMaterials.Num()) { + if (foundPageIndex >= atlasScreenBlendMaterials.Num()) { clipper.clipEnd(*slot); continue; } - material = atlasScreenBlendMaterials[i]; + material = atlasScreenBlendMaterials[foundPageIndex]; break; case BlendMode_Normal: default: - if (i >= atlasNormalBlendMaterials.Num()) { + if (foundPageIndex >= atlasNormalBlendMaterials.Num()) { clipper.clipEnd(*slot); continue; } - material = atlasNormalBlendMaterials[i]; + material = atlasNormalBlendMaterials[foundPageIndex]; break; }