Skip to content

Commit 2366c50

Browse files
committed
Updates for UE4.24
- Added stub for BULKDATA_Size64Bit - FStaticMeshLODModel4::Serialize() works correctly with empty bulk
1 parent 5915da3 commit 2366c50

File tree

5 files changed

+17
-16
lines changed

5 files changed

+17
-16
lines changed

Unreal/UnCore.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2340,12 +2340,13 @@ void appReadCompressedChunk(FArchive &Ar, byte *Buffer, int Size, int Compressio
23402340
#define BULKDATA_PayloadInSeperateFile 0x0100 // data stored in .ubulk file near the asset (UE4.12+)
23412341
#define BULKDATA_SerializeCompressedBitWindow 0x0200 // use platform-specific compression
23422342
#define BULKDATA_OptionalPayload 0x0800 // same as BULKDATA_PayloadInSeperateFile, but stored with .uptnl extension (UE4.20+)
2343+
#define BULKDATA_Size64Bit 0x2000 // 64-bit size fields, UE4.22+
23432344

23442345
#endif // UNREAL4
23452346

23462347
struct FByteBulkData //?? separate FUntypedBulkData
23472348
{
2348-
int32 BulkDataFlags; // BULKDATA_...
2349+
uint32 BulkDataFlags; // BULKDATA_...
23492350
int32 ElementCount; // number of array elements
23502351
int64 BulkDataOffsetInFile; // position in file, points to BulkData; 32-bit in UE3, 64-bit in UE4
23512352
int32 BulkDataSizeOnDisk; // size of bulk data on disk

Unreal/UnCoreSerialize.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -998,7 +998,9 @@ void FByteBulkData::SerializeHeader(FArchive &Ar)
998998

999999
bIsUE4Data = true;
10001000

1001-
Ar << BulkDataFlags << ElementCount;
1001+
Ar << BulkDataFlags;
1002+
assert(!(BulkDataFlags & BULKDATA_Size64Bit));
1003+
Ar << ElementCount;
10021004
Ar << BulkDataSizeOnDisk;
10031005
if (Ar.ArVer < VER_UE4_BULKDATA_AT_LARGE_OFFSETS)
10041006
{

Unreal/UnMesh4.cpp

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1384,13 +1384,14 @@ struct FStaticLODModel4
13841384
{
13851385
//todo
13861386
appError("SkeletalMesh: LOD data in bulk");
1387+
// bulk, then bDiscardBulkData, then SerializeAvailabilityInfo
13871388
}
13881389
}
13891390

13901391
unguard;
13911392
}
13921393

1393-
// UE4.23+ serializer for most of LOD data
1394+
// UE4.24+ serializer for most of LOD data
13941395
void SerializeStreamedData(FArchive& Ar)
13951396
{
13961397
guard(FStaticLODModel4::SerializeStreamedData);
@@ -1423,14 +1424,8 @@ struct FStaticLODModel4
14231424
if (HasClothData())
14241425
Ar << ClothVertexBuffer;
14251426

1426-
//!! Try to share code with SerializeRenderItem_Legacy(), in this case Ar.Game >= GAME_UE4(23) will
1427-
//!! become usedful. The difference is that "Legacy" function also serializes Sections. ActiveBoneIndices
1428-
//!! and RequiredBones, plus it has extra "if" for vertex buffer serialization.
1429-
if (Ar.Game >= GAME_UE4(23))
1430-
{
1431-
FSkinWeightProfilesData SkinWeightProfilesData;
1432-
Ar << SkinWeightProfilesData;
1433-
}
1427+
FSkinWeightProfilesData SkinWeightProfilesData;
1428+
Ar << SkinWeightProfilesData;
14341429

14351430
//todo: this is a copy-paste of SerializeRenderItem_Legacy code!
14361431
guard(BuildVertexData);
@@ -2025,12 +2020,15 @@ struct FStaticMeshLODModel4
20252020
DBG_STAT("Serialize from bulk\n");
20262021
FByteBulkData Bulk;
20272022
Bulk.Serialize(Ar);
2028-
// perform SerializeBuffers on bulk array
2029-
Bulk.SerializeData(UObject::GLoadingObj);
2023+
if (Bulk.ElementCount > 0)
2024+
{
2025+
// perform SerializeBuffers on bulk array
2026+
Bulk.SerializeData(UObject::GLoadingObj);
20302027

2031-
FMemReader Reader(Bulk.BulkData, Bulk.ElementCount); // ElementCount is the same as data size, for byte bulk data
2032-
Reader.SetupFrom(*UObject::GLoadingObj->GetPackageArchive());
2033-
SerializeBuffers(Reader, Lod);
2028+
FMemReader Reader(Bulk.BulkData, Bulk.ElementCount); // ElementCount is the same as data size, for byte bulk data
2029+
Reader.SetupFrom(*UObject::GLoadingObj->GetPackageArchive());
2030+
SerializeBuffers(Reader, Lod);
2031+
}
20342032

20352033
// FStaticMeshLODResources::SerializeAvailabilityInfo()
20362034
uint32 DepthOnlyNumTriangles, PackedData;

umodel

0 Bytes
Binary file not shown.

umodel.exe

-19.5 KB
Binary file not shown.

0 commit comments

Comments
 (0)