Skip to content

Commit a02982f

Browse files
committed
UE4.27 support
- Updated unversioned props tables - Updated versions constants - UnMesh4.cpp has removed hack with pre-enabled "KeepMobileMinLODSettingOnDesktop" - Some code cleanup, added comments etc
1 parent d73e1db commit a02982f

File tree

8 files changed

+106
-37
lines changed

8 files changed

+106
-37
lines changed

Docs/UE4Props.pl

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
11
#!/usr/bin/perl -w
22

3+
# TODO:
4+
# - command line (has some commented code here)
5+
# - show file/line where class defined
6+
# - command line: show particular class and its parents
7+
# - when there's parent, parse its prpos and add count to the 1st property (e.g. for UMaterialInstanceConstant)
8+
9+
310
@dirs =
411
(
5-
"../../Epic/UnrealEngine4-latest/Engine/Source/Runtime/Engine",
12+
"../../Epic/UnrealEngine4/Engine/Source/Runtime/Engine",
13+
# "../../Epic/UnrealEngine4-latest/Engine/Source/Runtime/Engine",
614
);
715

816
@files =

Docs/UE4Version.pl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"EditorObjectVersion.h",
1414
"../../../Engine/Public/SkeletalMeshTypes.h", # for newer UE4 (post UE4.18)
1515
"../../../Engine/Private/SkeletalMesh.cpp", # for older UE4 version (UE4.18 and less)
16+
"../../../Engine/Public/SkeletalMeshLegacyCustomVersions.h", # UE4.27 and newer
1617
"CoreObjectVersion.h",
1718
"RenderingObjectVersion.h",
1819
"AnimObjectVersion.h",

Unreal/UE4Version.h

Lines changed: 63 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -95,13 +95,30 @@ enum
9595
VER_UE4_SKINWEIGHT_PROFILE_DATA_LAYOUT_CHANGES = 519,
9696
VER_UE4_NON_OUTER_PACKAGE_IMPORT = 520,
9797
VER_UE4_26 = 522,
98-
VER_UE4_27 = 523, //?? TODO
98+
VER_UE4_27 = 522,
9999
// look for NEW_ENGINE_VERSION over the code to find places where version constants should be inserted.
100100
// LATEST_SUPPORTED_UE4_VERSION should be updated too.
101101
};
102102

103103
int GetUE4CustomVersion(const FArchive& Ar, const FGuid& Guid);
104104

105+
106+
/*
107+
* Rules for writing code for custom versions
108+
* - Each version is a "struct". Ideally could use "enum class", however we're adding some code into it, so "struct" is ideal.
109+
* - Use "enum Type" inside of it.
110+
* - Each enum has members:
111+
* - VersionPlusOne - equals to the recent declared constant + 1, used to correctly set up LatestVersion without explicit
112+
* mentioning of the latest constant name.
113+
* - optional: ForceVersion - use it in a case we're not declaring the latest version as a constant, so LatestVersion value
114+
* will work correctly.
115+
* - There's "static Type Get(const FArchive& Ar)" function, it computes custom version based on Game constant. Needed in order
116+
* to make unversioned packages to work.
117+
* - This function does comparison of game constant with engine number PLUS ONE, so games which are derived from e.g. UE4.25
118+
* will work correctly after using logic "Game < GAME_UE4(26)", i.e. game is using engine smaller than UE4.26. If we'll use
119+
* "Game <= GAME_UE4.25", this WILL work for UE4.25, but not for 4.25-based games which has custom override.
120+
*/
121+
105122
struct FFrameworkObjectVersion
106123
{
107124
enum Type
@@ -124,7 +141,9 @@ struct FFrameworkObjectVersion
124141
// UE4.20, UE4.21 = 34
125142
// UE4.22, UE4.23 = 35
126143
// UE4.24 = 36
127-
// UE4.25, UE4.26 = 37
144+
// UE4.25-UE4.27 = 37
145+
146+
ForceVersion = 37, // the recent version, added here just to force LatestVersion to be correct
128147

129148
VersionPlusOne,
130149
LatestVersion = VersionPlusOne - 1
@@ -165,10 +184,10 @@ struct FFrameworkObjectVersion
165184
return (Type)35;
166185
if (Ar.Game < GAME_UE4(25))
167186
return (Type)36;
168-
// if (Ar.Game < GAME_UE4(27))
187+
if (Ar.Game < GAME_UE4(28))
169188
return (Type)37;
170189
// NEW_ENGINE_VERSION
171-
// return LatestVersion;
190+
return LatestVersion;
172191
}
173192
};
174193

@@ -195,7 +214,9 @@ struct FEditorObjectVersion
195214
// UE4.23 = 34
196215
// UE4.24 = 37
197216
// UE4.25 = 38
198-
// UE4.26 = 40
217+
// UE4.26, UE4.27 = 40
218+
219+
ForceVersion = 40,
199220

200221
VersionPlusOne,
201222
LatestVersion = VersionPlusOne - 1
@@ -243,10 +264,10 @@ struct FEditorObjectVersion
243264
return (Type)37;
244265
if (Ar.Game < GAME_UE4(26))
245266
return (Type)38;
246-
// if (Ar.Game < GAME_UE4(27))
267+
if (Ar.Game < GAME_UE4(28))
247268
return (Type)40;
248269
// NEW_ENGINE_VERSION
249-
// return LatestVersion;
270+
return LatestVersion;
250271
}
251272
};
252273

@@ -278,7 +299,7 @@ struct FSkeletalMeshCustomVersion
278299
SectionIgnoreByReduceAdded = 16,
279300
// UE4.23-UE4.25 = 17
280301
SkinWeightProfiles = 17, //todo: FSkeletalMeshLODModel::Serialize (editor mesh)
281-
// UE4.26 = 18
302+
// UE4.26, UE4.27 = 18
282303
RemoveEnableClothLOD = 18, //todo
283304

284305
VersionPlusOne,
@@ -316,10 +337,10 @@ struct FSkeletalMeshCustomVersion
316337
return SectionIgnoreByReduceAdded;
317338
if (Ar.Game < GAME_UE4(26))
318339
return SkinWeightProfiles;
319-
// if (Ar.Game < GAME_UE4(27))
340+
if (Ar.Game < GAME_UE4(28))
320341
return RemoveEnableClothLOD;
321342
// NEW_ENGINE_VERSION
322-
// return LatestVersion;
343+
return LatestVersion;
323344
}
324345
};
325346

@@ -333,7 +354,7 @@ struct FCoreObjectVersion
333354
// UE4.15-UE4.21 = 2
334355
// UE4.22-UE4.24 = 3
335356
SkeletalMaterialEditorDataStripping = 3,
336-
// UE4.25-UE4.26 = 4
357+
// UE4.25-UE4.27 = 4
337358

338359
VersionPlusOne,
339360
LatestVersion = VersionPlusOne - 1
@@ -353,10 +374,10 @@ struct FCoreObjectVersion
353374
return (Type)2;
354375
if (Ar.Game < GAME_UE4(25))
355376
return SkeletalMaterialEditorDataStripping;
356-
// if (Ar.Game < GAME_UE4(27))
377+
if (Ar.Game < GAME_UE4(28))
357378
return (Type)4;
358379
// NEW_ENGINE_VERSION
359-
// return LatestVersion;
380+
return LatestVersion;
360381
}
361382
};
362383

@@ -378,9 +399,12 @@ struct FRenderingObjectVersion
378399
// UE4.22 = 28
379400
// UE4.23 = 31
380401
// UE4.24 = 36
402+
StaticMeshSectionForceOpaqueField = 37,
381403
// UE4.25 = 43
382404
// UE4.26 = 44
383-
StaticMeshSectionForceOpaqueField = 37,
405+
// UE4.27 = 45
406+
407+
ForceVersion = 45,
384408

385409
VersionPlusOne,
386410
LatestVersion = VersionPlusOne - 1
@@ -425,10 +449,12 @@ struct FRenderingObjectVersion
425449
return (Type)36;
426450
if (Ar.Game < GAME_UE4(26))
427451
return (Type)43;
428-
// if (Ar.Game < GAME_UE4(27))
452+
if (Ar.Game < GAME_UE4(27))
429453
return (Type)44;
454+
if (Ar.Game < GAME_UE4(28))
455+
return (Type)45;
430456
// NEW_ENGINE_VERSION
431-
// return LatestVersion;
457+
return LatestVersion;
432458
}
433459
};
434460

@@ -442,7 +468,9 @@ struct FAnimObjectVersion
442468
// UE4.25 = 7
443469
IncreaseBoneIndexLimitPerChunk = 4,
444470
UnlimitedBoneInfluences = 5,
445-
// UE4.26 = 15
471+
// UE4.26, UE4.27 = 15
472+
473+
ForceVersion = 15,
446474

447475
VersionPlusOne,
448476
LatestVersion = VersionPlusOne - 1
@@ -460,11 +488,10 @@ struct FAnimObjectVersion
460488
return StoreMarkerNamesOnSkeleton;
461489
if (Ar.Game < GAME_UE4(26))
462490
return (Type)7;
463-
// if (Ar.Game < GAME_UE4(27))
491+
if (Ar.Game < GAME_UE4(28))
464492
return (Type)15;
465-
466493
// NEW_ENGINE_VERSION
467-
// return LatestVersion;
494+
return LatestVersion;
468495
}
469496
};
470497

@@ -481,7 +508,9 @@ struct FAnimPhysObjectVersion
481508
AddLODToCurveMetaData = 12,
482509
// UE4.19 = 16
483510
ChangeRetargetSourceReferenceToSoftObjectPtr = 15,
484-
// UE4.20-UE4.26 = 17
511+
// UE4.20-UE4.27 = 17
512+
513+
ForceVersion = 17,
485514

486515
VersionPlusOne,
487516
LatestVersion = VersionPlusOne - 1
@@ -503,10 +532,10 @@ struct FAnimPhysObjectVersion
503532
return AddLODToCurveMetaData;
504533
if (Ar.Game < GAME_UE4(20))
505534
return (Type)16;
506-
// if (Ar.Game < GAME_UE4(27))
535+
if (Ar.Game < GAME_UE4(28))
507536
return (Type)17;
508537
// NEW_ENGINE_VERSION
509-
// return LatestVersion;
538+
return LatestVersion;
510539
}
511540
};
512541

@@ -517,6 +546,9 @@ struct FReleaseObjectVersion
517546
BeforeCustomVersionWasAdded = 0,
518547
// UE4.19 = 12
519548
AddSkeletalMeshSectionDisable = 12,
549+
// Not used in our code, so for version mapping please refer to "Get()" method below...
550+
551+
ForceVersion = 43,
520552

521553
VersionPlusOne,
522554
LatestVersion = VersionPlusOne - 1
@@ -554,10 +586,12 @@ struct FReleaseObjectVersion
554586
return (Type)28;
555587
if (Ar.Game < GAME_UE4(26))
556588
return (Type)30;
557-
// if (Ar.Game < GAME_UE4(27))
589+
if (Ar.Game < GAME_UE4(27))
558590
return (Type)37;
591+
if (Ar.Game < GAME_UE4(28))
592+
return (Type)43;
559593
// NEW_ENGINE_VERSION
560-
// return LatestVersion;
594+
return LatestVersion;
561595
}
562596
};
563597

@@ -569,6 +603,8 @@ struct FEnterpriseObjectVersion
569603
// UE4.24 = 8
570604
MeshDescriptionBulkDataGuidIsHash = 8,
571605

606+
ForceVersion = 10,
607+
572608
VersionPlusOne,
573609
LatestVersion = VersionPlusOne - 1
574610
};
@@ -589,10 +625,10 @@ struct FEnterpriseObjectVersion
589625
return (Type)6;
590626
if (Ar.Game < GAME_UE4(25))
591627
return MeshDescriptionBulkDataGuidIsHash;
592-
// if (Ar.Game < GAME_UE4(27))
628+
if (Ar.Game < GAME_UE4(28))
593629
return (Type)10;
594630
// NEW_ENGINE_VERSION
595-
// return LatestVersion;
631+
return LatestVersion;
596632
}
597633
};
598634

Unreal/UnObject4.cpp

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,11 @@ struct PropInfo
8585

8686
static const PropInfo PropData[] =
8787
{
88+
// UStaticMesh
8889
BEGIN("UStaticMesh4")
90+
VERSION_BLOCK(GAME_UE4(27))
91+
DROP_INT8(14) // uint8 bSupportRayTracing
92+
VERSION_BLOCK(0)
8993
DROP_INT64(0) // FPerPlatformInt MinLOD - serialized as 2x int32, didn't find why
9094
MAP(StaticMaterials, 2)
9195
MAP(LightmapUVDensity, 3)
@@ -97,7 +101,11 @@ BEGIN("UStaticMesh4")
97101
DROP_OBJ_ARRAY(22) // TArray<UAssetUserData*> AssetUserData
98102
END
99103

104+
// USkeletalMesh
100105
BEGIN("USkeletalMesh4")
106+
VERSION_BLOCK(GAME_UE4(27))
107+
DROP_INT8(21) // uint8 bSupportRayTracing
108+
VERSION_BLOCK(0)
101109
MAP(Skeleton, 0)
102110
DROP_VECTOR3(3) // PositiveBoundsExtension
103111
DROP_VECTOR3(4) // PositiveBoundsExtension
@@ -125,20 +133,23 @@ BEGIN("USkeleton")
125133
DROP_OBJ_ARRAY(8) // TArray<UAssetUserData*> AssetUserData
126134
END
127135

136+
// UAnimSequence
128137
BEGIN("UAnimSequence4")
138+
VERSION_BLOCK(GAME_UE4(27))
139+
MAP(RetargetSourceAssetReferencePose, 9)
140+
VERSION_BLOCK(0)
129141
MAP(NumFrames, 0)
130142
MAP(TrackToSkeletonMapTable, 1)
131143
MAP(AdditiveAnimType, 4)
132144
MAP(RefPoseType, 5)
133145
MAP(RefPoseSeq, 6)
134146
MAP(RefFrameIndex, 7)
135147
MAP(RetargetSource, 8)
136-
MAP(RetargetSourceAssetReferencePose, 9)
137-
MAP(Interpolation, 10)
138-
MAP(bEnableRootMotion, 11)
139-
DROP_INT8(12, 13, 14, 15)
140-
MAP(AuthoredSyncMarkers, 16)
141-
MAP(BakedPerBoneCustomAttributeData, 17)
148+
MAP(Interpolation, 9)
149+
MAP(bEnableRootMotion, 10)
150+
DROP_INT8(11, 12, 13, 14)
151+
MAP(AuthoredSyncMarkers, 15)
152+
MAP(BakedPerBoneCustomAttributeData, 16)
142153
END
143154

144155
BEGIN("UAnimationAsset")
@@ -147,6 +158,7 @@ BEGIN("UAnimationAsset")
147158
DROP_OBJ_ARRAY(2) // AssetUserData
148159
END
149160

161+
// UTexture2D
150162
BEGIN("UTexture2D")
151163
DROP_INT8(2) // uint8 bTemporarilyDisableStreaming:1
152164
DROP_INT8(3) // TEnumAsByte<enum TextureAddress> AddressX
@@ -161,6 +173,7 @@ BEGIN("UTexture3")
161173
DROP_OBJ_ARRAY(14) // AssetUserData
162174
END
163175

176+
// UMaterialInstance
164177
BEGIN("UMaterialInstance")
165178
MAP(Parent, 9)
166179
DROP_INT8(10, 11)
@@ -174,6 +187,7 @@ BEGIN("UMaterialInstance")
174187
DROP_OBJ_ARRAY(20) //todo: TArray<UObject*> CachedReferencedTextures
175188
END
176189

190+
// UMaterial
177191
BEGIN("UMaterial3")
178192
// known properties
179193
MAP(BlendMode, 17)
@@ -278,13 +292,18 @@ static const ParentInfo ParentData[] =
278292
{ "UTexture2D", "UTexture3", 6 },
279293
{ "UTexture3", "UStreamableRenderAsset", 15 },
280294
// Mesh classes
295+
{ "USkeletalMesh4", "UStreamableRenderAsset", 29, GAME_UE4(27) },
281296
{ "USkeletalMesh4", "UStreamableRenderAsset", 28 },
297+
{ "UStaticMesh4", "UStreamableRenderAsset", 26, GAME_UE4(27) },
282298
{ "UStaticMesh4", "UStreamableRenderAsset", 25 },
283299
// Material classes
284300
{ "UMaterialInstanceConstant", "UMaterialInstance", 1 }, // contains just a single UObject* property
285301
{ "UMaterialInstance", "UMaterialInterface", 21 },
302+
{ "UMaterial3", "UMaterialInterface", 119, GAME_UE4(27) },
286303
{ "UMaterial3", "UMaterialInterface", 117 },
287-
{ "UAnimSequence4", "UAnimSequenceBase", 18 },
304+
// Animation classes
305+
{ "UAnimSequence4", "UAnimSequenceBase", 18, GAME_UE4(27) },
306+
{ "UAnimSequence4", "UAnimSequenceBase", 17 },
288307
{ "UAnimSequenceBase", "UAnimationAsset", 4 },
289308
// Structures
290309
{ "FStaticSwitchParameter", "FStaticParameterBase", 1 },

Unreal/UnrealMesh/UnMesh4.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@
5353
#error MAX_STATIC_UV_SETS_UE4 too large
5454
#endif
5555

56+
// This is a CVar in UE4.27+. Set to false by default, some games might have it set to "true".
57+
static bool KeepMobileMinLODSettingOnDesktop = false;
5658

5759
/*-----------------------------------------------------------------------------
5860
Common data types
@@ -1831,7 +1833,7 @@ void USkeletalMesh4::Serialize(FArchive &Ar)
18311833
bool bCooked;
18321834
Ar << bCooked;
18331835

1834-
if (Ar.Game >= GAME_UE4(27))
1836+
if (Ar.Game >= GAME_UE4(27) && KeepMobileMinLODSettingOnDesktop)
18351837
{
18361838
// The serialization of this variable is cvar-dependent in UE4, so there's no clear way to understand
18371839
// if it should be serialize in our code or not.
@@ -2728,7 +2730,7 @@ void UStaticMesh4::Serialize(FArchive &Ar)
27282730
// Note: code below still contains 'if (bCooked)' switches, this is because the same
27292731
// code could be used to read data from DDC, for non-cooked assets.
27302732
DBG_STAT("Serializing RenderData\n");
2731-
if (Ar.Game >= GAME_UE4(27))
2733+
if (Ar.Game >= GAME_UE4(27) && KeepMobileMinLODSettingOnDesktop)
27322734
{
27332735
// The serialization of this variable is cvar-dependent in UE4, so there's no clear way to understand
27342736
// if it should be serialize in our code or not.

0 commit comments

Comments
 (0)