Skip to content

Commit

Permalink
fix(mesh): bug related to degenerated triangle when using smart linking
Browse files Browse the repository at this point in the history
Reference array is not initialized properly for a degenerated triangle when using smart linking
Smart linking can merge two very close triangle vertices together. For instance a triangle T(a,b,c)
could become T(a,a,c) after smart linking. The UpdateReferences() function do not update the
refs[] array correctly in this case because it overwrites the same ref cell twice and leaves the
second ref cell not initialized because the indexer is updated only at the end of the function.
  • Loading branch information
is3D-1 authored May 1, 2020
1 parent 8e82854 commit e9d5def
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions Runtime/MeshSimplifier.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#region License
#region License
/*
MIT License
Expand Down Expand Up @@ -1176,19 +1176,15 @@ private void UpdateReferences()
int v1 = triangles[i].v1;
int v2 = triangles[i].v2;
int start0 = vertices[v0].tstart;
int count0 = vertices[v0].tcount;
int count0 = vertices[v0].tcount++;
int start1 = vertices[v1].tstart;
int count1 = vertices[v1].tcount;
int count1 = vertices[v1].tcount++;
int start2 = vertices[v2].tstart;
int count2 = vertices[v2].tcount;
int count2 = vertices[v2].tcount++;

refs[start0 + count0].Set(i, 0);
refs[start1 + count1].Set(i, 1);
refs[start2 + count2].Set(i, 2);

++vertices[v0].tcount;
++vertices[v1].tcount;
++vertices[v2].tcount;
}
}
#endregion
Expand Down

0 comments on commit e9d5def

Please sign in to comment.