1
0
mirror of synced 2024-11-14 19:17:39 +01:00

Prevent duplicate verts from transforming UVs multiple times

This commit is contained in:
KillzXGaming 2020-01-18 17:41:36 -05:00
parent 8fc7693a51
commit 1302a096b0

View File

@ -272,6 +272,7 @@ namespace Toolbox.Library
if (settings.TransformColorUVs) if (settings.TransformColorUVs)
{ {
List<Vertex> transformedVertices = new List<Vertex>();
foreach (var poly in mesh.PolygonGroups) foreach (var poly in mesh.PolygonGroups)
{ {
var mat = poly.Material; var mat = poly.Material;
@ -288,16 +289,22 @@ namespace Toolbox.Library
if (diffuse != null) if (diffuse != null)
transform = diffuse.Transform; transform = diffuse.Transform;
Console.WriteLine("transform scale " + transform.Scale); var vertexA = mesh.vertices[faces[v]];
Console.WriteLine("transform translate " + transform.Translate); var vertexB = mesh.vertices[faces[v+1]];
var vertexC = mesh.vertices[faces[v+2]];
mesh.vertices[faces[v]].uv0 *= transform.Scale; if (!transformedVertices.Contains(vertexA)) {
mesh.vertices[faces[v + 1]].uv0 *= transform.Scale; vertexA.uv0 = (vertexA.uv0 * transform.Scale) + transform.Translate;
mesh.vertices[faces[v + 2]].uv0 *= transform.Scale; transformedVertices.Add(vertexA);
}
mesh.vertices[faces[v]].uv0 += transform.Translate; if (!transformedVertices.Contains(vertexB)) {
mesh.vertices[faces[v + 1]].uv0 += transform.Translate; vertexB.uv0 = (vertexB.uv0 * transform.Scale) + transform.Translate;
mesh.vertices[faces[v + 2]].uv0 += transform.Translate; transformedVertices.Add(vertexB);
}
if (!transformedVertices.Contains(vertexC)) {
vertexC.uv0 = (vertexC.uv0 * transform.Scale) + transform.Translate;
transformedVertices.Add(vertexC);
}
} }
} }
} }