Skip to content

Commit caf5120

Browse files
committed
Fixed crash with some meshes of Star Wars Jefi: Fallen Order
1 parent 4b6e44f commit caf5120

File tree

3 files changed

+41
-28
lines changed

3 files changed

+41
-28
lines changed

Unreal/UnMesh4.cpp

Lines changed: 41 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -180,47 +180,60 @@ struct FStaticMeshVertexBuffer4
180180

181181
if (!StripFlags.IsDataStrippedForServer())
182182
{
183-
#if JEDI
184-
if (Ar.Game == GAME_Jedi)
185-
{
186-
int32 unk;
187-
Ar << unk;
188-
}
189-
#endif // JEDI
190-
191183
GNumStaticUVSets = S.NumTexCoords;
192184
GUseStaticFloatUVs = S.bUseFullPrecisionUVs;
185+
193186
if (Ar.Game < GAME_UE4(19))
194187
{
195188
S.UV.BulkSerialize(Ar);
196189
}
197190
else
198191
{
199192
// In 4.19 tangents and texture coordinates are stored in separate vertex streams
200-
int32 ItemSize, ItemCount;
201-
S.UV.AddUninitialized(S.NumVertices);
202-
203-
// Tangents
204-
Ar << ItemSize << ItemCount;
205-
DBG_MESH("... tangents: %d items by %d bytes\n", ItemCount, ItemSize);
206-
assert(ItemCount == S.NumVertices);
207-
int Pos = Ar.Tell();
208-
for (int i = 0; i < S.NumVertices; i++)
193+
S.UV.AddZeroed(S.NumVertices);
194+
195+
#if JEDI
196+
if (Ar.Game == GAME_Jedi)
209197
{
210-
FStaticMeshUVItem4::SerializeTangents(Ar, S.UV[i]);
198+
int32 bDropNormals;
199+
Ar << bDropNormals;
200+
assert(bDropNormals == 0 || bDropNormals == 1); //todo: replace with bool
201+
if (bDropNormals)
202+
{
203+
//!! todo: no tangents, should indicate that tangents should be recreated
204+
goto texcoords;
205+
}
206+
}
207+
#endif // JEDI
208+
209+
{
210+
// Tangents: simulate TArray::BulkSerialize()
211+
int32 ItemSize, ItemCount;
212+
Ar << ItemSize << ItemCount;
213+
DBG_MESH("... tangents: %d items by %d bytes\n", ItemCount, ItemSize);
214+
assert(ItemCount == S.NumVertices);
215+
int Pos = Ar.Tell();
216+
for (int i = 0; i < S.NumVertices; i++)
217+
{
218+
FStaticMeshUVItem4::SerializeTangents(Ar, S.UV[i]);
219+
}
220+
assert(Ar.Tell() - Pos == ItemCount * ItemSize);
211221
}
212-
assert(Ar.Tell() - Pos == ItemCount * ItemSize);
213-
214-
// Texture coordinates
215-
Ar << ItemSize << ItemCount;
216-
DBG_MESH("... texcoords: %d items by %d bytes\n", ItemCount, ItemSize);
217-
assert(ItemCount == S.NumVertices * S.NumTexCoords);
218-
Pos = Ar.Tell();
219-
for (int i = 0; i < S.NumVertices; i++)
222+
220223
{
221-
FStaticMeshUVItem4::SerializeTexcoords(Ar, S.UV[i]);
224+
texcoords:
225+
// Texture coordinates: simulate TArray::BulkSerialize()
226+
int32 ItemSize, ItemCount;
227+
Ar << ItemSize << ItemCount;
228+
DBG_MESH("... texcoords: %d items by %d bytes\n", ItemCount, ItemSize);
229+
assert(ItemCount == S.NumVertices * S.NumTexCoords);
230+
int Pos = Ar.Tell();
231+
for (int i = 0; i < S.NumVertices; i++)
232+
{
233+
FStaticMeshUVItem4::SerializeTexcoords(Ar, S.UV[i]);
234+
}
235+
assert(Ar.Tell() - Pos == ItemCount * ItemSize);
222236
}
223-
assert(Ar.Tell() - Pos == ItemCount * ItemSize);
224237
}
225238
}
226239

umodel

0 Bytes
Binary file not shown.

umodel.exe

0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)