mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-03-26 22:49:01 +08:00
[ue] Closes #2257, import uses null attachment loader, leading to crash for mesh attachments. Also fixes atlas page fetch in renderer.
This commit is contained in:
parent
41dc6cc84f
commit
a557db3a54
@ -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