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 20, 2022
1 parent 9ecbbfe commit 87026fc
Showing 1 changed file with 25 additions and 16 deletions.
41 changes: 25 additions & 16 deletions Exporters/ExportPsk.cpp
Original file line number Diff line number Diff line change
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 87026fc

Please sign in to comment.