Преглед на файлове

[ue] Closes #2257, import uses null attachment loader, leading to crash for mesh attachments. Also fixes atlas page fetch in renderer.

badlogic преди 2 години
родител
ревизия
a557db3a54

+ 4 - 2
spine-cpp/spine-cpp/src/spine/MeshAttachment.cpp

@@ -28,7 +28,6 @@
  *****************************************************************************/
 
 #include <spine/MeshAttachment.h>
-#include <spine/HasRendererObject.h>
 
 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);

+ 9 - 9
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;
 		}