Don't look for duplicate conditional verts.

This commit is contained in:
Leonardo Zide 2021-03-07 09:57:17 -08:00
parent b2880731db
commit b7740d9db1
2 changed files with 7 additions and 23 deletions

View file

@ -113,11 +113,6 @@ static bool lcCompareVertices(const lcVector3& Position1, const lcVector2& TexCo
return lcCompareVertices(Position1, Position2) && fabsf(TexCoord1.x - TexCoord2.x) < lcTexCoordEpsilon && fabsf(TexCoord1.y - TexCoord2.y) < lcTexCoordEpsilon;
}
static bool lcCompareConditionalVertices(const lcVector3* Position1, const lcVector3* Position2)
{
return lcCompareVertices(Position1[0], Position2[0]) && lcCompareVertices(Position1[1], Position2[1]) && lcCompareVertices(Position1[2], Position2[2]) && lcCompareVertices(Position1[3], Position2[3]);
}
lcLibraryMeshSection* lcMeshLoaderTypeData::AddSection(lcMeshPrimitiveType PrimitiveType, quint32 ColorCode, lcTexture* Texture)
{
for (std::unique_ptr<lcLibraryMeshSection>& Section : mSections)
@ -293,19 +288,8 @@ quint32 lcMeshLoaderTypeData::AddTexturedVertex(const lcVector3& Position, const
return mVertices.GetSize() - 1;
}
quint32 lcMeshLoaderTypeData::AddConditionalVertex(const lcVector3* Position, bool Optimize)
quint32 lcMeshLoaderTypeData::AddConditionalVertex(const lcVector3(&Position)[4])
{
if (Optimize)
{
for (int VertexIdx = mConditionalVertices.GetSize() - 1; VertexIdx >= 0; VertexIdx--)
{
lcMeshLoaderConditionalVertex& Vertex = mConditionalVertices[VertexIdx];
if (lcCompareConditionalVertices(Position, Vertex.Position))
return VertexIdx;
}
}
lcMeshLoaderConditionalVertex& Vertex = mConditionalVertices.Add();
Vertex.Position[0] = Position[0];
@ -316,7 +300,7 @@ quint32 lcMeshLoaderTypeData::AddConditionalVertex(const lcVector3* Position, bo
return mConditionalVertices.GetSize() - 1;
}
void lcMeshLoaderTypeData::ProcessLine(int LineType, quint32 ColorCode, bool WindingCCW, lcVector3* Vertices, bool Optimize)
void lcMeshLoaderTypeData::ProcessLine(int LineType, quint32 ColorCode, bool WindingCCW, lcVector3 (&Vertices)[4], bool Optimize)
{
lcMeshPrimitiveType PrimitiveTypes[4] = { LC_MESH_LINES, LC_MESH_TRIANGLES, LC_MESH_TRIANGLES, LC_MESH_CONDITIONAL_LINES };
lcMeshPrimitiveType PrimitiveType = PrimitiveTypes[LineType - 2];
@ -351,9 +335,9 @@ void lcMeshLoaderTypeData::ProcessLine(int LineType, quint32 ColorCode, bool Win
}
else if (LineType == 5)
{
Indices[0] = AddConditionalVertex(Vertices, Optimize);
Indices[0] = AddConditionalVertex(Vertices);
std::swap(Vertices[0], Vertices[1]);
Indices[1] = AddConditionalVertex(Vertices, Optimize);
Indices[1] = AddConditionalVertex(Vertices);
}
switch (LineType)
@ -663,7 +647,7 @@ void lcMeshLoaderTypeData::AddMeshData(const lcMeshLoaderTypeData& Data, const l
Position[2] = lcMul31(DataVertex.Position[2], Transform);
Position[3] = lcMul31(DataVertex.Position[3], Transform);
int Index = AddConditionalVertex(Position, true);
int Index = AddConditionalVertex(Position);
ConditionalRemap.Add(Index);
}

View file

@ -122,9 +122,9 @@ public:
quint32 AddVertex(const lcVector3& Position, const lcVector3& Normal, bool Optimize);
quint32 AddTexturedVertex(const lcVector3& Position, const lcVector2& TexCoord, bool Optimize);
quint32 AddTexturedVertex(const lcVector3& Position, const lcVector3& Normal, const lcVector2& TexCoord, bool Optimize);
quint32 AddConditionalVertex(const lcVector3* Position, bool Optimize);
quint32 AddConditionalVertex(const lcVector3 (&Position)[4]);
void ProcessLine(int LineType, quint32 ColorCode, bool WindingCCW, lcVector3* Vertices, bool Optimize);
void ProcessLine(int LineType, quint32 ColorCode, bool WindingCCW, lcVector3 (&Vertices)[4], bool Optimize);
void ProcessTexturedLine(int LineType, quint32 ColorCode, bool WindingCCW, const lcMeshLoaderTextureMap& Map, const lcVector3* Vertices, bool Optimize);
void AddMeshData(const lcMeshLoaderTypeData& Data, const lcMatrix44& Transform, quint32 CurrentColorCode, bool InvertWinding, bool InvertNormals, lcMeshLoaderTextureMap* TextureMap);