Skip to content

Commit 88367d0

Browse files
committed
update static mesh and texture parsing for ue 5.6.1
1 parent 5d38ea5 commit 88367d0

10 files changed

Lines changed: 51 additions & 17 deletions

File tree

libsave/include/SatisfactorySave/GameTypes/UE/Core/Math/Box.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,5 @@ namespace SatisfactorySave {
2020
};
2121

2222
using FBox = TBox<double>;
23+
using FBox3f = TBox<float>;
2324
} // namespace SatisfactorySave

libsave/include/SatisfactorySave/GameTypes/UE/Core/Math/IntVector.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,6 @@ namespace SatisfactorySave {
1919
};
2020

2121
using FInt32Vector3 = TIntVector3<int32_t>;
22+
using FInt32Vector = FInt32Vector3;
2223
using FIntVector = FInt32Vector3;
2324
} // namespace SatisfactorySave

libsave/include/SatisfactorySave/GameTypes/UE/Core/Math/Vector2D.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,5 @@ namespace SatisfactorySave {
1616
};
1717

1818
using FVector2D = TVector2<double>;
19+
using FVector2f = TVector2<float>;
1920
} // namespace SatisfactorySave

libsave/include/SatisfactorySave/GameTypes/UE/Engine/DistanceFieldAtlas.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@
1414
namespace SatisfactorySave {
1515
class SATISFACTORYSAVE_API FSparseDistanceFieldMip {
1616
public:
17-
FIntVector IndirectionDimensions;
17+
FInt32Vector IndirectionDimensions;
1818
int32_t NumDistanceFieldBricks = 0;
19-
FVector VolumeToVirtualUVScale;
20-
FVector VolumeToVirtualUVAdd;
21-
FVector2D DistanceFieldToVolumeScaleBias;
19+
FVector3f VolumeToVirtualUVScale;
20+
FVector3f VolumeToVirtualUVAdd;
21+
FVector2f DistanceFieldToVolumeScaleBias;
2222
uint32_t BulkOffset = 0;
2323
uint32_t BulkSize = 0;
2424

@@ -35,7 +35,7 @@ namespace SatisfactorySave {
3535

3636
class SATISFACTORYSAVE_API FDistanceFieldVolumeData {
3737
public:
38-
FBox LocalSpaceMeshBounds;
38+
FBox3f LocalSpaceMeshBounds;
3939
bool bMostlyTwoSided;
4040
std::array<FSparseDistanceFieldMip, /*DistanceField::NumMips*/ 3> Mips;
4141
std::vector<uint8_t> AlwaysLoadedMip;

libsave/include/SatisfactorySave/GameTypes/UE/Engine/EngineUtils.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ namespace SatisfactorySave {
3232
}
3333

3434
void validateOnlyEditorDataIsStripped() const {
35-
if (GlobalStripFlags != 1 || ClassStripFlags != 0) {
35+
if (GlobalStripFlags != 5 || ClassStripFlags != 0) {
3636
throw std::runtime_error("FStripDataFlags has unimplemented flags set!");
3737
}
3838
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#pragma once
2+
3+
#include <array>
4+
5+
#include "../../../IO/Archive/Archive.h"
6+
#include "satisfactorysave_export.h"
7+
8+
namespace SatisfactorySave {
9+
struct SATISFACTORYSAVE_API FMatrix3x4 {
10+
public:
11+
std::array<float, 12> M;
12+
13+
void serialize(Archive& ar) {
14+
ar << M;
15+
}
16+
};
17+
} // namespace SatisfactorySave

libsave/include/SatisfactorySave/GameTypes/UE/Engine/Rendering/NaniteResources.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include "../../Core/Math/Vector.h"
88
#include "../../Core/Math/Vector4.h"
99
#include "../../CoreUObject/Serialization/BulkData.h"
10+
#include "../Matrix3x4.h"
1011
#include "satisfactorysave_export.h"
1112

1213
#define NANITE_MAX_BVH_NODE_FANOUT_BITS 2
@@ -71,13 +72,13 @@ namespace SatisfactorySave {
7172
std::vector<uint32_t> HierarchyRootOffsets;
7273
std::vector<FPageStreamingState> PageStreamingStates;
7374
std::vector<uint32_t> PageDependencies;
75+
std::vector<FMatrix3x4> AssemblyTransforms;
76+
FBoxSphereBounds3f MeshBounds;
7477
uint32_t NumRootPages = 0;
7578
int32_t PositionPrecision = 0;
7679
int32_t NormalPrecision = 0;
7780
uint32_t NumInputTriangles = 0;
7881
uint32_t NumInputVertices = 0;
79-
uint16_t NumInputMeshes = 0;
80-
uint16_t NumInputTexCoords = 0;
8182
uint32_t NumClusters = 0;
8283
uint32_t ResourceFlags = 0;
8384

@@ -96,14 +97,14 @@ namespace SatisfactorySave {
9697
ar << HierarchyNodes;
9798
ar << HierarchyRootOffsets;
9899
ar << PageDependencies;
100+
ar << AssemblyTransforms;
101+
ar << MeshBounds;
99102
ar << ImposterAtlas;
100103
ar << NumRootPages;
101104
ar << PositionPrecision;
102105
ar << NormalPrecision;
103106
ar << NumInputTriangles;
104107
ar << NumInputVertices;
105-
ar << NumInputMeshes;
106-
ar << NumInputTexCoords;
107108
ar << NumClusters;
108109
}
109110
};

libsave/include/SatisfactorySave/GameTypes/UE/Engine/StaticMeshResources.h

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ namespace SatisfactorySave {
7777
};
7878

7979
std::vector<FStaticMeshSection> Sections;
80+
FBoxSphereBounds SourceMeshBounds;
8081
float MaxDeviation = 0.0f;
8182
FStaticMeshVertexBuffers VertexBuffers;
8283
FRawStaticIndexBuffer IndexBuffer;
@@ -89,12 +90,13 @@ namespace SatisfactorySave {
8990
FCardRepresentationData CardRepresentationData;
9091
FDistanceFieldVolumeData DistanceFieldData;
9192

92-
// https://github.com/EpicGames/UnrealEngine/blob/4.26.2-release/Engine/Source/Runtime/Engine/Private/StaticMesh.cpp#L649
93+
// https://github.com/EpicGames/UnrealEngine/blob/5.6.1-release/Engine/Source/Runtime/Engine/Private/StaticMesh.cpp#L791
9394
void serialize(Archive& ar) {
9495
FStripDataFlags dataFlags;
9596
ar << dataFlags;
9697

9798
ar << Sections;
99+
ar << SourceMeshBounds;
98100
ar << MaxDeviation;
99101

100102
bool bIsLODCookedOut = false;
@@ -106,6 +108,9 @@ namespace SatisfactorySave {
106108
bool bInlined = false;
107109
ar << bInlined;
108110

111+
bool bHasRayTracingGeometry = false;
112+
ar << bHasRayTracingGeometry;
113+
109114
FStaticMeshBuffersSize TmpBuffersSize;
110115

111116
if (bInlined) {
@@ -162,15 +167,20 @@ namespace SatisfactorySave {
162167
uint8_t NumInlinedLODs = 0;
163168
FResources NaniteResources;
164169
FBoxSphereBounds Bounds;
165-
bool bLODsShareStaticLighting = false;
166170
std::array<FPerPlatformFloat, /*MAX_STATIC_MESH_LODS*/ 8> ScreenSize;
167171

168-
// https://github.com/EpicGames/UnrealEngine/blob/5.3.2-release/Engine/Source/Runtime/Engine/Private/StaticMesh.cpp#L1683
172+
// https://github.com/EpicGames/UnrealEngine/blob/5.6.1-release/Engine/Source/Runtime/Engine/Private/StaticMesh.cpp#L2390
169173
void serialize(Archive& ar) {
170174
ar << LODResources;
171175
ar << NumInlinedLODs;
172176
ar << NaniteResources;
173177

178+
bool bHasRayTracingProxy = false;
179+
ar << bHasRayTracingProxy;
180+
if (bHasRayTracingProxy) {
181+
throw std::runtime_error("FStaticMeshRenderData: bHasRayTracingProxy == true not implemented!");
182+
}
183+
174184
// FStaticMeshRenderData::SerializeInlineDataRepresentations
175185
FStripDataFlags StripFlags;
176186
ar << StripFlags;
@@ -199,7 +209,9 @@ namespace SatisfactorySave {
199209
}
200210

201211
ar << Bounds;
202-
ar << bLODsShareStaticLighting;
212+
213+
uint8_t bRenderDataFlags = 0;
214+
ar << bRenderDataFlags;
203215

204216
for (auto& screenSizeEntry : ScreenSize) {
205217
ar << screenSizeEntry;

libsave/src/GameTypes/UE/Engine/Engine/StaticMesh.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#include "GameTypes/FactoryGame/FGObjectReference.h"
44
#include "GameTypes/UE/Engine/EngineUtils.h"
55

6-
// https://github.com/EpicGames/UnrealEngine/blob/5.3.2-release/Engine/Source/Runtime/Engine/Private/StaticMesh.cpp#L5534
6+
// https://github.com/EpicGames/UnrealEngine/blob/5.6.1-release/Engine/Source/Runtime/Engine/Private/StaticMesh.cpp#L6936
77
void SatisfactorySave::UStaticMesh::serialize(Archive& ar) {
88
if (!ar.isIArchive()) {
99
throw std::runtime_error("Only IStreamArchive support implemented!");
@@ -39,7 +39,8 @@ void SatisfactorySave::UStaticMesh::serialize(Archive& ar) {
3939
bool bHasSpeedTreeWind = false;
4040
ar << bHasSpeedTreeWind;
4141
if (bHasSpeedTreeWind) {
42-
throw std::runtime_error("bHasSpeedTreeWind == true not implemented!");
42+
// TODO bHasSpeedTreeWind == true not implemented! Stop parsing here for now.
43+
return;
4344
}
4445

4546
ar << StaticMaterials;

libsave/src/GameTypes/UE/Engine/Engine/Texture2D.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ void SatisfactorySave::UTexture2D::serialize(Archive& ar) {
1111
UObject::serialize(ar);
1212

1313
// UTexture::Serialize
14-
// https://github.com/EpicGames/UnrealEngine/blob/4.26.2-release/Engine/Source/Runtime/Engine/Private/Texture.cpp#L366
14+
// https://github.com/EpicGames/UnrealEngine/blob/5.6.1-release/Engine/Source/Runtime/Engine/Private/Texture.cpp#L1055
1515

1616
FStripDataFlags flags;
1717
ar << flags;

0 commit comments

Comments
 (0)