Skip to content

Commit 0b92aac

Browse files
committed
Fixed a few crashes with invalid vertex color or morph data
1 parent 7b9bdf1 commit 0b92aac

File tree

4 files changed

+12
-5
lines changed

4 files changed

+12
-5
lines changed

Unreal/UnMesh3.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,12 @@ void FMorphTargetLODModel::Serialize3(FArchive& Ar, FMorphTargetLODModel& Lod)
9393
Super::Serialize(Ar);
9494
MorphLODModels.Serialize2<FMorphTargetLODModel::Serialize3>(Ar);
9595

96+
if (Ar.Tell() < Ar.GetStopper())
97+
{
98+
appPrintf("UMorphTarget%s: dropping %d bytes\n", Name, Ar.GetStopper() - Ar.Tell());
99+
DROP_REMAINING_DATA(Ar);
100+
}
101+
96102
unguard;
97103
}
98104

@@ -2077,8 +2083,10 @@ void USkeletalMesh3::ConvertMesh()
20772083
}
20782084
// allocate the vertices
20792085
Lod->AllocateVerts(VertexCount);
2080-
if (SrcLod.VertexColor.Num())
2086+
if (SrcLod.VertexColor.Num() == VertexCount)
20812087
Lod->AllocateVertexColorBuffer();
2088+
else if (SrcLod.VertexColor.Num())
2089+
appPrintf("LOD %d has invalid vertex color stream\n", lod);
20822090

20832091
int chunkIndex = 0;
20842092
const FSkelMeshChunk3 *C = NULL;

Unreal/UnMesh4.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1176,7 +1176,6 @@ struct FStaticLODModel4
11761176
Ar << NewColorVertexBuffer;
11771177
Exchange(Lod.ColorVertexBuffer.Data, NewColorVertexBuffer.Data);
11781178
}
1179-
DBG_SKEL("Colors: %d\n", Lod.ColorVertexBuffer.Data.Num());
11801179
}
11811180

11821181
if (Ar.ArVer < VER_UE4_REMOVE_EXTRA_SKELMESH_VERTEX_INFLUENCES)
@@ -1387,11 +1386,9 @@ struct FStaticLODModel4
13871386
assert(LoadingMesh);
13881387
if (LoadingMesh->bHasVertexColors)
13891388
{
1390-
appPrintf("WARNING: SkeletalMesh %s has vertex colors\n", LoadingMesh->Name);
13911389
FColorVertexBuffer4 NewColorVertexBuffer;
13921390
Ar << NewColorVertexBuffer;
13931391
Exchange(ColorVertexBuffer.Data, NewColorVertexBuffer.Data);
1394-
DBG_SKEL("Colors: %d\n", ColorVertexBuffer.Data.Num());
13951392
}
13961393

13971394
if (!StripFlags.IsClassDataStripped(CDSF_AdjacencyData))
@@ -1632,8 +1629,10 @@ void USkeletalMesh4::ConvertMesh()
16321629
const FSkeletalMeshVertexBuffer4& VertBuffer = SrcLod.VertexBufferGPUSkin;
16331630
CSkelMeshVertex* D = Lod->Verts;
16341631

1635-
if (SrcLod.ColorVertexBuffer.Data.Num())
1632+
if (SrcLod.ColorVertexBuffer.Data.Num() == VertexCount)
16361633
Lod->AllocateVertexColorBuffer();
1634+
else if (SrcLod.ColorVertexBuffer.Data.Num())
1635+
appPrintf("LOD %d has invalid vertex color stream\n", lod);
16371636

16381637
for (int Vert = 0; Vert < VertexCount; Vert++, D++)
16391638
{

umodel

0 Bytes
Binary file not shown.

umodel.exe

0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)