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 /source/blender/editors/sculpt_paint
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.
Diffstat (limited to 'source/blender/editors/sculpt_paint')
-rw-r--r--source/blender/editors/sculpt_paint/paint_vertex.c76
1 files changed, 22 insertions, 54 deletions
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