From 9547b76c2e8e0f6aa07858e94e4f0c404b86ac7d Mon Sep 17 00:00:00 2001 From: Jason Hays Date: Thu, 31 May 2012 17:22:52 +0000 Subject: This fixes a precision issue in multi-paint so that near zero values do not cause flickering as you paint. It also changes multi-paint's "zero weight color" to black again--it was unintentionally changed to red some time late last year when an aspect of the colors were changed. --- source/blender/blenkernel/intern/DerivedMesh.c | 4 ++-- source/blender/editors/sculpt_paint/paint_vertex.c | 8 +++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c index 5774dd7b1ba..7130776d05a 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.c +++ b/source/blender/blenkernel/intern/DerivedMesh.c @@ -1054,10 +1054,10 @@ static void calc_weightpaint_vert_color( } if (make_black) { /* TODO, theme color */ - r_col[3] = 0; + r_col[3] = 255; r_col[2] = 0; r_col[1] = 0; - r_col[0] = 255; + r_col[0] = 0; } else { CLAMP(input, 0.0f, 1.0f); diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c index e05191dad3b..88cf9b1b0dd 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex.c +++ b/source/blender/editors/sculpt_paint/paint_vertex.c @@ -1878,6 +1878,7 @@ static void do_weight_paint_vertex( float oldw; float neww; float testw = 0; + float observedChange = 0; float change = 0; float oldChange = 0; int i; @@ -1889,13 +1890,14 @@ static void do_weight_paint_vertex( wpi->brush_alpha_value, wpi->do_flip, do_multipaint_totsel); /* setup multi-paint */ - if (do_multipaint_totsel) { + observedChange = neww - oldw; + if (do_multipaint_totsel && observedChange) { dv_copy.dw = MEM_dupallocN(dv->dw); dv_copy.flag = dv->flag; dv_copy.totweight = dv->totweight; tdw = dw; tdw_prev = dw_prev; - change = get_mp_change(&wp->wpaint_prev[index], wpi->defbase_tot, wpi->defbase_sel, neww - oldw); + change = get_mp_change(&wp->wpaint_prev[index], wpi->defbase_tot, wpi->defbase_sel, observedChange); if (change) { if (!tdw->weight) { i = get_first_selected_nonzero_weight(dv, wpi->defbase_tot, wpi->defbase_sel); @@ -1911,7 +1913,7 @@ static void do_weight_paint_vertex( if (tdw->weight != tdw_prev->weight) { oldChange = tdw->weight / tdw_prev->weight; testw = tdw_prev->weight * change; - if (testw > tdw_prev->weight) { + if (observedChange > 0) { if (change > oldChange) { /* reset the weights and use the new change */ defvert_reset_to_prev(wp->wpaint_prev + index, dv); -- cgit v1.2.3