Fix for potential bug with new GP Fill
While trying to track down why I still keep getting some random "extra" triangles showing up when reloading files with fills, I noticed that there's an index mismatch here that may cause problems in some rare cases: There are "gps->totpoints" items in tmp_triangles, but there should only be "gps->tot_triangles" triangles in the gps->triangles array. If for whatever reason some of the triangles in tmp_triangles are invalid, this could have meant that while a tmp_triangles candidate was skipped, a corresponding slot for a valid triangle also got skipped.
This commit is contained in:
@@ -408,12 +408,15 @@ static void gp_triangulate_stroke_fill(bGPDstroke *gps)
|
||||
gps->triangles = MEM_recallocN(gps->triangles, sizeof(bGPDtriangle) * gps->tot_triangles);
|
||||
}
|
||||
|
||||
for (int i = 0; i < gps->tot_triangles; i++) {
|
||||
int triangle_index = 0;
|
||||
int i;
|
||||
|
||||
for (i = 0; (i < gps->totpoints) && (triangle_index < gps->tot_triangles); i++) {
|
||||
if ((tmp_triangles[i][0] >= 0) && (tmp_triangles[i][0] < gps->totpoints) &&
|
||||
(tmp_triangles[i][1] >= 0) && (tmp_triangles[i][1] < gps->totpoints) &&
|
||||
(tmp_triangles[i][2] >= 0) && (tmp_triangles[i][2] < gps->totpoints))
|
||||
{
|
||||
bGPDtriangle *stroke_triangle = &gps->triangles[i];
|
||||
bGPDtriangle *stroke_triangle = &gps->triangles[triangle_index++];
|
||||
|
||||
stroke_triangle->v1 = tmp_triangles[i][0];
|
||||
stroke_triangle->v2 = tmp_triangles[i][1];
|
||||
|
Reference in New Issue
Block a user