[Bf-blender-cvs] [af8a54b] master: Fix for potential bug with new GP Fill
Joshua Leung
noreply at git.blender.org
Sun May 8 15:11:23 CEST 2016
Commit: af8a54bd8dd40b9a9bdad60f6d58dc920dcd0b87
Author: Joshua Leung
Date: Fri Apr 29 03:25:48 2016 +1200
Branches: master
https://developer.blender.org/rBaf8a54bd8dd40b9a9bdad60f6d58dc920dcd0b87
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.
===================================================================
M source/blender/editors/gpencil/drawgpencil.c
===================================================================
diff --git a/source/blender/editors/gpencil/drawgpencil.c b/source/blender/editors/gpencil/drawgpencil.c
index c885842..2ba9a79 100644
--- a/source/blender/editors/gpencil/drawgpencil.c
+++ b/source/blender/editors/gpencil/drawgpencil.c
@@ -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];
More information about the Bf-blender-cvs
mailing list