[Bf-blender-cvs] [f4b1f9b9255] master: Vertex Paint: remove accumulate (soc-2017-vertex_paint)

Campbell Barton noreply at git.blender.org
Tue Oct 3 09:55:29 CEST 2017


Commit: f4b1f9b9255cda1af5e093f25cdde816bd94d8cd
Author: Campbell Barton
Date:   Tue Oct 3 18:50:34 2017 +1100
Branches: master
https://developer.blender.org/rBf4b1f9b9255cda1af5e093f25cdde816bd94d8cd

Vertex Paint: remove accumulate (soc-2017-vertex_paint)

This secondary accumulation option accumulated brush falloff.
The same option in image painting accumulates color
as vertex paiht 'Spray' does.

Giving this option different behavior for vertex paint seems strange.
Also this is basically increasing falloff over time.

Remove the new code, expose existing 'Spray' as 'Accumulate'
to match other paint modes.

===================================================================

M	release/scripts/startup/bl_ui/space_view3d_toolbar.py
M	source/blender/blenkernel/BKE_paint.h
M	source/blender/blenkernel/intern/paint.c
M	source/blender/blenloader/intern/versioning_270.c
M	source/blender/editors/sculpt_paint/paint_vertex.c
M	source/blender/makesdna/DNA_scene_types.h
M	source/blender/makesrna/intern/rna_sculpt_paint.c

===================================================================

diff --git a/release/scripts/startup/bl_ui/space_view3d_toolbar.py b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
index 798b5e28d9c..5aca4c554d8 100644
--- a/release/scripts/startup/bl_ui/space_view3d_toolbar.py
+++ b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
@@ -1773,7 +1773,6 @@ class VIEW3D_PT_tools_weightpaint_options(Panel, View3DPaintPanel):
         sub.prop(wpaint, "normal_angle", text="")
         col = layout.column()
         row = col.row()
-        row.prop(wpaint, "use_spray")
         row.prop(wpaint, "use_group_restrict")
 
         obj = context.weight_paint_object
@@ -1816,8 +1815,6 @@ class VIEW3D_PT_tools_vertexpaint(Panel, View3DPaintPanel):
         sub.active = (vpaint.use_normal_falloff)
         sub.prop(vpaint, "normal_angle", text="")
 
-        col.prop(vpaint, "use_spray")
-
         self.unified_paint_settings(col, context)
 
 
diff --git a/source/blender/blenkernel/BKE_paint.h b/source/blender/blenkernel/BKE_paint.h
index 19f332f5f54..3a70819ec58 100644
--- a/source/blender/blenkernel/BKE_paint.h
+++ b/source/blender/blenkernel/BKE_paint.h
@@ -220,18 +220,14 @@ typedef struct SculptSession {
 
 			/* For non-airbrush painting to re-apply from the original (MLoop aligned). */
 			unsigned int *previous_color;
-			float        *previous_accum;
 		} vpaint;
 
 		struct {
 			struct SculptVertexPaintGeomMap gmap;
-
-			/* Vertex aligned arrays of weights. */
-			float *previous_accum;
 			/* Keep track of how much each vertex has been painted (non-airbrush only). */
 			float *alpha_weight;
 
-			/* Needed to continuously re-apply over the same weights (VP_FLAG_SPRAY disabled).
+			/* Needed to continuously re-apply over the same weights (BRUSH_ACCUMULATE disabled).
 			 * Lazy initialize as needed (flag is set to 1 to tag it as uninitialized). */
 			struct MDeformVert *dvert_prev;
 		} wpaint;
diff --git a/source/blender/blenkernel/intern/paint.c b/source/blender/blenkernel/intern/paint.c
index c2f1d05dd89..62af61585c1 100644
--- a/source/blender/blenkernel/intern/paint.c
+++ b/source/blender/blenkernel/intern/paint.c
@@ -681,13 +681,11 @@ void BKE_sculptsession_free_vwpaint_data(struct SculptSession *ss)
 		gmap = &ss->mode.vpaint.gmap;
 
 		MEM_SAFE_FREE(ss->mode.vpaint.previous_color);
-		MEM_SAFE_FREE(ss->mode.vpaint.previous_accum);
 	}
 	else if (ss->mode_type == OB_MODE_WEIGHT_PAINT) {
 		gmap = &ss->mode.wpaint.gmap;
 
 		MEM_SAFE_FREE(ss->mode.wpaint.alpha_weight);
-		MEM_SAFE_FREE(ss->mode.wpaint.previous_accum);
 		if (ss->mode.wpaint.dvert_prev) {
 			BKE_defvert_array_free_elems(ss->mode.wpaint.dvert_prev, ss->totvert);
 			MEM_freeN(ss->mode.wpaint.dvert_prev);
diff --git a/source/blender/blenloader/intern/versioning_270.c b/source/blender/blenloader/intern/versioning_270.c
index d40dbd542dd..e1a4137d069 100644
--- a/source/blender/blenloader/intern/versioning_270.c
+++ b/source/blender/blenloader/intern/versioning_270.c
@@ -1690,7 +1690,7 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main)
 					VPaint *vp = i ? ts->vpaint : ts->wpaint;
 					if (vp != NULL) {
 						/* remove all other flags */
-						vp->flag &= (VP_FLAG_SPRAY | VP_FLAG_VGROUP_RESTRICT);
+						vp->flag &= (VP_FLAG_VGROUP_RESTRICT);
 						vp->normal_angle = 80;
 					}
 				}
diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c
index c61d250446c..ee8934422bc 100644
--- a/source/blender/editors/sculpt_paint/paint_vertex.c
+++ b/source/blender/editors/sculpt_paint/paint_vertex.c
@@ -241,11 +241,10 @@ int weight_paint_poll(bContext *C)
 	return 0;
 }
 
-static VPaint *new_vpaint(int wpaint)
+static VPaint *new_vpaint(void)
 {
 	VPaint *vp = MEM_callocN(sizeof(VPaint), "VPaint");
 
-	vp->flag = (wpaint) ? 0 : VP_FLAG_SPRAY;
 	vp->paint.flags |= PAINT_SHOW_BRUSH;
 
 	return vp;
@@ -272,8 +271,8 @@ static uint vpaint_blend(
 
 	uint color_blend = ED_vpaint_blend_tool(tool, color_curr, color_paint, alpha_i);
 
-	/* if no spray, clip color adding with colorig & orig alpha */
-	if ((vp->flag & VP_FLAG_SPRAY) == 0) {
+	/* if no accumulate, clip color adding with colorig & orig alpha */
+	if ((brush->flag & BRUSH_ACCUMULATE) == 0) {
 		uint color_test, a;
 		char *cp, *ct, *co;
 
@@ -730,7 +729,7 @@ static void do_weight_paint_vertex_single(
 		index_mirr = vgroup_mirr = -1;
 	}
 
-	if ((wp->flag & VP_FLAG_SPRAY) == 0) {
+	if ((wp->paint.brush->flag & BRUSH_ACCUMULATE) == 0) {
 		struct MDeformVert *dvert_prev = ob->sculpt->mode.wpaint.dvert_prev;
 		defweight_prev_restore_or_init(dvert_prev, me->dvert, index);
 		if (index_mirr != -1) {
@@ -874,7 +873,7 @@ static void do_weight_paint_vertex_multi(
 		}
 	}
 
-	if ((wp->flag & VP_FLAG_SPRAY) == 0) {
+	if ((wp->paint.brush->flag & BRUSH_ACCUMULATE) == 0) {
 		struct MDeformVert *dvert_prev = ob->sculpt->mode.wpaint.dvert_prev;
 		defweight_prev_restore_or_init(dvert_prev, me->dvert, index);
 		if (index_mirr != -1) {
@@ -1007,7 +1006,7 @@ static void vertex_paint_init_session_data(const ToolSettings *ts, Object *ob)
 
 	/* Create average brush arrays */
 	if (ob->mode == OB_MODE_VERTEX_PAINT) {
-		if ((ts->vpaint->flag & VP_FLAG_SPRAY) == 0) {
+		if ((brush->flag & BRUSH_ACCUMULATE) == 0) {
 			if (ob->sculpt->mode.vpaint.previous_color == NULL) {
 				ob->sculpt->mode.vpaint.previous_color =
 				        MEM_callocN(me->totloop * sizeof(uint), __func__);
@@ -1016,19 +1015,9 @@ static void vertex_paint_init_session_data(const ToolSettings *ts, Object *ob)
 		else {
 			MEM_SAFE_FREE(ob->sculpt->mode.vpaint.previous_color);
 		}
-
-		if (brush && brush->flag & BRUSH_ACCUMULATE) {
-			if (ob->sculpt->mode.vpaint.previous_accum == NULL) {
-				ob->sculpt->mode.vpaint.previous_accum =
-				        MEM_callocN(me->totloop * sizeof(float), __func__);
-			}
-		}
-		else {
-			MEM_SAFE_FREE(ob->sculpt->mode.vpaint.previous_accum);
-		}
 	}
 	else if (ob->mode == OB_MODE_WEIGHT_PAINT) {
-		if ((ts->wpaint->flag & VP_FLAG_SPRAY) == 0) {
+		if ((brush->flag & BRUSH_ACCUMULATE) == 0) {
 			if (ob->sculpt->mode.wpaint.alpha_weight == NULL) {
 				ob->sculpt->mode.wpaint.alpha_weight =
 				        MEM_callocN(me->totvert * sizeof(float), __func__);
@@ -1051,15 +1040,6 @@ static void vertex_paint_init_session_data(const ToolSettings *ts, Object *ob)
 				ob->sculpt->mode.wpaint.dvert_prev = NULL;
 			}
 		}
-		if (brush && brush->flag & BRUSH_ACCUMULATE) {
-			if (ob->sculpt->mode.wpaint.previous_accum == NULL) {
-				ob->sculpt->mode.wpaint.previous_accum =
-				        MEM_callocN(me->totvert * sizeof(float), __func__);
-			}
-		}
-		else {
-			MEM_SAFE_FREE(ob->sculpt->mode.wpaint.previous_accum);
-		}
 	}
 
 }
@@ -1114,7 +1094,7 @@ static int wpaint_mode_toggle_exec(bContext *C, wmOperator *op)
 		ob->mode |= mode_flag;
 
 		if (wp == NULL)
-			wp = scene->toolsettings->wpaint = new_vpaint(1);
+			wp = scene->toolsettings->wpaint = new_vpaint();
 
 		paint_cursor_start(C, weight_paint_poll);
 
@@ -1557,14 +1537,17 @@ static void do_wpaint_brush_blur_task_cb_ex(
 					     view_angle_limits_apply_falloff(&data->wpd->normal_angle_precalc, angle_cos, &brush_strength)))
 					{
 						const float brush_fade = BKE_brush_curve_strength(brush, sqrtf(test.dist), cache->radius);
-						float final_alpha =
+						const float final_alpha =
 						        brush_fade * brush_strength *
 						        grid_alpha * brush_alpha_pressure;
 
-						if (brush->flag & BRUSH_ACCUMULATE) {
-							float mask_accum = ss->mode.wpaint.previous_accum[v_index];
-							final_alpha = min_ff(final_alpha + mask_accum, brush_strength);
-							ss->mode.wpaint.previous_accum[v_index] = final_alpha;
+						if ((brush->flag & BRUSH_ACCUMULATE) == 0) {
+							if (ss->mode.wpaint.alpha_weight[v_index] < final_alpha) {
+								ss->mode.wpaint.alpha_weight[v_index] = final_alpha;
+							}
+							else {
+								continue;
+							}
 						}
 
 						weight_final /= total_hit_loops;
@@ -1729,16 +1712,9 @@ static void do_wpaint_brush_draw_task_cb_ex(
 				     view_angle_limits_apply_falloff(&data->wpd->normal_angle_precalc, angle_cos, &brush_strength)))
 				{
 					const float brush_fade = BKE_brush_curve_strength(brush, sqrtf(test.dist), cache->radius);
-					float final_alpha = brush_fade * brush_strength * grid_alpha * brush_alpha_pressure;
-					if (brush->flag & BRUSH_ACCUMULATE) {
-						float mask_accum = ss->mode.wpaint.previous_accum[v_index];
-						final_alpha = min_ff(final_alpha + mask_accum, brush_strength);
-						ss->mode.wpaint.previous_accum[v_index] = final_alpha;
-					}
+					const float final_alpha = brush_fade * brush_strength * grid_alpha * brush_alpha_pressure;
 
-					/* Non-spray logic. */
-					if ((data->vp->flag & VP_FLAG_SPRAY) == 0) {
-						/* Only paint if we have greater alpha. */
+					if ((brush->flag & BRUSH_ACCUMULATE) == 0) {
 						if (ss->mode.wpaint.alpha_weight[v_index] < final_alpha) {
 							ss->mode.wpaint.alpha_weight[v_index] = final_alpha;
 						}
@@ -1804,9 +1780,6 @@ static void do_wpaint_brush_calc_average_weight_cb_ex(
 
 static void calculate_average_weight(SculptThreadedTaskData *data, PBVHNode **UNUSED(nodes), int totnode)
 {
-	Scene *scene = CTX_data_scene(data->C);
-	UnifiedPaintSettings *ups = &scene->toolsettings->unified_paint_settings;
-
 	struct WPaintAverageAccum *accum = MEM_mallocN(sizeof(*accum) * totnode, __func__);
 	data->custom_data = accum;
 
@@ -2236,7 +2209,7 @@ static int vpaint_mode_toggle_exec(bContext *C, wmOperator *op)
 		ED_mesh_color_ensure(me, NULL);
 
 		if (vp == NULL)
-			vp = scene->toolsettings->vpaint = new_vpaint(0);
+			vp = scene->toolsettings->vpaint = new_vpaint();
 
 		paint_cursor_start(C, vertex_paint_poll);
 
@@ -2538,14 +2511,9 @@ static void do_vpaint_brush_draw_task_cb_ex(
 								}
 								color_orig = ss->mode.vpaint.previous_color[l_index];
 							}
-							float final_alpha =
+							const float final_alpha =
 							        255 * brush_fade * brush_strength *
 							        tex_alpha * brush_alpha_pressure * grid_alpha;
-							if (brush->flag & BRUSH_ACCUMULATE) {
-								float mask_accum = ss->mode.vpaint.previous_accum[l_index];
-								final_alpha = min_ff(final_alpha + mask_accum, 255.0f * brush_strength);
-					

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list