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>2018-11-06 10:06:33 +0300
committerCampbell Barton <ideasman42@gmail.com>2018-11-06 10:06:33 +0300
commit80109c976cf1f43e1f1730cb827130aa270abaaa (patch)
tree93932897c425ea9f062f6960bc50f1f265a53e32 /source/blender/editors
parent900c562b71b6efcf68d649cb639cc8bc246d5899 (diff)
Brush: split out vertex paint tool & blend mode
- Vertex & weight paint now use the 'blend' setting. - Weight paint now has it's own tool setting, since weight paint doesn't deal with color - we'll likely support different tools eventually.
Diffstat (limited to 'source/blender/editors')
-rw-r--r--source/blender/editors/interface/interface_icons.c45
-rw-r--r--source/blender/editors/interface/interface_region_tooltip.c2
-rw-r--r--source/blender/editors/sculpt_paint/paint_ops.c7
-rw-r--r--source/blender/editors/sculpt_paint/paint_vertex.c93
-rw-r--r--source/blender/editors/sculpt_paint/paint_vertex_color_utils.c42
-rw-r--r--source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c2
-rw-r--r--source/blender/editors/sculpt_paint/paint_vertex_weight_utils.c42
7 files changed, 119 insertions, 114 deletions
diff --git a/source/blender/editors/interface/interface_icons.c b/source/blender/editors/interface/interface_icons.c
index 09e16b806f3..80c62a3eda7 100644
--- a/source/blender/editors/interface/interface_icons.c
+++ b/source/blender/editors/interface/interface_icons.c
@@ -58,6 +58,7 @@
#include "BKE_context.h"
#include "BKE_global.h"
+#include "BKE_paint.h"
#include "BKE_icons.h"
#include "BKE_appdir.h"
#include "BKE_studiolight.h"
@@ -1679,7 +1680,7 @@ static int ui_id_brush_get_icon(const bContext *C, ID *id)
WorkSpace *workspace = CTX_wm_workspace(C);
Object *ob = CTX_data_active_object(C);
const EnumPropertyItem *items = NULL;
- int tool = PAINT_TOOL_DRAW, mode = 0;
+ ePaintMode paint_mode = ePaintInvalid;
ScrArea *sa = CTX_wm_area(C);
char space_type = sa->spacetype;
/* When in an unsupported space. */
@@ -1692,12 +1693,18 @@ static int ui_id_brush_get_icon(const bContext *C, ID *id)
* checking various context stuff here */
if ((space_type == SPACE_VIEW3D) && ob) {
- if (ob->mode & OB_MODE_SCULPT)
- mode = OB_MODE_SCULPT;
- else if (ob->mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT))
- mode = OB_MODE_VERTEX_PAINT;
- else if (ob->mode & OB_MODE_TEXTURE_PAINT)
- mode = OB_MODE_TEXTURE_PAINT;
+ if (ob->mode & OB_MODE_SCULPT) {
+ paint_mode = ePaintSculpt;
+ }
+ else if (ob->mode & OB_MODE_VERTEX_PAINT) {
+ paint_mode = ePaintVertex;
+ }
+ else if (ob->mode & OB_MODE_WEIGHT_PAINT) {
+ paint_mode = ePaintWeight;
+ }
+ else if (ob->mode & OB_MODE_TEXTURE_PAINT) {
+ paint_mode = ePaintTextureProjective;
+ }
}
else if (space_type == SPACE_IMAGE) {
int sima_mode;
@@ -1710,7 +1717,7 @@ static int ui_id_brush_get_icon(const bContext *C, ID *id)
}
if (sima_mode == SI_MODE_PAINT) {
- mode = OB_MODE_TEXTURE_PAINT;
+ paint_mode = ePaintTexture2D;
}
}
@@ -1756,21 +1763,17 @@ static int ui_id_brush_get_icon(const bContext *C, ID *id)
}
return id->icon_id;
}
- else if (mode == OB_MODE_SCULPT) {
- items = rna_enum_brush_sculpt_tool_items;
- tool = br->sculpt_tool;
- }
- else if (mode == OB_MODE_VERTEX_PAINT) {
- items = rna_enum_brush_vertex_tool_items;
- tool = br->vertexpaint_tool;
- }
- else if (mode == OB_MODE_TEXTURE_PAINT) {
- items = rna_enum_brush_image_tool_items;
- tool = br->imagepaint_tool;
+ else if (paint_mode != ePaintInvalid) {
+ items = BKE_paint_get_tool_enum_from_paintmode(paint_mode);
+ const uint tool_offset = BKE_paint_get_brush_tool_offset_from_paint_mode(paint_mode);
+ const int tool_type = *(char *)POINTER_OFFSET(br, tool_offset);
+ if (!items || !RNA_enum_icon_from_value(items, tool_type, &id->icon_id)) {
+ id->icon_id = 0;
+ }
}
-
- if (!items || !RNA_enum_icon_from_value(items, tool, &id->icon_id))
+ else {
id->icon_id = 0;
+ }
}
return id->icon_id;
diff --git a/source/blender/editors/interface/interface_region_tooltip.c b/source/blender/editors/interface/interface_region_tooltip.c
index e410421479c..4e1218c3b2f 100644
--- a/source/blender/editors/interface/interface_region_tooltip.c
+++ b/source/blender/editors/interface/interface_region_tooltip.c
@@ -472,7 +472,7 @@ static uiTooltipData *ui_tooltip_data_from_tool(bContext *C, uiBut *but, bool is
break;
case CTX_MODE_PAINT_WEIGHT:
tool_attr = "weight_paint_tool";
- tool_offset = offsetof(Brush, vertexpaint_tool);
+ tool_offset = offsetof(Brush, weightpaint_tool);
break;
case CTX_MODE_PAINT_TEXTURE:
tool_attr = "texture_paint_tool";
diff --git a/source/blender/editors/sculpt_paint/paint_ops.c b/source/blender/editors/sculpt_paint/paint_ops.c
index f15f727ed2c..cb78ecd511d 100644
--- a/source/blender/editors/sculpt_paint/paint_ops.c
+++ b/source/blender/editors/sculpt_paint/paint_ops.c
@@ -483,10 +483,9 @@ static int brush_select_exec(bContext *C, wmOperator *op)
RNA_enum_name_from_value(rna_enum_brush_vertex_tool_items, tool, &tool_name);
break;
case OB_MODE_WEIGHT_PAINT:
- /* vertexpaint_tool is used for weight paint mode */
- tool_offset = offsetof(Brush, vertexpaint_tool);
+ tool_offset = offsetof(Brush, weightpaint_tool);
tool = RNA_enum_get(op->ptr, "weight_paint_tool");
- RNA_enum_name_from_value(rna_enum_brush_vertex_tool_items, tool, &tool_name);
+ RNA_enum_name_from_value(rna_enum_brush_weight_tool_items, tool, &tool_name);
break;
case OB_MODE_TEXTURE_PAINT:
tool_offset = offsetof(Brush, imagepaint_tool);
@@ -567,7 +566,7 @@ static void PAINT_OT_brush_select(wmOperatorType *ot)
RNA_def_property_flag(prop, PROP_HIDDEN);
prop = RNA_def_enum(ot->srna, "vertex_paint_tool", rna_enum_brush_vertex_tool_items, 0, "Vertex Paint Tool", "");
RNA_def_property_flag(prop, PROP_HIDDEN);
- prop = RNA_def_enum(ot->srna, "weight_paint_tool", rna_enum_brush_vertex_tool_items, 0, "Weight Paint Tool", "");
+ prop = RNA_def_enum(ot->srna, "weight_paint_tool", rna_enum_brush_weight_tool_items, 0, "Weight Paint Tool", "");
RNA_def_property_flag(prop, PROP_HIDDEN);
prop = RNA_def_enum(ot->srna, "texture_paint_tool", rna_enum_brush_image_tool_items, 0, "Texture Paint Tool", "");
RNA_def_property_flag(prop, PROP_HIDDEN);
diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c
index 103cb6b5f2f..bf20146f195 100644
--- a/source/blender/editors/sculpt_paint/paint_vertex.c
+++ b/source/blender/editors/sculpt_paint/paint_vertex.c
@@ -76,6 +76,9 @@
#include "ED_screen.h"
#include "ED_view3d.h"
+/* For IMB_BlendMode only. */
+#include "IMB_imbuf.h"
+
#include "bmesh.h"
#include "BKE_ccg.h"
@@ -153,9 +156,17 @@ static bool vwpaint_use_normal(const VPaint *vp)
((vp->paint.brush->flag & BRUSH_FRONTFACE_FALLOFF) != 0);
}
-static bool brush_use_accumulate(const Brush *brush)
+static bool brush_use_accumulate_ex(const Brush *brush, const int ob_mode)
+{
+ return ((brush->flag & BRUSH_ACCUMULATE) != 0 ||
+ (ob_mode == OB_MODE_VERTEX_PAINT ?
+ (brush->vertexpaint_tool == VPAINT_TOOL_SMEAR) :
+ (brush->weightpaint_tool == WPAINT_TOOL_SMEAR)));
+}
+
+static bool brush_use_accumulate(const VPaint *vp)
{
- return (brush->flag & BRUSH_ACCUMULATE) != 0 || brush->vertexpaint_tool == PAINT_BLEND_SMEAR;
+ return brush_use_accumulate_ex(vp->paint.brush, vp->paint.runtime.ob_mode);
}
static MDeformVert *defweight_prev_init(MDeformVert *dvert_prev, MDeformVert *dvert_curr, int index)
@@ -291,16 +302,16 @@ static uint vpaint_blend(
const int brush_alpha_value_i)
{
const Brush *brush = vp->paint.brush;
- const int tool = brush->vertexpaint_tool;
+ const IMB_BlendMode blend = brush->blend;
- uint color_blend = ED_vpaint_blend_tool(tool, color_curr, color_paint, alpha_i);
+ uint color_blend = ED_vpaint_blend_tool(blend, color_curr, color_paint, alpha_i);
/* if no accumulate, clip color adding with colorig & orig alpha */
- if (!brush_use_accumulate(brush)) {
+ if (!brush_use_accumulate(vp)) {
uint color_test, a;
char *cp, *ct, *co;
- color_test = ED_vpaint_blend_tool(tool, color_orig, color_paint, brush_alpha_value_i);
+ color_test = ED_vpaint_blend_tool(blend, color_orig, color_paint, brush_alpha_value_i);
cp = (char *)&color_blend;
ct = (char *)&color_test;
@@ -319,7 +330,7 @@ static uint vpaint_blend(
}
if ((brush->flag & BRUSH_LOCK_ALPHA) &&
- !ELEM(tool, PAINT_BLEND_ALPHA_SUB, PAINT_BLEND_ALPHA_ADD))
+ !ELEM(blend, IMB_BLEND_ERASE_ALPHA, IMB_BLEND_ADD_ALPHA))
{
char *cp, *cc;
cp = (char *)&color_blend;
@@ -363,24 +374,25 @@ static float wpaint_blend(
const short do_flip)
{
const Brush *brush = wp->paint.brush;
- int tool = brush->vertexpaint_tool;
+ IMB_BlendMode blend = brush->blend;
if (do_flip) {
- switch (tool) {
- case PAINT_BLEND_MIX:
+ switch (blend) {
+ case IMB_BLEND_MIX:
paintval = 1.f - paintval; break;
- case PAINT_BLEND_ADD:
- tool = PAINT_BLEND_SUB; break;
- case PAINT_BLEND_SUB:
- tool = PAINT_BLEND_ADD; break;
- case PAINT_BLEND_LIGHTEN:
- tool = PAINT_BLEND_DARKEN; break;
- case PAINT_BLEND_DARKEN:
- tool = PAINT_BLEND_LIGHTEN; break;
+ case IMB_BLEND_ADD:
+ blend = IMB_BLEND_SUB; break;
+ case IMB_BLEND_SUB:
+ blend = IMB_BLEND_ADD; break;
+ case IMB_BLEND_LIGHTEN:
+ blend = IMB_BLEND_DARKEN; break;
+ case IMB_BLEND_DARKEN:
+ blend = IMB_BLEND_LIGHTEN; break;
+ default: break;
}
}
- weight = ED_wpaint_blend_tool(tool, weight, paintval, alpha);
+ weight = ED_wpaint_blend_tool(blend, weight, paintval, alpha);
CLAMP(weight, 0.0f, 1.0f);
@@ -759,7 +771,7 @@ static void do_weight_paint_vertex_single(
dw_mirr = NULL;
}
- if (!brush_use_accumulate(wp->paint.brush)) {
+ if (!brush_use_accumulate(wp)) {
MDeformVert *dvert_prev = ob->sculpt->mode.wpaint.dvert_prev;
MDeformVert *dv_prev = defweight_prev_init(dvert_prev, me->dvert, index);
if (index_mirr != -1) {
@@ -875,7 +887,7 @@ static void do_weight_paint_vertex_multi(
return;
}
- if (!brush_use_accumulate(wp->paint.brush)) {
+ if (!brush_use_accumulate(wp)) {
MDeformVert *dvert_prev = ob->sculpt->mode.wpaint.dvert_prev;
MDeformVert *dv_prev = defweight_prev_init(dvert_prev, me->dvert, index);
if (index_mirr != -1) {
@@ -978,15 +990,12 @@ static void vertex_paint_init_session_data(const ToolSettings *ts, Object *ob)
{
/* Create maps */
struct SculptVertexPaintGeomMap *gmap = NULL;
- const Brush *brush = NULL;
if (ob->mode == OB_MODE_VERTEX_PAINT) {
gmap = &ob->sculpt->mode.vpaint.gmap;
- brush = BKE_paint_brush(&ts->vpaint->paint);
BLI_assert(ob->sculpt->mode_type == OB_MODE_VERTEX_PAINT);
}
else if (ob->mode == OB_MODE_WEIGHT_PAINT) {
gmap = &ob->sculpt->mode.wpaint.gmap;
- brush = BKE_paint_brush(&ts->wpaint->paint);
BLI_assert(ob->sculpt->mode_type == OB_MODE_WEIGHT_PAINT);
}
else {
@@ -1014,7 +1023,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 (!brush_use_accumulate(brush)) {
+ if (!brush_use_accumulate(ts->vpaint)) {
if (ob->sculpt->mode.vpaint.previous_color == NULL) {
ob->sculpt->mode.vpaint.previous_color =
MEM_callocN(me->totloop * sizeof(uint), __func__);
@@ -1025,7 +1034,7 @@ static void vertex_paint_init_session_data(const ToolSettings *ts, Object *ob)
}
}
else if (ob->mode == OB_MODE_WEIGHT_PAINT) {
- if (!brush_use_accumulate(brush)) {
+ if (!brush_use_accumulate(ts->wpaint)) {
if (ob->sculpt->mode.wpaint.alpha_weight == NULL) {
ob->sculpt->mode.wpaint.alpha_weight =
MEM_callocN(me->totvert * sizeof(float), __func__);
@@ -1544,7 +1553,7 @@ static bool wpaint_stroke_test_start(bContext *C, wmOperator *op, const float mo
wpd->mirror.lock = tmpflags;
}
- if (ELEM(vp->paint.brush->vertexpaint_tool, PAINT_BLEND_SMEAR, PAINT_BLEND_BLUR)) {
+ if (ELEM(vp->paint.brush->weightpaint_tool, WPAINT_TOOL_SMEAR, WPAINT_TOOL_BLUR)) {
wpd->precomputed_weight = MEM_mallocN(sizeof(float) * me->totvert, __func__);
}
@@ -1612,7 +1621,7 @@ static void do_wpaint_precompute_weight_cb_ex(
static void precompute_weight_values(
bContext *C, Object *ob, Brush *brush, struct WPaintData *wpd, WeightPaintInfo *wpi, Mesh *me)
{
- if (wpd->precomputed_weight_ready && !brush_use_accumulate(brush))
+ if (wpd->precomputed_weight_ready && !brush_use_accumulate_ex(brush, ob->mode))
return;
/* threaded loop over vertices */
@@ -2006,8 +2015,8 @@ static void wpaint_paint_leaves(
/* NOTE: current mirroring code cannot be run in parallel */
settings.use_threading = !(me->editflag & ME_EDIT_MIRROR_X);
- switch (brush->vertexpaint_tool) {
- case PAINT_BLEND_AVERAGE:
+ switch ((eBrushWeightPaintTool)brush->weightpaint_tool) {
+ case WPAINT_TOOL_AVERAGE:
calculate_average_weight(&data, nodes, totnode);
BLI_task_parallel_range(
0, totnode,
@@ -2015,21 +2024,21 @@ static void wpaint_paint_leaves(
do_wpaint_brush_draw_task_cb_ex,
&settings);
break;
- case PAINT_BLEND_SMEAR:
+ case WPAINT_TOOL_SMEAR:
BLI_task_parallel_range(
0, totnode,
&data,
do_wpaint_brush_smear_task_cb_ex,
&settings);
break;
- case PAINT_BLEND_BLUR:
+ case WPAINT_TOOL_BLUR:
BLI_task_parallel_range(
0, totnode,
&data,
do_wpaint_brush_blur_task_cb_ex,
&settings);
break;
- default:
+ case WPAINT_TOOL_DRAW:
BLI_task_parallel_range(
0, totnode,
&data,
@@ -2512,7 +2521,7 @@ static bool vpaint_stroke_test_start(bContext *C, struct wmOperator *op, const f
vpd->paintcol = vpaint_get_current_col(scene, vp, (RNA_enum_get(op->ptr, "mode") == BRUSH_STROKE_INVERT));
- vpd->is_texbrush = !(brush->vertexpaint_tool == PAINT_BLEND_BLUR) && brush->mtex.tex;
+ vpd->is_texbrush = !(brush->vertexpaint_tool == VPAINT_TOOL_BLUR) && brush->mtex.tex;
/* are we painting onto a modified mesh?,
* if not we can skip face map trickiness */
@@ -2526,11 +2535,11 @@ static bool vpaint_stroke_test_start(bContext *C, struct wmOperator *op, const f
}
/* to keep tracked of modified loops for shared vertex color blending */
- if (brush->vertexpaint_tool == PAINT_BLEND_BLUR) {
+ if (brush->vertexpaint_tool == VPAINT_TOOL_BLUR) {
vpd->mlooptag = MEM_mallocN(sizeof(bool) * me->totloop, "VPaintData mlooptag");
}
- if (brush->vertexpaint_tool == PAINT_BLEND_SMEAR) {
+ if (brush->vertexpaint_tool == VPAINT_TOOL_SMEAR) {
vpd->smear.color_prev = MEM_mallocN(sizeof(uint) * me->totloop, __func__);
memcpy(vpd->smear.color_prev, me->mloopcol, sizeof(uint) * me->totloop);
vpd->smear.color_curr = MEM_dupallocN(vpd->smear.color_prev);
@@ -3009,8 +3018,8 @@ static void vpaint_paint_leaves(
};
ParallelRangeSettings settings;
BLI_parallel_range_settings_defaults(&settings);
- switch (brush->vertexpaint_tool) {
- case PAINT_BLEND_AVERAGE:
+ switch ((eBrushVertexPaintTool)brush->vertexpaint_tool) {
+ case VPAINT_TOOL_AVERAGE:
calculate_average_color(&data, nodes, totnode);
BLI_task_parallel_range(
0, totnode,
@@ -3018,21 +3027,21 @@ static void vpaint_paint_leaves(
do_vpaint_brush_draw_task_cb_ex,
&settings);
break;
- case PAINT_BLEND_BLUR:
+ case VPAINT_TOOL_BLUR:
BLI_task_parallel_range(
0, totnode,
&data,
do_vpaint_brush_blur_task_cb_ex,
&settings);
break;
- case PAINT_BLEND_SMEAR:
+ case VPAINT_TOOL_SMEAR:
BLI_task_parallel_range(
0, totnode,
&data,
do_vpaint_brush_smear_task_cb_ex,
&settings);
break;
- default:
+ case VPAINT_TOOL_DRAW:
BLI_task_parallel_range(
0, totnode,
&data,
@@ -3144,7 +3153,7 @@ static void vpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, P
BKE_mesh_batch_cache_dirty_tag(ob->data, BKE_MESH_BATCH_DIRTY_ALL);
- if (vp->paint.brush->vertexpaint_tool == PAINT_BLEND_SMEAR) {
+ if (vp->paint.brush->vertexpaint_tool == PAINT_TOOL_SMEAR) {
memcpy(vpd->smear.color_prev, vpd->smear.color_curr, sizeof(uint) * ((Mesh *)ob->data)->totloop);
}
diff --git a/source/blender/editors/sculpt_paint/paint_vertex_color_utils.c b/source/blender/editors/sculpt_paint/paint_vertex_color_utils.c
index 481d5e7d5ea..f78588df0fa 100644
--- a/source/blender/editors/sculpt_paint/paint_vertex_color_utils.c
+++ b/source/blender/editors/sculpt_paint/paint_vertex_color_utils.c
@@ -36,6 +36,7 @@
#include "BLI_math_color.h"
#include "IMB_colormanagement.h"
+#include "IMB_imbuf.h"
#include "BKE_context.h"
#include "BKE_mesh.h"
@@ -617,29 +618,26 @@ uint ED_vpaint_blend_tool(
const int tool, const uint col,
const uint paintcol, const int alpha_i)
{
- switch (tool) {
- case PAINT_BLEND_MIX:
- case PAINT_BLEND_BLUR: return mcol_blend(col, paintcol, alpha_i);
- case PAINT_BLEND_AVERAGE: return mcol_blend(col, paintcol, alpha_i);
- case PAINT_BLEND_SMEAR: return mcol_blend(col, paintcol, alpha_i);
- case PAINT_BLEND_ADD: return mcol_add(col, paintcol, alpha_i);
- case PAINT_BLEND_SUB: return mcol_sub(col, paintcol, alpha_i);
- case PAINT_BLEND_MUL: return mcol_mul(col, paintcol, alpha_i);
- case PAINT_BLEND_LIGHTEN: return mcol_lighten(col, paintcol, alpha_i);
- case PAINT_BLEND_DARKEN: return mcol_darken(col, paintcol, alpha_i);
- case PAINT_BLEND_COLORDODGE: return mcol_colordodge(col, paintcol, alpha_i);
- case PAINT_BLEND_DIFFERENCE: return mcol_difference(col, paintcol, alpha_i);
- case PAINT_BLEND_SCREEN: return mcol_screen(col, paintcol, alpha_i);
- case PAINT_BLEND_HARDLIGHT: return mcol_hardlight(col, paintcol, alpha_i);
- case PAINT_BLEND_OVERLAY: return mcol_overlay(col, paintcol, alpha_i);
- case PAINT_BLEND_SOFTLIGHT: return mcol_softlight(col, paintcol, alpha_i);
- case PAINT_BLEND_EXCLUSION: return mcol_exclusion(col, paintcol, alpha_i);
- case PAINT_BLEND_LUMINOCITY: return mcol_luminosity(col, paintcol, alpha_i);
- case PAINT_BLEND_SATURATION: return mcol_saturation(col, paintcol, alpha_i);
- case PAINT_BLEND_HUE: return mcol_hue(col, paintcol, alpha_i);
+ switch ((IMB_BlendMode)tool) {
+ case IMB_BLEND_MIX: return mcol_blend(col, paintcol, alpha_i);
+ case IMB_BLEND_ADD: return mcol_add(col, paintcol, alpha_i);
+ case IMB_BLEND_SUB: return mcol_sub(col, paintcol, alpha_i);
+ case IMB_BLEND_MUL: return mcol_mul(col, paintcol, alpha_i);
+ case IMB_BLEND_LIGHTEN: return mcol_lighten(col, paintcol, alpha_i);
+ case IMB_BLEND_DARKEN: return mcol_darken(col, paintcol, alpha_i);
+ case IMB_BLEND_COLORDODGE: return mcol_colordodge(col, paintcol, alpha_i);
+ case IMB_BLEND_DIFFERENCE: return mcol_difference(col, paintcol, alpha_i);
+ case IMB_BLEND_SCREEN: return mcol_screen(col, paintcol, alpha_i);
+ case IMB_BLEND_HARDLIGHT: return mcol_hardlight(col, paintcol, alpha_i);
+ case IMB_BLEND_OVERLAY: return mcol_overlay(col, paintcol, alpha_i);
+ case IMB_BLEND_SOFTLIGHT: return mcol_softlight(col, paintcol, alpha_i);
+ case IMB_BLEND_EXCLUSION: return mcol_exclusion(col, paintcol, alpha_i);
+ case IMB_BLEND_LUMINOSITY: return mcol_luminosity(col, paintcol, alpha_i);
+ case IMB_BLEND_SATURATION: return mcol_saturation(col, paintcol, alpha_i);
+ case IMB_BLEND_HUE: return mcol_hue(col, paintcol, alpha_i);
/* non-color */
- case PAINT_BLEND_ALPHA_SUB: return mcol_alpha_sub(col, alpha_i);
- case PAINT_BLEND_ALPHA_ADD: return mcol_alpha_add(col, alpha_i);
+ case IMB_BLEND_ERASE_ALPHA: return mcol_alpha_sub(col, alpha_i);
+ case IMB_BLEND_ADD_ALPHA: return mcol_alpha_add(col, alpha_i);
default:
BLI_assert(0);
return 0;
diff --git a/source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c b/source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c
index d15fd41a510..46eb3995ea3 100644
--- a/source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c
+++ b/source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c
@@ -591,7 +591,7 @@ static void gradientVert_update(WPGradient_userData *grad_data, int index)
MDeformVert *dv = &me->dvert[index];
MDeformWeight *dw = defvert_verify_index(dv, grad_data->def_nr);
// dw->weight = alpha; // testing
- int tool = grad_data->brush->vertexpaint_tool;
+ int tool = grad_data->brush->blend;
float testw;
/* init if we just added */
diff --git a/source/blender/editors/sculpt_paint/paint_vertex_weight_utils.c b/source/blender/editors/sculpt_paint/paint_vertex_weight_utils.c
index 51cd759b260..0a1fc7c0b4e 100644
--- a/source/blender/editors/sculpt_paint/paint_vertex_weight_utils.c
+++ b/source/blender/editors/sculpt_paint/paint_vertex_weight_utils.c
@@ -45,6 +45,9 @@
#include "BKE_report.h"
#include "BKE_object.h"
+/* Only for blend modes. */
+#include "IMB_imbuf.h"
+
#include "WM_api.h"
#include "WM_types.h"
@@ -280,31 +283,24 @@ float ED_wpaint_blend_tool(
const float weight,
const float paintval, const float alpha)
{
- switch (tool) {
- case PAINT_BLEND_MIX:
- case PAINT_BLEND_AVERAGE:
- case PAINT_BLEND_SMEAR:
- case PAINT_BLEND_BLUR: return wval_blend(weight, paintval, alpha);
- case PAINT_BLEND_ADD: return wval_add(weight, paintval, alpha);
- case PAINT_BLEND_SUB: return wval_sub(weight, paintval, alpha);
- case PAINT_BLEND_MUL: return wval_mul(weight, paintval, alpha);
- case PAINT_BLEND_LIGHTEN: return wval_lighten(weight, paintval, alpha);
- case PAINT_BLEND_DARKEN: return wval_darken(weight, paintval, alpha);
+ switch ((IMB_BlendMode)tool) {
+ case IMB_BLEND_MIX: return wval_blend(weight, paintval, alpha);
+ case IMB_BLEND_ADD: return wval_add(weight, paintval, alpha);
+ case IMB_BLEND_SUB: return wval_sub(weight, paintval, alpha);
+ case IMB_BLEND_MUL: return wval_mul(weight, paintval, alpha);
+ case IMB_BLEND_LIGHTEN: return wval_lighten(weight, paintval, alpha);
+ case IMB_BLEND_DARKEN: return wval_darken(weight, paintval, alpha);
/* Mostly make sense for color: support anyway. */
- case PAINT_BLEND_COLORDODGE: return wval_colordodge(weight, paintval, alpha);
- case PAINT_BLEND_DIFFERENCE: return wval_difference(weight, paintval, alpha);
- case PAINT_BLEND_SCREEN: return wval_screen(weight, paintval, alpha);
- case PAINT_BLEND_HARDLIGHT: return wval_hardlight(weight, paintval, alpha);
- case PAINT_BLEND_OVERLAY: return wval_overlay(weight, paintval, alpha);
- case PAINT_BLEND_SOFTLIGHT: return wval_softlight(weight, paintval, alpha);
- case PAINT_BLEND_EXCLUSION: return wval_exclusion(weight, paintval, alpha);
+ case IMB_BLEND_COLORDODGE: return wval_colordodge(weight, paintval, alpha);
+ case IMB_BLEND_DIFFERENCE: return wval_difference(weight, paintval, alpha);
+ case IMB_BLEND_SCREEN: return wval_screen(weight, paintval, alpha);
+ case IMB_BLEND_HARDLIGHT: return wval_hardlight(weight, paintval, alpha);
+ case IMB_BLEND_OVERLAY: return wval_overlay(weight, paintval, alpha);
+ case IMB_BLEND_SOFTLIGHT: return wval_softlight(weight, paintval, alpha);
+ case IMB_BLEND_EXCLUSION: return wval_exclusion(weight, paintval, alpha);
/* Only for color: just use blend. */
- case PAINT_BLEND_LUMINOCITY:
- case PAINT_BLEND_SATURATION:
- case PAINT_BLEND_HUE:
- case PAINT_BLEND_ALPHA_SUB:
- case PAINT_BLEND_ALPHA_ADD:
- default: return wval_blend(weight, paintval, alpha);
+ default:
+ return wval_blend(weight, paintval, alpha);
}
}