Fix image projection paint with "mode" set to "Smooth"

Setting the paint.image_paint mode to smooth did nothing,
now it uses the soften tool as expected.
This commit is contained in:
Campbell Barton
2023-07-27 20:54:37 +10:00
parent d2fb16baeb
commit a5215fda33

View File

@@ -261,7 +261,14 @@ struct ProjPaintState {
float dither;
Brush *brush;
short tool, blend, mode;
/**
* Based on #Brush::imagepaint_tool but may be overridden by mode (#BrushStrokeMode).
* So check this value instead of `brush->imagepaint_tool`.
*/
short tool;
short blend;
BrushStrokeMode mode;
float brush_size;
Object *ob;
@@ -5869,15 +5876,18 @@ static void project_state_init(bContext *C, Object *ob, ProjPaintState *ps, int
ToolSettings *settings = scene->toolsettings;
/* brush */
ps->mode = mode;
ps->mode = BrushStrokeMode(mode);
ps->brush = BKE_paint_brush(&settings->imapaint.paint);
if (ps->brush) {
Brush *brush = ps->brush;
ps->tool = brush->imagepaint_tool;
ps->blend = brush->blend;
if (mode == BRUSH_STROKE_SMOOTH) {
ps->tool = PAINT_TOOL_SOFTEN;
}
/* only check for inversion for the soften tool, elsewhere,
* a resident brush inversion flag can cause issues */
if (brush->imagepaint_tool == PAINT_TOOL_SOFTEN) {
if (ps->tool == PAINT_TOOL_SOFTEN) {
ps->mode = (((ps->mode == BRUSH_STROKE_INVERT) ^ ((brush->flag & BRUSH_DIR_IN) != 0)) ?
BRUSH_STROKE_INVERT :
BRUSH_STROKE_NORMAL);
@@ -5887,8 +5897,7 @@ static void project_state_init(bContext *C, Object *ob, ProjPaintState *ps, int
/* disable for 3d mapping also because painting on mirrored mesh can create "stripes" */
ps->do_masking = paint_use_opacity_masking(brush);
ps->is_texbrush = (brush->mtex.tex && brush->imagepaint_tool == PAINT_TOOL_DRAW) ? true :
false;
ps->is_texbrush = (brush->mtex.tex && ps->tool == PAINT_TOOL_DRAW) ? true : false;
ps->is_maskbrush = (brush->mask_mtex.tex) ? true : false;
}
else {
@@ -5934,7 +5943,7 @@ static void project_state_init(bContext *C, Object *ob, ProjPaintState *ps, int
ps->do_layer_clone = (settings->imapaint.flag & IMAGEPAINT_PROJECT_LAYER_CLONE);
}
ps->do_stencil_brush = (ps->brush && ps->brush->imagepaint_tool == PAINT_TOOL_MASK);
ps->do_stencil_brush = (ps->tool == PAINT_TOOL_MASK);
/* deactivate stenciling for the stencil brush :) */
ps->do_layer_stencil = ((settings->imapaint.flag & IMAGEPAINT_PROJECT_LAYER_STENCIL) &&
!(ps->do_stencil_brush) && ps->stencil_ima);
@@ -5983,11 +5992,13 @@ void *paint_proj_new_stroke(bContext *C, Object *ob, const float mouse[2], int m
ps_handle->scene = scene;
ps_handle->brush = BKE_paint_brush(&settings->imapaint.paint);
/* bypass regular stroke logic */
if ((ps_handle->brush->imagepaint_tool == PAINT_TOOL_CLONE) && (mode == BRUSH_STROKE_INVERT)) {
view3d_operator_needs_opengl(C);
ps_handle->is_clone_cursor_pick = true;
return ps_handle;
if (mode == BRUSH_STROKE_INVERT) {
/* Bypass regular stroke logic. */
if (ps_handle->brush->imagepaint_tool == PAINT_TOOL_CLONE) {
view3d_operator_needs_opengl(C);
ps_handle->is_clone_cursor_pick = true;
return ps_handle;
}
}
ps_handle->orig_brush_size = BKE_brush_size_get(scene, ps_handle->brush);