[Bf-blender-cvs] [80109c976cf] blender2.8: Brush: split out vertex paint tool & blend mode
Campbell Barton
noreply at git.blender.org
Tue Nov 6 08:13:43 CET 2018
Commit: 80109c976cf1f43e1f1730cb827130aa270abaaa
Author: Campbell Barton
Date: Tue Nov 6 18:06:33 2018 +1100
Branches: blender2.8
https://developer.blender.org/rB80109c976cf1f43e1f1730cb827130aa270abaaa
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.
===================================================================
M release/scripts/startup/bl_ui/space_toolsystem_common.py
M release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
M release/scripts/startup/bl_ui/space_view3d.py
M release/scripts/startup/bl_ui/space_view3d_toolbar.py
M source/blender/blenkernel/BKE_paint.h
M source/blender/blenkernel/intern/paint.c
M source/blender/blenloader/intern/versioning_280.c
M source/blender/editors/interface/interface_icons.c
M source/blender/editors/interface/interface_region_tooltip.c
M source/blender/editors/sculpt_paint/paint_ops.c
M source/blender/editors/sculpt_paint/paint_vertex.c
M source/blender/editors/sculpt_paint/paint_vertex_color_utils.c
M source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c
M source/blender/editors/sculpt_paint/paint_vertex_weight_utils.c
M source/blender/makesdna/DNA_brush_types.h
M source/blender/makesrna/RNA_enum_types.h
M source/blender/makesrna/intern/rna_brush.c
M source/blender/makesrna/intern/rna_sculpt_paint.c
===================================================================
diff --git a/release/scripts/startup/bl_ui/space_toolsystem_common.py b/release/scripts/startup/bl_ui/space_toolsystem_common.py
index b034b99d8b3..138f69860a6 100644
--- a/release/scripts/startup/bl_ui/space_toolsystem_common.py
+++ b/release/scripts/startup/bl_ui/space_toolsystem_common.py
@@ -816,7 +816,7 @@ def keymap_from_context(context, space_type):
mode = context.active_object.mode
attr_op, attr_brush = {
'SCULPT': ("sculpt_tool", "sculpt_tool"),
- 'WEIGHT_PAINT': ("weight_paint_tool", "vertex_tool"),
+ 'WEIGHT_PAINT': ("weight_paint_tool", "weight_tool"),
'VERTEX_PAINT': ("vertex_paint_tool", "vertex_tool"),
'TEXTURE_PAINT': ("texture_paint_tool", "image_tool"),
}.get(mode, (None, None))
diff --git a/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py b/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
index bd64e7e3834..8ea25a99d6c 100644
--- a/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
+++ b/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
@@ -1040,7 +1040,7 @@ class _defs_weight_paint:
context,
icon_prefix="brush.paint_weight.",
type=bpy.types.Brush,
- attr="vertex_tool",
+ attr="weight_tool",
)
@ToolDef.from_fn
diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py
index 49c0c2c7834..81eeb567696 100644
--- a/release/scripts/startup/bl_ui/space_view3d.py
+++ b/release/scripts/startup/bl_ui/space_view3d.py
@@ -2107,8 +2107,10 @@ class VIEW3D_MT_brush(Menu):
layout.prop_menu_enum(brush, "sculpt_tool")
elif context.image_paint_object:
layout.prop_menu_enum(brush, "image_tool")
- elif context.vertex_paint_object or context.weight_paint_object:
+ elif context.vertex_paint_object:
layout.prop_menu_enum(brush, "vertex_tool")
+ elif context.weight_paint_object:
+ layout.prop_menu_enum(brush, "weight_tool")
# TODO: still missing a lot of brush options here
diff --git a/release/scripts/startup/bl_ui/space_view3d_toolbar.py b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
index 1abfb92917b..07ebfb36f7d 100644
--- a/release/scripts/startup/bl_ui/space_view3d_toolbar.py
+++ b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
@@ -399,9 +399,9 @@ class VIEW3D_PT_tools_brush(Panel, View3DPaintPanel):
self.prop_unified_strength(row, context, brush, "use_pressure_strength")
col.separator()
- col.prop(brush, "vertex_tool", text="Blend")
+ col.prop(brush, "blend", text="Blend")
- if brush.vertex_tool != 'SMEAR':
+ if brush.weight_tool != 'SMEAR':
col.prop(brush, "use_accumulate")
col.separator()
@@ -440,7 +440,7 @@ class VIEW3D_PT_tools_brush(Panel, View3DPaintPanel):
self.prop_unified_strength(row, context, brush, "use_pressure_strength")
col.separator()
- col.prop(brush, "vertex_tool", text="Blend")
+ col.prop(brush, "blend", text="Blend")
col.prop(brush, "use_alpha")
if brush.vertex_tool != 'SMEAR':
diff --git a/source/blender/blenkernel/BKE_paint.h b/source/blender/blenkernel/BKE_paint.h
index dc05642fb69..27f85d754cd 100644
--- a/source/blender/blenkernel/BKE_paint.h
+++ b/source/blender/blenkernel/BKE_paint.h
@@ -81,8 +81,9 @@ typedef enum ePaintMode {
ePaintTextureProjective = 3,
ePaintTexture2D = 4,
ePaintSculptUV = 5,
- ePaintInvalid = 6,
- ePaintGpencil = 7
+ ePaintGpencil = 6,
+
+ ePaintInvalid = 7,
} ePaintMode;
/* overlay invalidation */
@@ -139,6 +140,7 @@ void BKE_paint_cavity_curve_preset(struct Paint *p, int preset);
eObjectMode BKE_paint_object_mode_from_paint_mode(ePaintMode mode);
struct Paint *BKE_paint_get_active_from_paintmode(struct Scene *sce, ePaintMode mode);
const struct EnumPropertyItem *BKE_paint_get_tool_enum_from_paintmode(ePaintMode mode);
+uint BKE_paint_get_brush_tool_offset_from_paint_mode(const ePaintMode mode);
struct Paint *BKE_paint_get_active(struct Scene *sce, struct ViewLayer *view_layer);
struct Paint *BKE_paint_get_active_from_context(const struct bContext *C);
ePaintMode BKE_paintmode_get_active_from_context(const struct bContext *C);
diff --git a/source/blender/blenkernel/intern/paint.c b/source/blender/blenkernel/intern/paint.c
index 6bc86f75d71..55f6100c7be 100644
--- a/source/blender/blenkernel/intern/paint.c
+++ b/source/blender/blenkernel/intern/paint.c
@@ -182,9 +182,9 @@ const EnumPropertyItem *BKE_paint_get_tool_enum_from_paintmode(ePaintMode mode)
case ePaintVertex:
return rna_enum_brush_vertex_tool_items;
case ePaintWeight:
- return rna_enum_brush_vertex_tool_items;
- case ePaintTextureProjective:
+ return rna_enum_brush_weight_tool_items;
case ePaintTexture2D:
+ case ePaintTextureProjective:
return rna_enum_brush_image_tool_items;
case ePaintSculptUV:
return NULL;
@@ -369,7 +369,7 @@ void BKE_paint_runtime_init(const ToolSettings *ts, Paint *paint)
paint->runtime.ob_mode = OB_MODE_VERTEX_PAINT;
}
else if (paint == &ts->wpaint->paint) {
- paint->runtime.tool_offset = offsetof(Brush, vertexpaint_tool);
+ paint->runtime.tool_offset = offsetof(Brush, weightpaint_tool);
paint->runtime.ob_mode = OB_MODE_WEIGHT_PAINT;
}
else if (paint == &ts->gp_paint->paint) {
@@ -386,6 +386,26 @@ void BKE_paint_runtime_init(const ToolSettings *ts, Paint *paint)
}
}
+uint BKE_paint_get_brush_tool_offset_from_paint_mode(const ePaintMode mode)
+{
+ switch (mode) {
+ case ePaintTexture2D:
+ case ePaintTextureProjective:
+ return offsetof(Brush, imagepaint_tool);
+ case ePaintSculpt:
+ return offsetof(Brush, sculpt_tool);
+ case ePaintVertex:
+ return offsetof(Brush, vertexpaint_tool);
+ case ePaintWeight:
+ return offsetof(Brush, weightpaint_tool);
+ case ePaintGpencil:
+ return offsetof(Brush, gpencil_tool);
+ case ePaintSculptUV:
+ case ePaintInvalid:
+ break; /* We don't use these yet. */
+ }
+ return 0;
+}
/** Free (or release) any data used by this paint curve (does not free the pcurve itself). */
void BKE_paint_curve_free(PaintCurve *pc)
@@ -591,9 +611,8 @@ eObjectMode BKE_paint_object_mode_from_paint_mode(ePaintMode mode)
return OB_MODE_VERTEX_PAINT;
case ePaintWeight:
return OB_MODE_WEIGHT_PAINT;
- case ePaintTextureProjective:
- return OB_MODE_TEXTURE_PAINT;
case ePaintTexture2D:
+ case ePaintTextureProjective:
return OB_MODE_TEXTURE_PAINT;
case ePaintSculptUV:
return OB_MODE_EDIT;
diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c
index fc009f6c876..040c08eb63f 100644
--- a/source/blender/blenloader/intern/versioning_280.c
+++ b/source/blender/blenloader/intern/versioning_280.c
@@ -89,6 +89,9 @@
#include "BKE_key.h"
#include "BKE_unit.h"
+/* Only for IMB_BlendMode */
+#include "IMB_imbuf.h"
+
#include "DEG_depsgraph.h"
#include "BLT_translation.h"
@@ -2253,6 +2256,106 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
scene->eevee.overscan = 3.0f;
}
}
+
+ if (!DNA_struct_elem_find(fd->filesdna, "Brush", "char", "weightpaint_tool")) {
+ /* Magic defines from old files (2.7x) */
+
+#define PAINT_BLEND_MIX 0
+#define PAINT_BLEND_ADD 1
+#define PAINT_BLEND_SUB 2
+#define PAINT_BLEND_MUL 3
+#define PAINT_BLEND_BLUR 4
+#define PAINT_BLEND_LIGHTEN 5
+#define PAINT_BLEND_DARKEN 6
+#define PAINT_BLEND_AVERAGE 7
+#define PAINT_BLEND_SMEAR 8
+#define PAINT_BLEND_COLORDODGE 9
+#define PAINT_BLEND_DIFFERENCE 10
+#define PAINT_BLEND_SCREEN 11
+#define PAINT_BLEND_HARDLIGHT 12
+#define PAINT_BLEND_OVERLAY 13
+#define PAINT_BLEND_SOFTLIGHT 14
+#define PAINT_BLEND_EXCLUSION 15
+#define PAINT_BLEND_LUMINOSITY 16
+#define PAINT_BLEND_SATURATION 17
+#define PAINT_BLEND_HUE 18
+#define PAINT_BLEND_ALPHA_SUB 19
+#define PAINT_BLEND_ALPHA_ADD 20
+
+ for (Brush *brush = bmain->brush.first; brush; brush = brush->id.next) {
+ if (brush->ob_mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT)) {
+ const char tool_init = brush->vertexpaint_tool;
+ bool is_blend = false;
+
+ {
+ char tool = tool_init;
+ switch (tool_init) {
+ case PAINT_BLEND_MIX: tool = VPAINT_TOOL_DRAW; break;
+ case PAINT_BLEND_BLUR: tool = VPAINT_TOOL_BLUR; break;
+ case PAINT_BLEND_AVERAGE: tool = VPAINT_TOOL_AVERAGE; break;
+ case PAINT_BLEND_SMEAR: tool = VPAINT_TOOL_SMEAR; break;
+ default:
+ tool = VPAINT_TOOL_DRAW;
+ is_blend = true;
+ break;
+ }
+ brush->vertexpaint_tool = tool;
+ }
+
+ if (is_blend == false) {
+ brush->blend = IMB_BLEND_MIX;
+ }
+ else {
+ short blend = IMB_BLEND_MIX;
+ switch (tool_init) {
+ case PAINT_BLEND_ADD: blend = IMB_BLEND_ADD; break;
+ case PAINT_BLEND_SUB: blend = IMB_BLEND_SUB; break;
+ case PAINT_BLEND_MUL: blend = IMB_BLEND_MUL; break;
+ case PAINT_BLEND_LIGHTEN: blend = IMB_BLEND_LIGHTEN; break;
+ case PAINT_BLEND_DARKEN: blend = IMB_BLEND_DARKEN; break;
+ case PAINT_BLEND_COLORDODGE: blend = IMB_BLEND_COLORDODGE; break;
+ case PAINT_BLEND_DIFFERENCE: blend = IMB_BLEND_DIFFERENCE; break;
+ case PAINT_BLEND_SCREEN: blend = IMB_BLEND_SCREEN; break;
+ case PAINT_BLEND_HARDLIGHT: blend = IMB_BLEND_HARDLIGHT; break;
+ case PAINT_BLEND_OVERLAY: blend = IMB_BLEND_OVERLAY; break;
+ case PAINT_BLEND_SOFTLIGHT: blend = IMB_BLEND_SOFTLIGHT; break;
+ case PAINT_BLEND_EXCLUSION: blend = IMB_BLEND_EXCLUSION; break;
+ case PAINT_BLEND_LUMINOSITY: blend = IMB_BLEND_LUMINOSITY; break;
+ case PAINT_BLEND_SATURATION: blend = IMB_BLEND_SATURATION; break;
+ case PAINT_BLEND_HUE: blend = IMB_BLEND_HUE; break;
+ case PAINT_BLEND_ALPHA_SUB: blend = IMB_BLEND_ERASE_ALPHA; break;
+ case PAINT_BLEND_ALPHA_ADD: blend =
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list