Skip to content

Commit

Permalink
VTXNORMS chunk at the end.
Browse files Browse the repository at this point in the history
  • Loading branch information
floxay committed Jul 21, 2022
1 parent 9ecbbfe commit 4f58f51
Showing 1 changed file with 26 additions and 17 deletions.
43 changes: 26 additions & 17 deletions Exporters/ExportPsk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ static void ExportCommonMeshData
guard(ExportCommonMeshData);

// using 'static' here to avoid zero-filling unused fields
static VChunkHeader MainHdr, PtsHdr, WedgHdr, FacesHdr, MatrHdr, NormHdr;
static VChunkHeader MainHdr, PtsHdr, WedgHdr, FacesHdr, MatrHdr;
int i;

#define SECT(n) (Sections + n)
Expand Down Expand Up @@ -247,22 +247,6 @@ static void ExportCommonMeshData
}
unguard;

guard(Normals);
NormHdr.DataCount = Share.Normals.Num();
NormHdr.DataSize = sizeof(CVec3);
SAVE_CHUNK(NormHdr, "VTXNORMS");
for (i = 0; i < Share.Normals.Num(); i++)
{
CVec3 Normal;
Unpack(Normal, Share.Normals[i]);
Normal.Normalize();
#if MIRROR_MESH
Normal.Y = -Normal.Y;
#endif
Ar << Normal.X << Normal.Y << Normal.Z;
}
unguard;

unguard;
}

Expand Down Expand Up @@ -322,6 +306,29 @@ static void ExportExtraUV
unguard;
}

static void ExportVertexNormals(FArchive &Ar, const TArray<CPackedNormal> &Normals)
{
guard(ExportVertexNormals);

static VChunkHeader NormalHdr;
NormalHdr.DataCount = Normals.Num();
NormalHdr.DataSize = sizeof(CVec3);

SAVE_CHUNK(NormalHdr, "VTXNORMS");
for (int i = 0; i < Normals.Num(); i++)
{
CVec3 Normal;
Unpack(Normal, Normals[i]);
Normal.Normalize();
#if MIRROR_MESH
Normal.Y = -Normal.Y;
#endif
Ar << Normal.X << Normal.Y << Normal.Z;
}

unguard;
}

static void CopyBoneName(char* Dst, int DstLen, const char* Src)
{
int NameLength = strlen(Src);
Expand Down Expand Up @@ -461,6 +468,7 @@ static void ExportSkeletalMeshLod(const CSkeletalMesh &Mesh, const CSkelMeshLod

ExportVertexColors(Ar, Lod.VertexColors, Lod.NumVerts);
ExportExtraUV(Ar, Lod.ExtraUV, Lod.NumVerts, Lod.NumTexCoords);
ExportVertexNormals(Ar, Share.Normals);

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

ExportVertexColors(Ar, Lod.VertexColors, Lod.NumVerts);
ExportExtraUV(Ar, Lod.ExtraUV, Lod.NumVerts, Lod.NumTexCoords);
ExportVertexNormals(Ar, Share.Normals);

unguard;
}
Expand Down

0 comments on commit 4f58f51

Please sign in to comment.