Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoshua Leung <aligorith@gmail.com>2016-04-28 18:25:48 +0300
committerJoshua Leung <aligorith@gmail.com>2016-05-08 15:53:49 +0300
commitaf8a54bd8dd40b9a9bdad60f6d58dc920dcd0b87 (patch)
tree864366f7aba946207f3ccc4a4d7a0807cc2535d2 /source/blender/editors/gpencil
parentf5ddcfeb031176becb40c2bd9ad226466c6ddff7 (diff)
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.
Diffstat (limited to 'source/blender/editors/gpencil')
-rw-r--r--source/blender/editors/gpencil/drawgpencil.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/source/blender/editors/gpencil/drawgpencil.c b/source/blender/editors/gpencil/drawgpencil.c
index c885842e756..2ba9a79eff3 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];