Skip to content

Commit 87026fc

Browse files
committed
VTXNORMS chunk at the end.
1 parent 9ecbbfe commit 87026fc

File tree

1 file changed

+25
-16
lines changed

1 file changed

+25
-16
lines changed

Exporters/ExportPsk.cpp

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -247,22 +247,6 @@ static void ExportCommonMeshData
247247
}
248248
unguard;
249249

250-
guard(Normals);
251-
NormHdr.DataCount = Share.Normals.Num();
252-
NormHdr.DataSize = sizeof(CVec3);
253-
SAVE_CHUNK(NormHdr, "VTXNORMS");
254-
for (i = 0; i < Share.Normals.Num(); i++)
255-
{
256-
CVec3 Normal;
257-
Unpack(Normal, Share.Normals[i]);
258-
Normal.Normalize();
259-
#if MIRROR_MESH
260-
Normal.Y = -Normal.Y;
261-
#endif
262-
Ar << Normal.X << Normal.Y << Normal.Z;
263-
}
264-
unguard;
265-
266250
unguard;
267251
}
268252

@@ -322,6 +306,29 @@ static void ExportExtraUV
322306
unguard;
323307
}
324308

309+
static void ExportVertexNormals(FArchive &Ar, const TArray<CPackedNormal> &Normals)
310+
{
311+
guard(ExportVertexNormals);
312+
313+
static VChunkHeader NormalHdr;
314+
NormalHdr.DataCount = Normals.Num();
315+
NormalHdr.DataSize = sizeof(CVec3);
316+
317+
SAVE_CHUNK(NormalHdr, "VTXNORMS");
318+
for (int i = 0; i < Normals.Num(); i++)
319+
{
320+
CVec3 Normal;
321+
Unpack(Normal, Normals[i]);
322+
Normal.Normalize();
323+
#if MIRROR_MESH
324+
Normal.Y = -Normal.Y;
325+
#endif
326+
Ar << Normal.X << Normal.Y << Normal.Z;
327+
}
328+
329+
unguard;
330+
}
331+
325332
static void CopyBoneName(char* Dst, int DstLen, const char* Src)
326333
{
327334
int NameLength = strlen(Src);
@@ -461,6 +468,7 @@ static void ExportSkeletalMeshLod(const CSkeletalMesh &Mesh, const CSkelMeshLod
461468

462469
ExportVertexColors(Ar, Lod.VertexColors, Lod.NumVerts);
463470
ExportExtraUV(Ar, Lod.ExtraUV, Lod.NumVerts, Lod.NumTexCoords);
471+
ExportVertexNormals(Ar, Share.Normals);
464472

465473
/* if (!GExportPskx) // nothing more to write
466474
return;
@@ -900,6 +908,7 @@ static void ExportStaticMeshLod(const CStaticMeshLod &Lod, FArchive &Ar)
900908

901909
ExportVertexColors(Ar, Lod.VertexColors, Lod.NumVerts);
902910
ExportExtraUV(Ar, Lod.ExtraUV, Lod.NumVerts, Lod.NumTexCoords);
911+
ExportVertexNormals(Ar, Share.Normals);
903912

904913
unguard;
905914
}

0 commit comments

Comments
 (0)