diff --git a/scripts/startup/bl_ui/properties_grease_pencil_common.py b/scripts/startup/bl_ui/properties_grease_pencil_common.py index 06a015743da..95f3ffe6572 100644 --- a/scripts/startup/bl_ui/properties_grease_pencil_common.py +++ b/scripts/startup/bl_ui/properties_grease_pencil_common.py @@ -499,44 +499,6 @@ class GreasePencilMaterialsPanel: row.template_ID(space, "pin_id") -class GreasePencilVertexcolorPanel: - - def draw(self, context): - layout = self.layout - layout.use_property_split = True - layout.use_property_decorate = False - - tool_settings = context.scene.tool_settings - is_vertex = context.mode == 'VERTEX_GPENCIL' - gpencil_paint = tool_settings.gpencil_vertex_paint if is_vertex else tool_settings.gpencil_paint - brush = gpencil_paint.brush - gp_settings = brush.gpencil_settings - tool = brush.gpencil_vertex_tool if is_vertex else brush.gpencil_tool - - ob = context.object - - if ob: - col = layout.column() - col.template_color_picker(brush, "color", value_slider=True) - - sub_row = layout.row(align=True) - sub_row.prop(brush, "color", text="") - sub_row.prop(brush, "secondary_color", text="") - - sub_row.operator("gpencil.tint_flip", icon='FILE_REFRESH', text="") - - row = layout.row(align=True) - row.template_ID(gpencil_paint, "palette", new="palette.new") - if gpencil_paint.palette: - layout.template_palette(gpencil_paint, "palette", color=True) - - if tool in {'DRAW', 'FILL'} and is_vertex is False: - row = layout.row(align=True) - row.prop(gp_settings, "vertex_mode", text="Mode") - row = layout.row(align=True) - row.prop(gp_settings, "vertex_color_factor", slider=True, text="Mix Factor") - - class GPENCIL_UL_layer(UIList): def draw_item(self, _context, layout, _data, item, icon, _active_data, _active_propname, _index): # assert(isinstance(item, bpy.types.GPencilLayer) diff --git a/scripts/startup/bl_ui/space_view3d.py b/scripts/startup/bl_ui/space_view3d.py index 5c98b4c4b54..6718e69b7e6 100644 --- a/scripts/startup/bl_ui/space_view3d.py +++ b/scripts/startup/bl_ui/space_view3d.py @@ -20,7 +20,6 @@ from bl_ui.properties_grease_pencil_common import ( AnnotationDataPanel, AnnotationOnionSkin, GreasePencilMaterialsPanel, - GreasePencilVertexcolorPanel, ) from bl_ui.space_toolsystem_common import ( ToolActivePanelHelper, @@ -8594,17 +8593,22 @@ class TOPBAR_PT_grease_pencil_vertex_color(Panel): paint = context.scene.tool_settings.gpencil_paint elif ob.mode == 'VERTEX_GREASE_PENCIL': paint = context.scene.tool_settings.gpencil_vertex_paint + use_unified_paint = (ob.mode != 'PAINT_GREASE_PENCIL') ups = context.tool_settings.unified_paint_settings brush = paint.brush - prop_owner = ups if ups.use_unified_color else brush + prop_owner = ups if use_unified_paint and ups.use_unified_color else brush col = layout.column() col.template_color_picker(prop_owner, "color", value_slider=True) sub_row = layout.row(align=True) - UnifiedPaintPanel.prop_unified_color(sub_row, context, brush, "color", text="") - UnifiedPaintPanel.prop_unified_color(sub_row, context, brush, "secondary_color", text="") + if use_unified_paint: + UnifiedPaintPanel.prop_unified_color(sub_row, context, brush, "color", text="") + UnifiedPaintPanel.prop_unified_color(sub_row, context, brush, "secondary_color", text="") + else: + sub_row.prop(brush, "color", text="") + sub_row.prop(brush, "secondary_color", text="") sub_row.operator("paint.brush_colors_flip", icon='FILE_REFRESH', text="") diff --git a/scripts/startup/bl_ui/space_view3d_toolbar.py b/scripts/startup/bl_ui/space_view3d_toolbar.py index 7f8e98d8c08..3b1decdebc3 100644 --- a/scripts/startup/bl_ui/space_view3d_toolbar.py +++ b/scripts/startup/bl_ui/space_view3d_toolbar.py @@ -2159,16 +2159,25 @@ class VIEW3D_PT_tools_grease_pencil_brush_vertex_color(View3DPanel, Panel): tool_settings = context.tool_settings settings = tool_settings.gpencil_vertex_paint brush = settings.brush + use_unified_paint = (context.object.mode != 'PAINT_GREASE_PENCIL') + ups = context.tool_settings.unified_paint_settings + prop_owner = ups if use_unified_paint and ups.use_unified_color else brush col = layout.column() - col.template_color_picker(brush, "color", value_slider=True) + col.template_color_picker(prop_owner, "color", value_slider=True) sub_row = col.row(align=True) - sub_row.prop(brush, "color", text="") - sub_row.prop(brush, "secondary_color", text="") + if use_unified_paint: + UnifiedPaintPanel.prop_unified_color(sub_row, context, brush, "color", text="") + UnifiedPaintPanel.prop_unified_color(sub_row, context, brush, "secondary_color", text="") + else: + sub_row.prop(brush, "color", text="") + sub_row.prop(brush, "secondary_color", text="") - sub_row.operator("gpencil.tint_flip", icon='FILE_REFRESH', text="") + sub_row.operator("paint.brush_colors_flip", icon='FILE_REFRESH', text="") + if use_unified_paint: + sub_row.prop(ups, "use_unified_color", text="", icon='BRUSHES_ALL') class VIEW3D_PT_tools_grease_pencil_brush_vertex_falloff(GreasePencilBrushFalloff, Panel, View3DPaintPanel): @@ -2272,7 +2281,7 @@ class VIEW3D_PT_tools_grease_pencil_brush_mixcolor(View3DPanel, Panel): sub_row.prop(brush, "color", text="") sub_row.prop(brush, "secondary_color", text="") - sub_row.operator("gpencil.tint_flip", icon='FILE_REFRESH', text="") + sub_row.operator("paint.brush_colors_flip", icon='FILE_REFRESH', text="") if brush.gpencil_tool in {'DRAW', 'FILL'}: col.prop(gp_settings, "vertex_mode", text="Mode") @@ -2778,6 +2787,9 @@ class VIEW3D_PT_tools_grease_pencil_v3_brush_mixcolor(View3DPanel, Panel): settings = tool_settings.gpencil_paint brush = settings.brush gp_settings = brush.gpencil_settings + use_unified_paint = (context.object.mode != 'PAINT_GREASE_PENCIL') + ups = context.tool_settings.unified_paint_settings + prop_owner = ups if use_unified_paint and ups.use_unified_color else brush row = layout.row() row.prop(settings, "color_mode", expand=True) @@ -2787,11 +2799,16 @@ class VIEW3D_PT_tools_grease_pencil_v3_brush_mixcolor(View3DPanel, Panel): col = layout.column() col.enabled = settings.color_mode == 'VERTEXCOLOR' - col.template_color_picker(brush, "color", value_slider=True) + # This panel is only used for Draw mode, which does not use unified paint settings. + col.template_color_picker(prop_owner, "color", value_slider=True) sub_row = col.row(align=True) - UnifiedPaintPanel.prop_unified_color(sub_row, context, brush, "color", text="") - UnifiedPaintPanel.prop_unified_color(sub_row, context, brush, "secondary_color", text="") + if use_unified_paint: + UnifiedPaintPanel.prop_unified_color(sub_row, context, brush, "color", text="") + UnifiedPaintPanel.prop_unified_color(sub_row, context, brush, "secondary_color", text="") + else: + sub_row.prop(brush, "color", text="") + sub_row.prop(brush, "secondary_color", text="") sub_row.operator("paint.brush_colors_flip", icon='FILE_REFRESH', text="") diff --git a/source/blender/blenkernel/BKE_brush.hh b/source/blender/blenkernel/BKE_brush.hh index 6b2f32cca14..df850a8101f 100644 --- a/source/blender/blenkernel/BKE_brush.hh +++ b/source/blender/blenkernel/BKE_brush.hh @@ -22,6 +22,7 @@ struct ImBuf; struct ImagePool; struct Main; struct MTex; +struct Paint; struct Scene; struct UnifiedPaintSettings; @@ -141,9 +142,11 @@ ImBuf *BKE_brush_gen_radial_control_imbuf(Brush *br, bool secondary, bool displa /* Unified strength size and color. */ -const float *BKE_brush_color_get(const Scene *scene, const Brush *brush); -const float *BKE_brush_secondary_color_get(const Scene *scene, const Brush *brush); -void BKE_brush_color_set(Scene *scene, Brush *brush, const float color[3]); +const float *BKE_brush_color_get(const Scene *scene, const Paint *paint, const Brush *brush); +const float *BKE_brush_secondary_color_get(const Scene *scene, + const Paint *paint, + const Brush *brush); +void BKE_brush_color_set(Scene *scene, const Paint *paint, Brush *brush, const float color[3]); int BKE_brush_size_get(const Scene *scene, const Brush *brush); void BKE_brush_size_set(Scene *scene, Brush *brush, int size); diff --git a/source/blender/blenkernel/BKE_paint.hh b/source/blender/blenkernel/BKE_paint.hh index a7d1b6667d1..bc41e29f7b7 100644 --- a/source/blender/blenkernel/BKE_paint.hh +++ b/source/blender/blenkernel/BKE_paint.hh @@ -210,6 +210,7 @@ Paint *BKE_paint_get_active(Scene *sce, ViewLayer *view_layer); Paint *BKE_paint_get_active_from_context(const bContext *C); PaintMode BKE_paintmode_get_active_from_context(const bContext *C); PaintMode BKE_paintmode_get_from_tool(const bToolRef *tref); +bool BKE_paint_use_unified_color(const ToolSettings *tool_settings, const Paint *paint); /* Paint brush retrieval and assignment. */ diff --git a/source/blender/blenkernel/intern/brush.cc b/source/blender/blenkernel/intern/brush.cc index e5d88344455..87feb1bcf19 100644 --- a/source/blender/blenkernel/intern/brush.cc +++ b/source/blender/blenkernel/intern/brush.cc @@ -1026,23 +1026,28 @@ float BKE_brush_sample_masktex( * In any case, a better solution is needed to prevent * inconsistency. */ -const float *BKE_brush_color_get(const Scene *scene, const Brush *brush) +const float *BKE_brush_color_get(const Scene *scene, const Paint *paint, const Brush *brush) { - UnifiedPaintSettings *ups = &scene->toolsettings->unified_paint_settings; - return (ups->flag & UNIFIED_PAINT_COLOR) ? ups->rgb : brush->rgb; + if (BKE_paint_use_unified_color(scene->toolsettings, paint)) { + return scene->toolsettings->unified_paint_settings.rgb; + } + return brush->rgb; } -const float *BKE_brush_secondary_color_get(const Scene *scene, const Brush *brush) +const float *BKE_brush_secondary_color_get(const Scene *scene, + const Paint *paint, + const Brush *brush) { - UnifiedPaintSettings *ups = &scene->toolsettings->unified_paint_settings; - return (ups->flag & UNIFIED_PAINT_COLOR) ? ups->secondary_rgb : brush->secondary_rgb; + if (BKE_paint_use_unified_color(scene->toolsettings, paint)) { + return scene->toolsettings->unified_paint_settings.secondary_rgb; + } + return brush->secondary_rgb; } -void BKE_brush_color_set(Scene *scene, Brush *brush, const float color[3]) +void BKE_brush_color_set(Scene *scene, const Paint *paint, Brush *brush, const float color[3]) { - UnifiedPaintSettings *ups = &scene->toolsettings->unified_paint_settings; - - if (ups->flag & UNIFIED_PAINT_COLOR) { + if (BKE_paint_use_unified_color(scene->toolsettings, paint)) { + UnifiedPaintSettings *ups = &scene->toolsettings->unified_paint_settings; copy_v3_v3(ups->rgb, color); } else { diff --git a/source/blender/blenkernel/intern/paint.cc b/source/blender/blenkernel/intern/paint.cc index 6b7507bfab0..6076bb46052 100644 --- a/source/blender/blenkernel/intern/paint.cc +++ b/source/blender/blenkernel/intern/paint.cc @@ -602,6 +602,16 @@ PaintMode BKE_paintmode_get_from_tool(const bToolRef *tref) return PaintMode::Invalid; } +bool BKE_paint_use_unified_color(const ToolSettings *tool_settings, const Paint *paint) +{ + /* Grease pencil draw mode never uses unified paint. */ + if (paint->runtime.ob_mode == OB_MODE_PAINT_GREASE_PENCIL) { + return false; + } + + return tool_settings->unified_paint_settings.flag & UNIFIED_PAINT_COLOR; +} + /** * After changing #Paint.brush_asset_reference, call this to activate the matching brush, importing * it if necessary. Has no effect if #Paint.brush is set already. diff --git a/source/blender/editors/grease_pencil/intern/grease_pencil_vertex_paint.cc b/source/blender/editors/grease_pencil/intern/grease_pencil_vertex_paint.cc index b9a718f4846..0a61ba0725f 100644 --- a/source/blender/editors/grease_pencil/intern/grease_pencil_vertex_paint.cc +++ b/source/blender/editors/grease_pencil/intern/grease_pencil_vertex_paint.cc @@ -331,7 +331,7 @@ static int grease_pencil_vertex_paint_set_exec(bContext *C, wmOperator *op) const float factor = RNA_float_get(op->ptr, "factor"); float3 color_linear; - srgb_to_linearrgb_v3_v3(color_linear, BKE_brush_color_get(&scene, &brush)); + srgb_to_linearrgb_v3_v3(color_linear, BKE_brush_color_get(&scene, &paint, &brush)); const ColorGeometry4f target_color(color_linear[0], color_linear[1], color_linear[2], 1.0f); std::atomic any_changed; diff --git a/source/blender/editors/interface/interface_handlers.cc b/source/blender/editors/interface/interface_handlers.cc index d1624623844..12752386b1b 100644 --- a/source/blender/editors/interface/interface_handlers.cc +++ b/source/blender/editors/interface/interface_handlers.cc @@ -6521,13 +6521,13 @@ static int ui_do_but_COLOR(bContext *C, uiBut *but, uiHandleButtonData *data, co if (but->rnaprop && RNA_property_subtype(but->rnaprop) == PROP_COLOR_GAMMA) { RNA_property_float_get_array(&but->rnapoin, but->rnaprop, color); - BKE_brush_color_set(scene, brush, color); + BKE_brush_color_set(scene, paint, brush, color); updated = true; } else if (but->rnaprop && RNA_property_subtype(but->rnaprop) == PROP_COLOR) { RNA_property_float_get_array(&but->rnapoin, but->rnaprop, color); IMB_colormanagement_scene_linear_to_srgb_v3(color, color); - BKE_brush_color_set(scene, brush, color); + BKE_brush_color_set(scene, paint, brush, color); updated = true; } diff --git a/source/blender/editors/sculpt_paint/grease_pencil_tint.cc b/source/blender/editors/sculpt_paint/grease_pencil_tint.cc index cdf6d89eabb..ae58236780f 100644 --- a/source/blender/editors/sculpt_paint/grease_pencil_tint.cc +++ b/source/blender/editors/sculpt_paint/grease_pencil_tint.cc @@ -71,7 +71,7 @@ void TintOperation::on_stroke_begin(const bContext &C, const InputSample & /*sta float4 color_linear; color_linear[3] = 1.0f; - srgb_to_linearrgb_v3_v3(color_linear, BKE_brush_color_get(scene, brush)); + srgb_to_linearrgb_v3_v3(color_linear, BKE_brush_color_get(scene, paint, brush)); color_ = ColorGeometry4f(color_linear); diff --git a/source/blender/editors/sculpt_paint/grease_pencil_vertex_paint.cc b/source/blender/editors/sculpt_paint/grease_pencil_vertex_paint.cc index 5769490c280..73fdda0acfa 100644 --- a/source/blender/editors/sculpt_paint/grease_pencil_vertex_paint.cc +++ b/source/blender/editors/sculpt_paint/grease_pencil_vertex_paint.cc @@ -44,7 +44,7 @@ void VertexPaintOperation::on_stroke_extended(const bContext &C, const bool do_fill = do_vertex_color_fill(brush); float color_linear[3]; - srgb_to_linearrgb_v3_v3(color_linear, BKE_brush_color_get(&scene, &brush)); + srgb_to_linearrgb_v3_v3(color_linear, BKE_brush_color_get(&scene, &paint, &brush)); const ColorGeometry4f mix_color(color_linear[0], color_linear[1], color_linear[2], 1.0f); this->foreach_editable_drawing(C, GrainSize(1), [&](const GreasePencilStrokeParams ¶ms) { diff --git a/source/blender/editors/sculpt_paint/grease_pencil_vertex_replace.cc b/source/blender/editors/sculpt_paint/grease_pencil_vertex_replace.cc index 8f63c130b51..610e595e7a1 100644 --- a/source/blender/editors/sculpt_paint/grease_pencil_vertex_replace.cc +++ b/source/blender/editors/sculpt_paint/grease_pencil_vertex_replace.cc @@ -41,7 +41,7 @@ void VertexReplaceOperation::on_stroke_extended(const bContext &C, const bool do_fill = do_vertex_color_fill(brush); float3 color_linear; - srgb_to_linearrgb_v3_v3(color_linear, BKE_brush_color_get(&scene, &brush)); + srgb_to_linearrgb_v3_v3(color_linear, BKE_brush_color_get(&scene, &paint, &brush)); const ColorGeometry4f replace_color(color_linear.x, color_linear.y, color_linear.z, 1.0f); this->foreach_editable_drawing(C, GrainSize(1), [&](const GreasePencilStrokeParams ¶ms) { diff --git a/source/blender/editors/sculpt_paint/paint_cursor.cc b/source/blender/editors/sculpt_paint/paint_cursor.cc index 35c2ec4920c..ae0957a8044 100644 --- a/source/blender/editors/sculpt_paint/paint_cursor.cc +++ b/source/blender/editors/sculpt_paint/paint_cursor.cc @@ -1603,7 +1603,7 @@ static void grease_pencil_brush_cursor_draw(PaintCursorContext *pcontext) } else if (pcontext->mode == PaintMode::VertexGPencil) { pcontext->pixel_radius = BKE_brush_size_get(pcontext->vc.scene, brush); - color = BKE_brush_color_get(pcontext->vc.scene, brush); + color = BKE_brush_color_get(pcontext->vc.scene, paint, brush); } GPU_line_width(1.0f); diff --git a/source/blender/editors/sculpt_paint/paint_image.cc b/source/blender/editors/sculpt_paint/paint_image.cc index 77856691e0c..f96f017742d 100644 --- a/source/blender/editors/sculpt_paint/paint_image.cc +++ b/source/blender/editors/sculpt_paint/paint_image.cc @@ -363,6 +363,7 @@ bool paint_use_opacity_masking(Brush *brush) } void paint_brush_color_get(Scene *scene, + const Paint *paint, Brush *br, bool color_correction, bool invert, @@ -372,7 +373,7 @@ void paint_brush_color_get(Scene *scene, float r_color[3]) { if (invert) { - copy_v3_v3(r_color, BKE_brush_secondary_color_get(scene, br)); + copy_v3_v3(r_color, BKE_brush_secondary_color_get(scene, paint, br)); } else { if (br->flag & BRUSH_USE_GRADIENT) { @@ -396,7 +397,7 @@ void paint_brush_color_get(Scene *scene, IMB_colormanagement_scene_linear_to_srgb_v3(r_color, color_gr); } else { - copy_v3_v3(r_color, BKE_brush_color_get(scene, br)); + copy_v3_v3(r_color, BKE_brush_color_get(scene, paint, br)); } } if (color_correction) { @@ -685,7 +686,7 @@ static int sample_color_invoke(bContext *C, wmOperator *op, const wmEvent *event data->launch_event = WM_userdef_event_type_from_keymap_type(event->type); data->show_cursor = ((paint->flags & PAINT_SHOW_BRUSH) != 0); - copy_v3_v3(data->initcolor, BKE_brush_color_get(scene, brush)); + copy_v3_v3(data->initcolor, BKE_brush_color_get(scene, paint, brush)); data->sample_palette = false; op->customdata = data; paint->flags &= ~PAINT_SHOW_BRUSH; @@ -725,7 +726,7 @@ static int sample_color_modal(bContext *C, wmOperator *op, const wmEvent *event) } if (data->sample_palette) { - BKE_brush_color_set(scene, brush, data->initcolor); + BKE_brush_color_set(scene, paint, brush, data->initcolor); RNA_boolean_set(op->ptr, "palette", true); } WM_cursor_modal_restore(CTX_wm_window(C)); @@ -1030,12 +1031,12 @@ void PAINT_OT_texture_paint_toggle(wmOperatorType *ot) static int brush_colors_flip_exec(bContext *C, wmOperator * /*op*/) { Scene &scene = *CTX_data_scene(C); - UnifiedPaintSettings &ups = scene.toolsettings->unified_paint_settings; Paint *paint = BKE_paint_get_active_from_context(C); Brush *br = BKE_paint_brush(paint); - if (ups.flag & UNIFIED_PAINT_COLOR) { + if (BKE_paint_use_unified_color(scene.toolsettings, paint)) { + UnifiedPaintSettings &ups = scene.toolsettings->unified_paint_settings; swap_v3_v3(ups.rgb, ups.secondary_rgb); } else if (br) { diff --git a/source/blender/editors/sculpt_paint/paint_image_2d.cc b/source/blender/editors/sculpt_paint/paint_image_2d.cc index 43b641a5c88..17a54da3445 100644 --- a/source/blender/editors/sculpt_paint/paint_image_2d.cc +++ b/source/blender/editors/sculpt_paint/paint_image_2d.cc @@ -75,6 +75,7 @@ struct BrushPainterCache { struct BrushPainter { Scene *scene; + const Paint *paint; Brush *brush; bool firsttouch; /* first paint op */ @@ -134,12 +135,16 @@ struct ImagePaintState { BlurKernel *blurkernel; }; -static BrushPainter *brush_painter_2d_new(Scene *scene, Brush *brush, bool invert) +static BrushPainter *brush_painter_2d_new(Scene *scene, + const Paint *paint, + Brush *brush, + bool invert) { BrushPainter *painter = MEM_cnew(__func__); painter->brush = brush; painter->scene = scene; + painter->paint = paint; painter->firsttouch = true; painter->cache_invert = invert; @@ -369,6 +374,7 @@ static ImBuf *brush_painter_imbuf_new( BrushPainter *painter, ImagePaintTile *tile, const int size, float pressure, float distance) { Scene *scene = painter->scene; + const Paint *paint = painter->paint; Brush *brush = painter->brush; BrushPainterCache *cache = &tile->cache; @@ -390,8 +396,15 @@ static ImBuf *brush_painter_imbuf_new( /* get brush color */ if (brush->image_brush_type == IMAGE_PAINT_BRUSH_TYPE_DRAW) { - paint_brush_color_get( - scene, brush, use_color_correction, cache->invert, distance, pressure, display, brush_rgb); + paint_brush_color_get(scene, + paint, + brush, + use_color_correction, + cache->invert, + distance, + pressure, + display, + brush_rgb); } else { brush_rgb[0] = 1.0f; @@ -451,6 +464,7 @@ static void brush_painter_imbuf_update(BrushPainter *painter, int yt) { Scene *scene = painter->scene; + const Paint *paint = painter->paint; Brush *brush = painter->brush; const MTex *mtex = &brush->mtex; BrushPainterCache *cache = &tile->cache; @@ -475,7 +489,7 @@ static void brush_painter_imbuf_update(BrushPainter *painter, /* get brush color */ if (brush->image_brush_type == IMAGE_PAINT_BRUSH_TYPE_DRAW) { paint_brush_color_get( - scene, brush, use_color_correction, cache->invert, 0.0f, 1.0f, display, brush_rgb); + scene, paint, brush, use_color_correction, cache->invert, 0.0f, 1.0f, display, brush_rgb); } else { brush_rgb[0] = 1.0f; @@ -1565,6 +1579,7 @@ void *paint_2d_new_stroke(bContext *C, wmOperator *op, int mode) Scene *scene = CTX_data_scene(C); SpaceImage *sima = CTX_wm_space_image(C); ToolSettings *settings = scene->toolsettings; + const Paint *paint = BKE_paint_get_active_from_context(C); Brush *brush = BKE_paint_brush(&settings->imapaint.paint); ImagePaintState *s = MEM_cnew(__func__); @@ -1645,7 +1660,7 @@ void *paint_2d_new_stroke(bContext *C, wmOperator *op, int mode) paint_brush_init_tex(s->brush); /* create painter */ - s->painter = brush_painter_2d_new(scene, s->brush, mode == BRUSH_STROKE_INVERT); + s->painter = brush_painter_2d_new(scene, paint, s->brush, mode == BRUSH_STROKE_INVERT); return s; } diff --git a/source/blender/editors/sculpt_paint/paint_image_ops_paint.cc b/source/blender/editors/sculpt_paint/paint_image_ops_paint.cc index ef543319c86..17c8f1134d9 100644 --- a/source/blender/editors/sculpt_paint/paint_image_ops_paint.cc +++ b/source/blender/editors/sculpt_paint/paint_image_ops_paint.cc @@ -61,6 +61,7 @@ class AbstractPaintMode { virtual void paint_stroke_done(void *stroke_handle) = 0; virtual void paint_gradient_fill(const bContext *C, const Scene *scene, + const Paint *paint, Brush *brush, PaintStroke *stroke, void *stroke_handle, @@ -68,6 +69,7 @@ class AbstractPaintMode { float mouse_end[2]) = 0; virtual void paint_bucket_fill(const bContext *C, const Scene *scene, + const Paint *paint, Brush *brush, PaintStroke *stroke, void *stroke_handle, @@ -107,6 +109,7 @@ class ImagePaintMode : public AbstractPaintMode { void paint_gradient_fill(const bContext *C, const Scene * /*scene*/, + const Paint * /*paint*/, Brush *brush, PaintStroke * /*stroke*/, void *stroke_handle, @@ -118,6 +121,7 @@ class ImagePaintMode : public AbstractPaintMode { void paint_bucket_fill(const bContext *C, const Scene *scene, + const Paint *paint, Brush *brush, PaintStroke *stroke, void *stroke_handle, @@ -126,10 +130,10 @@ class ImagePaintMode : public AbstractPaintMode { { float color[3]; if (paint_stroke_inverted(stroke)) { - srgb_to_linearrgb_v3_v3(color, BKE_brush_secondary_color_get(scene, brush)); + srgb_to_linearrgb_v3_v3(color, BKE_brush_secondary_color_get(scene, paint, brush)); } else { - srgb_to_linearrgb_v3_v3(color, BKE_brush_color_get(scene, brush)); + srgb_to_linearrgb_v3_v3(color, BKE_brush_color_get(scene, paint, brush)); } paint_2d_bucket_fill(C, color, brush, mouse_start, mouse_end, stroke_handle); } @@ -167,29 +171,32 @@ class ProjectionPaintMode : public AbstractPaintMode { void paint_gradient_fill(const bContext *C, const Scene *scene, + const Paint *paint, Brush *brush, PaintStroke *stroke, void *stroke_handle, float mouse_start[2], float mouse_end[2]) override { - paint_fill(C, scene, brush, stroke, stroke_handle, mouse_start, mouse_end); + paint_fill(C, scene, paint, brush, stroke, stroke_handle, mouse_start, mouse_end); } void paint_bucket_fill(const bContext *C, const Scene *scene, + const Paint *paint, Brush *brush, PaintStroke *stroke, void *stroke_handle, float mouse_start[2], float mouse_end[2]) override { - paint_fill(C, scene, brush, stroke, stroke_handle, mouse_start, mouse_end); + paint_fill(C, scene, paint, brush, stroke, stroke_handle, mouse_start, mouse_end); } private: void paint_fill(const bContext *C, const Scene *scene, + const Paint * /*paint*/, Brush *brush, PaintStroke *stroke, void *stroke_handle, @@ -391,6 +398,7 @@ static void paint_stroke_done(const bContext *C, PaintStroke *stroke) Scene *scene = CTX_data_scene(C); ToolSettings *toolsettings = scene->toolsettings; PaintOperation *pop = static_cast(paint_stroke_mode_data(stroke)); + const Paint *paint = BKE_paint_get_active_from_context(C); Brush *brush = BKE_paint_brush(&toolsettings->imapaint.paint); toolsettings->imapaint.flag &= ~IMAGEPAINT_DRAWING; @@ -398,11 +406,11 @@ static void paint_stroke_done(const bContext *C, PaintStroke *stroke) if (brush->image_brush_type == IMAGE_PAINT_BRUSH_TYPE_FILL) { if (brush->flag & BRUSH_USE_GRADIENT) { pop->mode->paint_gradient_fill( - C, scene, brush, stroke, pop->stroke_handle, pop->startmouse, pop->prevmouse); + C, scene, paint, brush, stroke, pop->stroke_handle, pop->startmouse, pop->prevmouse); } else { pop->mode->paint_bucket_fill( - C, scene, brush, stroke, pop->stroke_handle, pop->startmouse, pop->prevmouse); + C, scene, paint, brush, stroke, pop->stroke_handle, pop->startmouse, pop->prevmouse); } } pop->mode->paint_stroke_done(pop->stroke_handle); diff --git a/source/blender/editors/sculpt_paint/paint_image_proj.cc b/source/blender/editors/sculpt_paint/paint_image_proj.cc index 3540130328f..4dcc31ba88f 100644 --- a/source/blender/editors/sculpt_paint/paint_image_proj.cc +++ b/source/blender/editors/sculpt_paint/paint_image_proj.cc @@ -265,6 +265,7 @@ struct ProjPaintState { float paint_color_linear[3]; float dither; + const Paint *paint; Brush *brush; /** @@ -5749,6 +5750,7 @@ static void paint_proj_stroke_ps(const bContext * /*C*/, ProjPaintState *ps) { ProjStrokeHandle *ps_handle = static_cast(ps_handle_p); + const Paint *paint = ps->paint; Brush *brush = ps->brush; Scene *scene = ps->scene; @@ -5761,6 +5763,7 @@ static void paint_proj_stroke_ps(const bContext * /*C*/, /* handle gradient and inverted stroke color here */ if (ELEM(ps->brush_type, IMAGE_PAINT_BRUSH_TYPE_DRAW, IMAGE_PAINT_BRUSH_TYPE_FILL)) { paint_brush_color_get(scene, + paint, brush, false, ps->mode == BRUSH_STROKE_INVERT, @@ -5836,6 +5839,7 @@ static void project_state_init(bContext *C, Object *ob, ProjPaintState *ps, int /* brush */ ps->mode = BrushStrokeMode(mode); + ps->paint = BKE_paint_get_active_from_context(C); ps->brush = BKE_paint_brush(&settings->imapaint.paint); if (ps->brush) { Brush *brush = ps->brush; diff --git a/source/blender/editors/sculpt_paint/paint_intern.hh b/source/blender/editors/sculpt_paint/paint_intern.hh index f904d8548da..648572fc318 100644 --- a/source/blender/editors/sculpt_paint/paint_intern.hh +++ b/source/blender/editors/sculpt_paint/paint_intern.hh @@ -304,6 +304,7 @@ void paint_proj_redraw(const bContext *C, void *ps_handle_p, bool final); void paint_proj_stroke_done(void *ps_handle_p); void paint_brush_color_get(Scene *scene, + const Paint *paint, Brush *br, bool color_correction, bool invert, diff --git a/source/blender/editors/sculpt_paint/paint_ops.cc b/source/blender/editors/sculpt_paint/paint_ops.cc index b719fbe8109..b2114f858da 100644 --- a/source/blender/editors/sculpt_paint/paint_ops.cc +++ b/source/blender/editors/sculpt_paint/paint_ops.cc @@ -185,9 +185,10 @@ static int palette_color_add_exec(bContext *C, wmOperator * /*op*/) PaintMode::Texture2D, PaintMode::Vertex, PaintMode::Sculpt, - PaintMode::GPencil)) + PaintMode::GPencil, + PaintMode::VertexGPencil)) { - copy_v3_v3(color->rgb, BKE_brush_color_get(scene, brush)); + copy_v3_v3(color->rgb, BKE_brush_color_get(scene, paint, brush)); color->value = 0.0; } else if (mode == PaintMode::Weight) { diff --git a/source/blender/editors/sculpt_paint/paint_utils.cc b/source/blender/editors/sculpt_paint/paint_utils.cc index f6b992b361e..6eede151042 100644 --- a/source/blender/editors/sculpt_paint/paint_utils.cc +++ b/source/blender/editors/sculpt_paint/paint_utils.cc @@ -405,7 +405,7 @@ void paint_sample_color( } else { linearrgb_to_srgb_v3_v3(rgba_f, rgba_f); - BKE_brush_color_set(scene, br, rgba_f); + BKE_brush_color_set(scene, paint, br, rgba_f); } } else { @@ -418,7 +418,7 @@ void paint_sample_color( else { float rgba_f[3]; rgb_uchar_to_float(rgba_f, rgba); - BKE_brush_color_set(scene, br, rgba_f); + BKE_brush_color_set(scene, paint, br, rgba_f); } } BKE_image_release_ibuf(image, ibuf, nullptr); @@ -445,7 +445,7 @@ void paint_sample_color( copy_v3_v3(color->rgb, rgba_f); } else { - BKE_brush_color_set(scene, br, rgba_f); + BKE_brush_color_set(scene, paint, br, rgba_f); } return; } @@ -462,7 +462,7 @@ void paint_sample_color( copy_v3_v3(color->rgb, rgb_fl); } else { - BKE_brush_color_set(scene, br, rgb_fl); + BKE_brush_color_set(scene, paint, br, rgb_fl); } } } diff --git a/source/blender/editors/sculpt_paint/paint_vertex.cc b/source/blender/editors/sculpt_paint/paint_vertex.cc index 22aef2f9c31..99cdf831631 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex.cc +++ b/source/blender/editors/sculpt_paint/paint_vertex.cc @@ -651,8 +651,8 @@ static ColorPaint4f vpaint_get_current_col(Scene &scene, VPaint &vp, bool second { const Brush *brush = BKE_paint_brush_for_read(&vp.paint); float color[4]; - const float *brush_color = secondary ? BKE_brush_secondary_color_get(&scene, brush) : - BKE_brush_color_get(&scene, brush); + const float *brush_color = secondary ? BKE_brush_secondary_color_get(&scene, &vp.paint, brush) : + BKE_brush_color_get(&scene, &vp.paint, brush); IMB_colormanagement_srgb_to_scene_linear_v3(color, brush_color); color[3] = 1.0f; /* alpha isn't used, could even be removed to speedup paint a little */ diff --git a/source/blender/editors/sculpt_paint/sculpt_expand.cc b/source/blender/editors/sculpt_paint/sculpt_expand.cc index 94adf4af6b6..f04bd878d82 100644 --- a/source/blender/editors/sculpt_paint/sculpt_expand.cc +++ b/source/blender/editors/sculpt_paint/sculpt_expand.cc @@ -2579,11 +2579,12 @@ static void cache_initial_config_set(bContext *C, wmOperator *op, Cache &expand_ /* Texture and color data from the active Brush. */ Scene &scene = *CTX_data_scene(C); + const Paint *paint = BKE_paint_get_active_from_context(C); const Sculpt &sd = *CTX_data_tool_settings(C)->sculpt; expand_cache.brush = BKE_paint_brush_for_read(&sd.paint); BKE_curvemapping_init(expand_cache.brush->curve); copy_v4_fl(expand_cache.fill_color, 1.0f); - copy_v3_v3(expand_cache.fill_color, BKE_brush_color_get(&scene, expand_cache.brush)); + copy_v3_v3(expand_cache.fill_color, BKE_brush_color_get(&scene, paint, expand_cache.brush)); IMB_colormanagement_srgb_to_scene_linear_v3(expand_cache.fill_color, expand_cache.fill_color); expand_cache.scene = CTX_data_scene(C); diff --git a/source/blender/editors/sculpt_paint/sculpt_ops.cc b/source/blender/editors/sculpt_paint/sculpt_ops.cc index 575f29eaa82..b0366cd6648 100644 --- a/source/blender/editors/sculpt_paint/sculpt_ops.cc +++ b/source/blender/editors/sculpt_paint/sculpt_ops.cc @@ -645,7 +645,7 @@ static int sample_color_invoke(bContext *C, wmOperator *op, const wmEvent * /*ev float color_srgb[3]; IMB_colormanagement_scene_linear_to_srgb_v3(color_srgb, active_vertex_color); - BKE_brush_color_set(&scene, &brush, color_srgb); + BKE_brush_color_set(&scene, &sd.paint, &brush, color_srgb); WM_event_add_notifier(C, NC_BRUSH | NA_EDITED, &brush); diff --git a/source/blender/editors/sculpt_paint/sculpt_paint_color.cc b/source/blender/editors/sculpt_paint/sculpt_paint_color.cc index 86a2475985b..126fa857c05 100644 --- a/source/blender/editors/sculpt_paint/sculpt_paint_color.cc +++ b/source/blender/editors/sculpt_paint/sculpt_paint_color.cc @@ -347,6 +347,7 @@ static void do_paint_brush_task(const Scene &scene, const Span corner_verts, const GroupedSpan vert_to_face_map, const MeshAttributeData &attribute_data, + const Paint &paint, const Brush &brush, const float4x4 &mat, const float4 wet_mix_sampled_color, @@ -409,8 +410,9 @@ static void do_paint_brush_task(const Scene &scene, } } - const float3 brush_color_rgb = ss.cache->invert ? BKE_brush_secondary_color_get(&scene, &brush) : - BKE_brush_color_get(&scene, &brush); + const float3 brush_color_rgb = ss.cache->invert ? + BKE_brush_secondary_color_get(&scene, &paint, &brush) : + BKE_brush_color_get(&scene, &paint, &brush); float4 brush_color(brush_color_rgb, 1.0f); IMB_colormanagement_srgb_to_scene_linear_v3(brush_color, brush_color); @@ -660,6 +662,7 @@ void do_paint_brush(const Scene &scene, corner_verts, vert_to_face_map, attribute_data, + sd.paint, brush, mat, wet_color, diff --git a/source/blender/editors/sculpt_paint/sculpt_paint_image.cc b/source/blender/editors/sculpt_paint/sculpt_paint_image.cc index c3ad1482b4e..2117d14b8f4 100644 --- a/source/blender/editors/sculpt_paint/sculpt_paint_image.cc +++ b/source/blender/editors/sculpt_paint/sculpt_paint_image.cc @@ -254,6 +254,7 @@ static BitVector<> init_uv_primitives_brush_test(SculptSession &ss, static void do_paint_pixels(const Scene &scene, const Depsgraph &depsgraph, Object &object, + const Paint &paint, const Brush &brush, ImageData image_data, bke::pbvh::Node &node) @@ -281,8 +282,8 @@ static void do_paint_pixels(const Scene &scene, brush_color[2] = float((hash >> 16) & 255) / 255.0f; #else copy_v3_v3(brush_color, - ss.cache->invert ? BKE_brush_secondary_color_get(&scene, &brush) : - BKE_brush_color_get(&scene, &brush)); + ss.cache->invert ? BKE_brush_secondary_color_get(&scene, &paint, &brush) : + BKE_brush_color_get(&scene, &paint, &brush)); #endif brush_color[3] = 1.0f; @@ -520,7 +521,7 @@ void SCULPT_do_paint_brush_image(const Scene &scene, do_push_undo_tile(*image_data.image, *image_data.image_user, nodes[i]); }); node_mask.foreach_index(GrainSize(1), [&](const int i) { - do_paint_pixels(scene, depsgraph, ob, *brush, image_data, nodes[i]); + do_paint_pixels(scene, depsgraph, ob, sd.paint, *brush, image_data, nodes[i]); }); fix_non_manifold_seam_bleeding(ob, *image_data.image, *image_data.image_user, nodes, node_mask);