[Bf-blender-cvs] [82bc438cfb3] sculpt-dev: Sculpt: fixed right click menus
Joseph Eagar
noreply at git.blender.org
Thu Sep 30 02:07:36 CEST 2021
Commit: 82bc438cfb393b9522c080c830013a6c973ff854
Author: Joseph Eagar
Date: Wed Sep 29 17:06:47 2021 -0700
Branches: sculpt-dev
https://developer.blender.org/rB82bc438cfb393b9522c080c830013a6c973ff854
Sculpt: fixed right click menus
They are now configurable in the
brush tab.
===================================================================
M release/scripts/startup/bl_ui/properties_paint_common.py
M release/scripts/startup/bl_ui/space_view3d.py
M source/blender/blenkernel/BKE_brush_engine.h
M source/blender/blenkernel/intern/brush_channel_define.h
M source/blender/blenkernel/intern/brush_engine.c
M source/blender/blenkernel/intern/brush_engine_presets.c
M source/blender/blenloader/intern/versioning_300.c
M source/blender/editors/sculpt_paint/sculpt.c
M source/blender/makesdna/DNA_sculpt_brush_types.h
M source/blender/makesrna/intern/rna_brush_engine.c
===================================================================
diff --git a/release/scripts/startup/bl_ui/properties_paint_common.py b/release/scripts/startup/bl_ui/properties_paint_common.py
index a9811941f38..1b8dceebdd5 100644
--- a/release/scripts/startup/bl_ui/properties_paint_common.py
+++ b/release/scripts/startup/bl_ui/properties_paint_common.py
@@ -126,16 +126,29 @@ class UnifiedPaintPanel:
return None
@staticmethod
- def get_channel(context, brush, prop_name, toolsettings_only=False):
- ch = brush.channels[prop_name]
+ def get_channel(context, brush, prop_name, toolsettings_only=False, need_path=False):
+ ch = brush.channels[prop_name] if prop_name in brush.channels else None
- if ch.inherit or toolsettings_only:
+ path = None
+
+ if ch:
+ path = "sculpt.brush.channels[\"%s\"]" % prop_name
+
+ if not ch or ch.inherit or toolsettings_only:
sd = context.tool_settings.sculpt
- #ensure channel exists in tool settings channel set
- sd.channels.ensure(ch)
- ch = sd.channels[prop_name]
- return ch
+ if ch:
+ #ensure channel exists in tool settings channel set
+ sd.channels.ensure(ch)
+
+ ch = sd.channels[prop_name] if prop_name in sd.channels else None
+ if ch:
+ path = "sculpt.channels[\"%s\"]" % prop_name
+
+ if need_path:
+ return (ch, path)
+ else:
+ return ch
@staticmethod
def get_channel_value(context, brush, prop_name, toolsettings_only=False):
@@ -163,11 +176,16 @@ class UnifiedPaintPanel:
return ch.curve
@staticmethod
- def channel_unified(layout, context, brush, prop_name, icon='NONE', pressure=True, text=None,
- slider=False, header=False, show_reorder=False, expand=None, toolsettings_only=False, ui_editing=True):
+ def channel_unified(layout, context, brush, prop_name, icon='NONE', pressure=None, text=None,
+ slider=False, header=False, show_reorder=False, expand=None, toolsettings_only=False, ui_editing=None):
""" Generalized way of adding brush options to the UI,
along with their pen pressure setting and global toggle"""
+
+ if ui_editing is None:
+ ui_editing = True
+ ui_editing = ui_editing and not header
+
if context.mode != "SCULPT":
return UnifiedPaintPanel.prop_unified(layout, context, brush, prop_name, icon=icon, text=text, slider=slider, header=header, expand=expand)
@@ -220,6 +238,9 @@ class UnifiedPaintPanel:
elif ch.type == "VEC4":
typeprop = "color4_value"
+ if pressure == None:
+ pressure = ch.type not in ["VEC3", "VEC4", "BITMASK", "ENUM", "BOOL"]
+
if text is None:
text = ch.name
@@ -262,6 +283,7 @@ class UnifiedPaintPanel:
if ui_editing and not header:
row.prop(ch, "show_in_workspace", text="", icon="HIDE_OFF")
+ row.prop(ch, "show_in_context_menu", text="", icon="MENU_PANEL")
#row.prop(ch, "ui_order", text="")
if ch.type == "CURVE":
@@ -319,6 +341,8 @@ class UnifiedPaintPanel:
if pressure:
row.prop(pressurech.mappings["PRESSURE"], "enabled", text="", icon="STYLUS_PRESSURE")
+ #if ch.is_color:
+ # UnifiedPaintPanel.prop_unified_color_picker(row, context, brush, prop_name)
#if pressure_name:
# row.prop(brush, pressure_name, text="")
@@ -441,6 +465,15 @@ class UnifiedPaintPanel:
def prop_unified_color_picker(parent, context, brush, prop_name, value_slider=True):
ups = context.tool_settings.unified_paint_settings
prop_owner = ups if ups.use_unified_color else brush
+
+ if context.mode == "SCULPT":
+ ch, path = UnifiedPaintPanel.get_channel(context, brush, prop_name, need_path=True)
+
+ if ch is not None:
+ print("FOUND CH", ch.idname)
+ prop_owner = ch
+ prop_name = "color3_value"
+
parent.template_color_picker(prop_owner, prop_name, value_slider=value_slider)
diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py
index e05b6478462..d1944f0132c 100644
--- a/release/scripts/startup/bl_ui/space_view3d.py
+++ b/release/scripts/startup/bl_ui/space_view3d.py
@@ -7454,6 +7454,49 @@ class VIEW3D_PT_sculpt_context_menu(Panel):
brush = context.tool_settings.sculpt.brush
capabilities = brush.sculpt_capabilities
+ channels = []
+ colorch = None
+ keys = {}
+
+ #maintain compatibility with old text overrides
+ textmap = {"plane_trim" : "Distance"}
+
+ for ch in brush.channels:
+ if ch.show_in_context_menu:
+ if ch.idname == "color":
+ colorch = ch
+ else:
+ key = ch.ui_order
+
+ if ch.idname == "blend":
+ key = -2
+ elif ch.idname == "secondary_color":
+ key = -1
+
+ keys[ch.idname] = key
+ channels.append(ch)
+
+ channels.sort(key=lambda ch: keys[ch.idname])
+
+ """
+ def channel_unified(layout, context, brush, prop_name, icon='NONE', pressure=None, text=None,
+ slider=False, header=False, show_reorder=False, expand=None, toolsettings_only=False, ui_editing=None):
+
+ """
+ if colorch:
+ split = layout.split(factor=0.1)
+ UnifiedPaintPanel.prop_unified_color(split, context, brush, "color", text="")
+ UnifiedPaintPanel.prop_unified_color_picker(split, context, brush, "color", value_slider=True)
+
+ for ch in channels:
+ if ch.idname in textmap:
+ UnifiedPaintPanel.channel_unified(layout, context, brush, ch.idname, ui_editing=False, slider=True, text=textmap[ch.idname])
+ else:
+ UnifiedPaintPanel.channel_unified(layout, context, brush, ch.idname, ui_editing=False, slider=True)
+
+ return
+ layout.label(text="-----")
+
if capabilities.has_color:
split = layout.split(factor=0.1)
UnifiedPaintPanel.prop_unified_color(split, context, brush, "color", text="")
@@ -7480,26 +7523,71 @@ class VIEW3D_PT_sculpt_context_menu(Panel):
)
if capabilities.has_auto_smooth:
- layout.prop(brush, "auto_smooth_factor", slider=True)
+ UnifiedPaintPanel.prop_unified(
+ layout,
+ context,
+ brush,
+ "auto_smooth_factor",
+ slider=True,
+ )
if capabilities.has_normal_weight:
- layout.prop(brush, "normal_weight", slider=True)
+ UnifiedPaintPanel.prop_unified(
+ layout,
+ context,
+ brush,
+ "normal_weight",
+ slider=True,
+ )
if capabilities.has_pinch_factor:
text = "Pinch"
if brush.sculpt_tool in {'BLOB', 'SNAKE_HOOK'}:
text = "Magnify"
- layout.prop(brush, "crease_pinch_factor", slider=True, text=text)
+ UnifiedPaintPanel.prop_unified(
+ layout,
+ context,
+ brush,
+ "crease_pinch_factor",
+ text=text,
+ slider=True,
+ )
if capabilities.has_rake_factor:
- layout.prop(brush, "rake_factor", slider=True)
+ UnifiedPaintPanel.prop_unified(
+ layout,
+ context,
+ brush,
+ "rake_factor",
+ slider=True,
+ )
if capabilities.has_plane_offset:
- layout.prop(brush, "plane_offset", slider=True)
- layout.prop(brush, "plane_trim", slider=True, text="Distance")
+ UnifiedPaintPanel.prop_unified(
+ layout,
+ context,
+ brush,
+ "plane_offset",
+ slider=True,
+ )
+ UnifiedPaintPanel.prop_unified(
+ layout,
+ context,
+ brush,
+ "plane_trim",
+ slider=True,
+ text="Distance"
+ )
if capabilities.has_height:
- layout.prop(brush, "height", slider=True, text="Height")
+ UnifiedPaintPanel.prop_unified(
+ layout,
+ context,
+ brush,
+ "height",
+ slider=True,
+ text="Height"
+ )
class TOPBAR_PT_gpencil_materials(GreasePencilMaterialsPanel, Panel):
diff --git a/source/blender/blenkernel/BKE_brush_engine.h b/source/blender/blenkernel/BKE_brush_engine.h
index d0e833673f1..15036014193 100644
--- a/source/blender/blenkernel/BKE_brush_engine.h
+++ b/source/blender/blenkernel/BKE_brush_engine.h
@@ -124,7 +124,7 @@ typedef struct BrushEnumDef {
} BrushEnumDef;
typedef struct BrushChannelType {
- char name[128], idname[64], tooltip[512];
+ char name[128], idname[64], tooltip[512], category[128];
float min, max, soft_min, soft_max;
BrushMappingPreset mappings;
@@ -342,6 +342,9 @@ void BKE_brush_check_toolsettings(struct Sculpt *sd);
void BKE_brush_channelset_ui_init(struct Brush *brush, int tool);
void BKE_brush_channelset_check_radius(BrushChannelSet *chset);
+const char *BKE_brush_channel_category_get(BrushChannel *ch);
+const char *BKE_brush_channel_category_set(BrushChannel *ch, const char *str);
+
/*
set up static type checker for BRUSHSET_XXX macros
*/
diff --git a/source/blender/blenkernel/intern/brush_channel_define.h b/source/blender/blenkernel/intern/brush_channel_define.h
index 232d77586f0..88cc5caa132 100644
--- a/source/blender/blenkernel/intern/brush_channel_define.h
+++ b/source/blender/blenkernel/intern/brush_channel_define.h
@@ -115,6 +115,85 @@ places in rna_engine_codebase are relevent:
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list