Skip to content

Commit e9d5def

Browse files
authored
fix(mesh): bug related to degenerated triangle when using smart linking
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.
1 parent 8e82854 commit e9d5def

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

Runtime/MeshSimplifier.cs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#region License
1+
#region License
22
/*
33
MIT License
44
@@ -1176,19 +1176,15 @@ private void UpdateReferences()
11761176
int v1 = triangles[i].v1;
11771177
int v2 = triangles[i].v2;
11781178
int start0 = vertices[v0].tstart;
1179-
int count0 = vertices[v0].tcount;
1179+
int count0 = vertices[v0].tcount++;
11801180
int start1 = vertices[v1].tstart;
1181-
int count1 = vertices[v1].tcount;
1181+
int count1 = vertices[v1].tcount++;
11821182
int start2 = vertices[v2].tstart;
1183-
int count2 = vertices[v2].tcount;
1183+
int count2 = vertices[v2].tcount++;
11841184

11851185
refs[start0 + count0].Set(i, 0);
11861186
refs[start1 + count1].Set(i, 1);
11871187
refs[start2 + count2].Set(i, 2);
1188-
1189-
++vertices[v0].tcount;
1190-
++vertices[v1].tcount;
1191-
++vertices[v2].tcount;
11921188
}
11931189
}
11941190
#endregion

0 commit comments

Comments
 (0)