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:
authorCampbell Barton <ideasman42@gmail.com>2017-10-03 10:50:34 +0300
committerCampbell Barton <ideasman42@gmail.com>2017-10-03 11:09:28 +0300
commitf4b1f9b9255cda1af5e093f25cdde816bd94d8cd (patch)
tree80c829f3f45a66b0b3c64def25179a74cd37a26e
parent515e69999e63aab7720e48b0c85233f61facce65 (diff)
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.
-rw-r--r--release/scripts/startup/bl_ui/space_view3d_toolbar.py3
-rw-r--r--source/blender/blenkernel/BKE_paint.h6
-rw-r--r--source/blender/blenkernel/intern/paint.c2
-rw-r--r--source/blender/blenloader/intern/versioning_270.c2
-rw-r--r--source/blender/editors/sculpt_paint/paint_vertex.c76
-rw-r--r--source/blender/makesdna/DNA_scene_types.h1
-rw-r--r--source/blender/makesrna/intern/rna_sculpt_paint.c6
7 files changed, 24 insertions, 72 deletions
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);
- ss->mode.vpaint.previous_accum[l_index] = final_alpha;
- }
/* Mix the new color with the original based on final_alpha. */
lcol[l_index] = vpaint_blend(
@@ -2649,7 +2617,7 @@ static void do_vpaint_brush_blur_task_cb_ex(
}
color_orig = ss->mode.vpaint.previous_color[l_index];
}
- float final_alpha =
+ const float final_alpha =
255 * brush_fade * brush_strength *
brush_alpha_pressure * grid_alpha;
/* Mix the new color with the original
@@ -2777,7 +2745,7 @@ static void do_vpaint_brush_smear_task_cb_ex(
}
color_orig = ss->mode.vpaint.previous_color[l_index];
}
- float final_alpha =
+ const float final_alpha =
255 * brush_fade * brush_strength *
brush_alpha_pressure * grid_alpha;
/* Mix the new color with the original
diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h
index e9caf7ada1c..89a8a410f3e 100644
--- a/source/blender/makesdna/DNA_scene_types.h
+++ b/source/blender/makesdna/DNA_scene_types.h
@@ -1128,7 +1128,6 @@ enum {
/* TODO */
// VP_FLAG_PROJECT_XRAY = (1 << 1),
VP_FLAG_PROJECT_FLAT = (1 << 3),
- VP_FLAG_SPRAY = (1 << 4),
/* weight paint only */
VP_FLAG_VGROUP_RESTRICT = (1 << 7)
};
diff --git a/source/blender/makesrna/intern/rna_sculpt_paint.c b/source/blender/makesrna/intern/rna_sculpt_paint.c
index 6c89767ad29..6e493e2c865 100644
--- a/source/blender/makesrna/intern/rna_sculpt_paint.c
+++ b/source/blender/makesrna/intern/rna_sculpt_paint.c
@@ -692,12 +692,6 @@ static void rna_def_vertex_paint(BlenderRNA *brna)
RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", VP_FLAG_PROJECT_FLAT);
RNA_def_property_ui_text(prop, "Normals", "Paint most on faces pointing towards the view");
RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
-
-
- prop = RNA_def_property(srna, "use_spray", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flag", VP_FLAG_SPRAY);
- RNA_def_property_ui_text(prop, "Spray", "Keep applying paint effect while holding mouse");
- RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
/* weight paint only */
prop = RNA_def_property(srna, "use_group_restrict", PROP_BOOLEAN, PROP_NONE);