diff options
author | Jacques Lucke <jacques@blender.org> | 2020-03-04 18:47:18 +0300 |
---|---|---|
committer | Jacques Lucke <jacques@blender.org> | 2020-03-04 18:48:37 +0300 |
commit | 765f2a1bcaa70e28afd73162e4d6ec1493d13ab2 (patch) | |
tree | a6f09e744440bccb05e84ef636f884e04746d014 /source | |
parent | a22573e243d7eeda7c10c9afc59377d474c74e5e (diff) |
Fix T71578: knife tool draws some points incorrectly
D6417 by @fbessou
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/editors/mesh/editmesh_knife.c | 16 |
1 files changed, 10 insertions, 6 deletions
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); |