Whinarn / UnityMeshSimplifier

Mesh simplification for Unity.
MIT License
1.76k stars 277 forks source link

Seems like normals are inverted (fix in comment) #17

Closed kalineh closed 5 years ago

kalineh commented 5 years ago

I'm not sure if it's our meshes in particular that are setup causing the inverted normals, but they were backwards -- I just changed this to fix locally:

+++ UnityMeshSimplifier/UnityMeshSimplifier-master/Runtime/MeshSimplifier.cs
@@ -1385,7 +1385,7 @@ private void UpdateMesh(int iteration)
                     p20 = p2 - p0;
                     Vector3d.Cross(ref p10, ref p20, out n);
                     n.Normalize();
-                    triangles[i].n = n;
+                    triangles[i].n = -n;

                     sm = new SymmetricMatrix(n.x, n.y, n.z, -Vector3d.Dot(ref n, ref p0));
                     vertices[v0].q += sm;
Whinarn commented 5 years ago

Hi @kalineh,

You closed this ticket. Does that mean that you were mistaken, or could you please explain why you closed it?

Thanks.