Skip to content

Commit 6d95fc7

Browse files
committed
Fixed LODMaterialMap for UE4 SkeletalMesh
1 parent c60461a commit 6d95fc7

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

Unreal/UnrealMesh/UnMesh4.cpp

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2092,16 +2092,19 @@ void USkeletalMesh4::ConvertMesh()
20922092
const FSkelMeshSection4 &S = SrcLod.Sections[Sec];
20932093
CMeshSection *Dst = new (Lod->Sections) CMeshSection;
20942094

2095-
// remap material for LOD
2095+
// Remap material for LOD
2096+
// In comment for LODMaterialMap, INDEX_NONE means "no remap", so let's use this logic here.
2097+
// Actually, INDEX_NONE in LODMaterialMap seems hides the mesh section in game.
2098+
// Reference: FSkeletalMeshSceneProxy
20962099
int MaterialIndex = S.MaterialIndex;
2097-
if (Info.LODMaterialMap.IsValidIndex(MaterialIndex))
2098-
MaterialIndex = Info.LODMaterialMap[MaterialIndex];
2099-
if (MaterialIndex < 0) // UE4 using Clamp(0, Materials.Num()), not Materials.Num()-1
2100-
MaterialIndex = 0;
2100+
if (Info.LODMaterialMap.IsValidIndex(Sec) && Materials.IsValidIndex(Info.LODMaterialMap[Sec]))
2101+
{
2102+
MaterialIndex = Info.LODMaterialMap[Sec];
2103+
}
21012104

2102-
Dst->Material = Materials.IsValidIndex(MaterialIndex) ? Materials[MaterialIndex].Material : NULL;
2105+
Dst->Material = Materials.IsValidIndex(MaterialIndex) ? Materials[MaterialIndex].Material : NULL;
21032106
Dst->FirstIndex = S.BaseIndex;
2104-
Dst->NumFaces = S.NumTriangles;
2107+
Dst->NumFaces = S.NumTriangles;
21052108
}
21062109

21072110
unguard; // ProcessSections

umodel.exe

0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)