From 765f2a1bcaa70e28afd73162e4d6ec1493d13ab2 Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Wed, 4 Mar 2020 16:47:18 +0100 Subject: Fix T71578: knife tool draws some points incorrectly D6417 by @fbessou --- source/blender/editors/mesh/editmesh_knife.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/mesh/editmesh_knife.c b/source/blender/editors/mesh/editmesh_knife.c index 93850abafea..705ebd324eb 100644 --- a/source/blender/editors/mesh/editmesh_knife.c +++ b/source/blender/editors/mesh/editmesh_knife.c @@ -1134,7 +1134,7 @@ static void knifetool_draw(const bContext *UNUSED(C), ARegion *UNUSED(ar), void if (kcd->totlinehit > 0) { KnifeLineHit *lh; - int i, v, vs; + int i, snapped_verts_count, other_verts_count; float fcol[4]; GPU_blend(true); @@ -1145,12 +1145,12 @@ static void knifetool_draw(const bContext *UNUSED(C), ARegion *UNUSED(ar), void GPU_vertbuf_data_alloc(vert, kcd->totlinehit); lh = kcd->linehits; - for (i = 0, v = 0, vs = kcd->totlinehit - 1; i < kcd->totlinehit; i++, lh++) { + for (i = 0, snapped_verts_count = 0, other_verts_count = 0; i < kcd->totlinehit; i++, lh++) { if (lh->v) { - GPU_vertbuf_attr_set(vert, pos, v++, lh->cagehit); + GPU_vertbuf_attr_set(vert, pos, snapped_verts_count++, lh->cagehit); } else { - GPU_vertbuf_attr_set(vert, pos, vs--, lh->cagehit); + GPU_vertbuf_attr_set(vert, pos, kcd->totlinehit - 1 - other_verts_count++, lh->cagehit); } } @@ -1163,13 +1163,17 @@ static void knifetool_draw(const bContext *UNUSED(C), ARegion *UNUSED(ar), void GPU_batch_uniform_4fv(batch, "color", fcol); GPU_matrix_bind(batch->interface); GPU_point_size(11); - GPU_batch_draw_advanced(batch, 0, v - 1, 0, 0); + if (snapped_verts_count > 0) { + GPU_batch_draw_advanced(batch, 0, snapped_verts_count, 0, 0); + } /* now draw the rest */ rgba_uchar_to_float(fcol, kcd->colors.curpoint_a); GPU_batch_uniform_4fv(batch, "color", fcol); GPU_point_size(7); - GPU_batch_draw_advanced(batch, vs + 1, kcd->totlinehit - (vs + 1), 0, 0); + if (other_verts_count > 0) { + GPU_batch_draw_advanced(batch, snapped_verts_count, other_verts_count, 0, 0); + } GPU_batch_program_use_end(batch); GPU_batch_discard(batch); -- cgit v1.2.3