Skip to content

Commit c4fdc5e

Browse files
committed
Finalized Days Gone support
1 parent 5865b94 commit c4fdc5e

File tree

7 files changed

+110
-23
lines changed

7 files changed

+110
-23
lines changed

Tools/CompatTable/table.ini

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,13 @@ THQ Nordic
8282
https://en.wikipedia.org/wiki/Darksiders_Genesis
8383
https://www.gildor.org/smf/index.php/topic,6903.0.html
8484

85+
[Days Gone (PS4)]
86+
Y Y Y Y UE4.11
87+
SIE Bend Studio
88+
https://en.wikipedia.org/wiki/Days_Gone
89+
https://www.gildor.org/smf/index.php/topic,6602.0.html
90+
; -game=daysgone
91+
8592
[Devil's Hunt]
8693
Y Y Y Y UE4.21
8794
Layopi Games

Unreal/UnCore.h

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1008,6 +1008,27 @@ struct FVector
10081008
X = _X; Y = _Y; Z = _Z;
10091009
}
10101010

1011+
void Add(const FVector& Other)
1012+
{
1013+
X += Other.X;
1014+
Y += Other.Y;
1015+
Z += Other.Z;
1016+
}
1017+
1018+
void Subtract(const FVector& Other)
1019+
{
1020+
X -= Other.X;
1021+
Y -= Other.Y;
1022+
Z -= Other.Z;
1023+
}
1024+
1025+
void Scale(const FVector& Other)
1026+
{
1027+
X *= Other.X;
1028+
Y *= Other.Y;
1029+
Z *= Other.Z;
1030+
}
1031+
10111032
void Scale(float value)
10121033
{
10131034
X *= value; Y *= value; Z *= value;

Unreal/UnMesh4.cpp

Lines changed: 33 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -73,23 +73,6 @@ struct FColorVertexBuffer4
7373
}
7474
};
7575

76-
#if DAYSGONE
77-
78-
struct FDGPackedVector
79-
{
80-
FVectorFixed48 V;
81-
uint16 Pad;
82-
83-
friend FArchive& operator<<(FArchive& Ar, FDGPackedVector& PV)
84-
{
85-
return Ar << PV.V << PV.Pad;
86-
}
87-
};
88-
89-
SIMPLE_TYPE(FDGPackedVector, uint16);
90-
91-
#endif // DAYSGONE
92-
9376
struct FPositionVertexBuffer4
9477
{
9578
TArray<FVector> Verts;
@@ -106,24 +89,29 @@ struct FPositionVertexBuffer4
10689
#if DAYSGONE
10790
if (Ar.Game == GAME_DaysGone)
10891
{
109-
// This happens only for StaticMesh
92+
// This is used only for StaticMesh
11093
if (S.Stride == 8)
11194
{
112-
TArray<FDGPackedVector> PackedVerts;
95+
TArray<FDGPackedVector64> PackedVerts;
11396
PackedVerts.BulkSerialize(Ar);
11497
S.Verts.AddUninitialized(PackedVerts.Num());
11598
for (int i = 0; i < PackedVerts.Num(); i++)
11699
{
117-
S.Verts[i] = PackedVerts[i].V;
100+
S.Verts[i] = PackedVerts[i];
118101
}
119102
//todo: should use some bounds to unpack positions, almost works but a bit distorted data
120103
return Ar;
121104
}
122105
else if (S.Stride == 4)
123106
{
124-
TArray<uint32> PackedVerts;
107+
TArray<FDGPackedVector32> PackedVerts;
125108
// No idea which format is used here
126109
PackedVerts.BulkSerialize(Ar);
110+
S.Verts.AddUninitialized(PackedVerts.Num());
111+
for (int i = 0; i < PackedVerts.Num(); i++)
112+
{
113+
S.Verts[i] = PackedVerts[i];
114+
}
127115
//todo: should use some bounds to unpack positions; position is 32-bit, with full use of all bits
128116
return Ar;
129117
}
@@ -2334,7 +2322,7 @@ void UStaticMesh4::Serialize(FArchive &Ar)
23342322
#if DAYSGONE
23352323
if (Ar.Game == GAME_DaysGone)
23362324
{
2337-
int32 unk;
2325+
TArray<int32> unk;
23382326
Ar << unk;
23392327
}
23402328
#endif // DAYSGONE
@@ -2506,6 +2494,29 @@ void UStaticMesh4::Serialize(FArchive &Ar)
25062494
// remaining is SpeedTree data
25072495
DROP_REMAINING_DATA(Ar);
25082496

2497+
#if DAYSGONE
2498+
if (Ar.Game == GAME_DaysGone)
2499+
{
2500+
// This game has packed positions, we should unpack it. When loading positions,
2501+
// we're converting values to range 0..1. Now we should use Bounds for it.
2502+
FVector Offset = Bounds.Origin;
2503+
Offset.Subtract(Bounds.BoxExtent);
2504+
FVector Scale = Bounds.BoxExtent;
2505+
Scale.Scale(2);
2506+
for (FStaticMeshLODModel4& Lod : Lods)
2507+
{
2508+
if (Lod.PositionVertexBuffer.Stride == 8 || Lod.PositionVertexBuffer.Stride == 4)
2509+
{
2510+
for (FVector& V : Lod.PositionVertexBuffer.Verts)
2511+
{
2512+
V.Scale(Scale);
2513+
V.Add(Offset);
2514+
}
2515+
}
2516+
}
2517+
}
2518+
#endif // DAYSGONE
2519+
25092520
if (bCooked)
25102521
{
25112522
ConvertMesh();

Unreal/UnMeshTypes.h

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,6 @@ struct FQuatFloat48NoW_Argo
535535

536536
SIMPLE_TYPE(FQuatFloat48NoW_Argo, uint16)
537537

538-
539538
#endif // ARGONAUTS
540539

541540

@@ -692,4 +691,50 @@ struct FQuatPolarEncoded48
692691
#endif // BORDERLANDS
693692

694693

694+
#if DAYSGONE
695+
696+
struct FDGPackedVector32
697+
{
698+
unsigned X:10, Y:10, Z:10;
699+
700+
friend FArchive& operator<<(FArchive& Ar, FDGPackedVector32& PV)
701+
{
702+
return Ar << GET_DWORD(PV);
703+
}
704+
705+
operator FVector() const
706+
{
707+
FVector V;
708+
V.X = X / 1024.0f;
709+
V.Y = Y / 1024.0f;
710+
V.Z = Z / 1024.0f;
711+
return V;
712+
}
713+
};
714+
715+
SIMPLE_TYPE(FDGPackedVector32, uint32);
716+
717+
struct FDGPackedVector64
718+
{
719+
uint16 X, Y, Z, W;
720+
721+
friend FArchive& operator<<(FArchive& Ar, FDGPackedVector64& PV)
722+
{
723+
return Ar << PV.X << PV.Y << PV.Z << PV.W;
724+
}
725+
726+
operator FVector() const
727+
{
728+
FVector V;
729+
V.X = X / 65535.0f;
730+
V.Y = Y / 65535.0f;
731+
V.Z = Z / 65535.0f;
732+
return V;
733+
}
734+
};
735+
736+
SIMPLE_TYPE(FDGPackedVector64, uint16);
737+
738+
#endif // DAYSGONE
739+
695740
#endif // __UNMESH_TYPES_H__

readme.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,9 @@ ooz
216216

217217
Changes
218218
~~~~~~~
219+
05.01.2020
220+
- added Days Gone (PS4) support, required game override -game=daysgone
221+
219222
29.12.2019
220223
- added option to disable MorphTarget loading: available in UI and with -nomorph command line option
221224

umodel

0 Bytes
Binary file not shown.

umodel.exe

1 KB
Binary file not shown.

0 commit comments

Comments
 (0)