[Bf-blender-cvs] [e2ffe889839] master: Curves: use paint cursor in curves sculpt mode

Jacques Lucke noreply at git.blender.org
Mon Feb 21 12:50:11 CET 2022


Commit: e2ffe88983938651a641e3d1be65f43c65a54901
Author: Jacques Lucke
Date:   Mon Feb 21 12:49:36 2022 +0100
Branches: master
https://developer.blender.org/rBe2ffe88983938651a641e3d1be65f43c65a54901

Curves: use paint cursor in curves sculpt mode

Also adds radius and strength control to the tool settings in the ui.

===================================================================

M	release/scripts/presets/keyconfig/keymap_data/blender_default.py
M	release/scripts/startup/bl_ui/properties_paint_common.py
M	release/scripts/startup/bl_ui/space_view3d.py
M	source/blender/editors/sculpt_paint/curves_sculpt_intern.h
M	source/blender/editors/sculpt_paint/curves_sculpt_ops.cc
M	source/blender/makesrna/intern/rna_scene.c
M	source/blender/makesrna/intern/rna_sculpt_paint.c

===================================================================

diff --git a/release/scripts/presets/keyconfig/keymap_data/blender_default.py b/release/scripts/presets/keyconfig/keymap_data/blender_default.py
index 62afe16d106..a9de17af496 100644
--- a/release/scripts/presets/keyconfig/keymap_data/blender_default.py
+++ b/release/scripts/presets/keyconfig/keymap_data/blender_default.py
@@ -5467,6 +5467,7 @@ def km_sculpt_curves(params):
 
     items.extend([
         ("sculpt_curves.brush_stroke", {"type": 'LEFTMOUSE', "value": 'PRESS'}, None),
+        *_template_paint_radial_control("curves_sculpt"),
     ])
 
     return keymap
diff --git a/release/scripts/startup/bl_ui/properties_paint_common.py b/release/scripts/startup/bl_ui/properties_paint_common.py
index ca623797c49..9e40a8d364a 100644
--- a/release/scripts/startup/bl_ui/properties_paint_common.py
+++ b/release/scripts/startup/bl_ui/properties_paint_common.py
@@ -79,6 +79,8 @@ class UnifiedPaintPanel:
             return tool_settings.gpencil_weight_paint
         elif mode == 'VERTEX_GPENCIL':
             return tool_settings.gpencil_vertex_paint
+        elif mode == 'SCULPT_CURVES':
+            return tool_settings.curves_sculpt
         return None
 
     @staticmethod
diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py
index 4174ec95e83..2ac6358bd9c 100644
--- a/release/scripts/startup/bl_ui/space_view3d.py
+++ b/release/scripts/startup/bl_ui/space_view3d.py
@@ -468,6 +468,38 @@ class _draw_tool_settings_context_mode:
 
         return True
 
+    @staticmethod
+    def SCULPT_CURVES(context, layout, tool):
+        if (tool is None) or (not tool.has_datablock):
+            return False
+
+        paint = context.tool_settings.curves_sculpt
+        layout.template_ID_preview(paint, "brush", rows=3, cols=8, hide_buttons=True)
+
+        brush = paint.brush
+        if brush is None:
+            return False
+
+        UnifiedPaintPanel.prop_unified(
+            layout,
+            context,
+            brush,
+            "size",
+            unified_name="use_unified_size",
+            text="Radius",
+            slider=True,
+            header=True
+        )
+
+        UnifiedPaintPanel.prop_unified(
+            layout,
+            context,
+            brush,
+            "strength",
+            unified_name="use_unified_strength",
+            header=True
+        )
+
 
 class VIEW3D_HT_header(Header):
     bl_space_type = 'VIEW_3D'
diff --git a/source/blender/editors/sculpt_paint/curves_sculpt_intern.h b/source/blender/editors/sculpt_paint/curves_sculpt_intern.h
index 6a96a8e0e9f..0d99e61192f 100644
--- a/source/blender/editors/sculpt_paint/curves_sculpt_intern.h
+++ b/source/blender/editors/sculpt_paint/curves_sculpt_intern.h
@@ -9,6 +9,7 @@ extern "C" {
 #endif
 
 bool CURVES_SCULPT_mode_poll(struct bContext *C);
+bool CURVES_SCULPT_mode_poll_view3d(struct bContext *C);
 
 #ifdef __cplusplus
 }
diff --git a/source/blender/editors/sculpt_paint/curves_sculpt_ops.cc b/source/blender/editors/sculpt_paint/curves_sculpt_ops.cc
index 3f732f6ac79..fb5b1d338a6 100644
--- a/source/blender/editors/sculpt_paint/curves_sculpt_ops.cc
+++ b/source/blender/editors/sculpt_paint/curves_sculpt_ops.cc
@@ -14,12 +14,23 @@
 #include "curves_sculpt_intern.h"
 #include "paint_intern.h"
 
-bool CURVES_SCULPT_mode_poll(struct bContext *C)
+bool CURVES_SCULPT_mode_poll(bContext *C)
 {
   Object *ob = CTX_data_active_object(C);
   return ob && ob->mode & OB_MODE_SCULPT_CURVES;
 }
 
+bool CURVES_SCULPT_mode_poll_view3d(bContext *C)
+{
+  if (!CURVES_SCULPT_mode_poll(C)) {
+    return false;
+  }
+  if (CTX_wm_region_view3d(C) == nullptr) {
+    return false;
+  }
+  return true;
+}
+
 namespace blender::ed::sculpt_paint {
 
 /* --------------------------------------------------------------------
@@ -108,9 +119,26 @@ static bool curves_sculptmode_toggle_poll(bContext *C)
   return true;
 }
 
-static int curves_sculptmode_toggle_exec(bContext *C, wmOperator *op)
+static void curves_sculptmode_enter(bContext *C)
 {
   Scene *scene = CTX_data_scene(C);
+  Object *ob = CTX_data_active_object(C);
+  BKE_paint_ensure(scene->toolsettings, (Paint **)&scene->toolsettings->curves_sculpt);
+  CurvesSculpt *curves_sculpt = scene->toolsettings->curves_sculpt;
+
+  ob->mode = OB_MODE_SCULPT_CURVES;
+
+  paint_cursor_start(&curves_sculpt->paint, CURVES_SCULPT_mode_poll_view3d);
+}
+
+static void curves_sculptmode_exit(bContext *C)
+{
+  Object *ob = CTX_data_active_object(C);
+  ob->mode = OB_MODE_OBJECT;
+}
+
+static int curves_sculptmode_toggle_exec(bContext *C, wmOperator *op)
+{
   Object *ob = CTX_data_active_object(C);
   const bool is_mode_set = ob->mode == OB_MODE_SCULPT_CURVES;
 
@@ -121,11 +149,10 @@ static int curves_sculptmode_toggle_exec(bContext *C, wmOperator *op)
   }
 
   if (is_mode_set) {
-    ob->mode = OB_MODE_OBJECT;
+    curves_sculptmode_exit(C);
   }
   else {
-    BKE_paint_ensure(scene->toolsettings, (Paint **)&scene->toolsettings->curves_sculpt);
-    ob->mode = OB_MODE_SCULPT_CURVES;
+    curves_sculptmode_enter(C);
   }
 
   WM_toolsystem_update_from_context_view3d(C);
diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c
index 14c91bf7cd1..29b06060256 100644
--- a/source/blender/makesrna/intern/rna_scene.c
+++ b/source/blender/makesrna/intern/rna_scene.c
@@ -2898,6 +2898,10 @@ static void rna_def_tool_settings(BlenderRNA *brna)
   RNA_def_property_struct_type(prop, "Sculpt");
   RNA_def_property_ui_text(prop, "Sculpt", "");
 
+  prop = RNA_def_property(srna, "curves_sculpt", PROP_POINTER, PROP_NONE);
+  RNA_def_property_struct_type(prop, "CurvesSculpt");
+  RNA_def_property_ui_text(prop, "Curves Sculpt", "");
+
   prop = RNA_def_property(srna, "use_auto_normalize", PROP_BOOLEAN, PROP_NONE);
   RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
   RNA_def_property_boolean_sdna(prop, NULL, "auto_normalize", 1);
diff --git a/source/blender/makesrna/intern/rna_sculpt_paint.c b/source/blender/makesrna/intern/rna_sculpt_paint.c
index cb105c22987..473711fb74b 100644
--- a/source/blender/makesrna/intern/rna_sculpt_paint.c
+++ b/source/blender/makesrna/intern/rna_sculpt_paint.c
@@ -423,6 +423,11 @@ static char *rna_UvSculpt_path(PointerRNA *UNUSED(ptr))
   return BLI_strdup("tool_settings.uv_sculpt");
 }
 
+static char *rna_CurvesSculpt_path(PointerRNA *UNUSED(ptr))
+{
+  return BLI_strdup("tool_settings.curves_sculpt");
+}
+
 static char *rna_GpPaint_path(PointerRNA *UNUSED(ptr))
 {
   return BLI_strdup("tool_settings.gpencil_paint");
@@ -1498,6 +1503,15 @@ static void rna_def_gpencil_sculpt(BlenderRNA *brna)
   RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
 }
 
+static void rna_def_curves_sculpt(BlenderRNA *brna)
+{
+  StructRNA *srna;
+
+  srna = RNA_def_struct(brna, "CurvesSculpt", "Paint");
+  RNA_def_struct_path_func(srna, "rna_CurvesSculpt_path");
+  RNA_def_struct_ui_text(srna, "Curves Sculpt Paint", "");
+}
+
 void RNA_def_sculpt_paint(BlenderRNA *brna)
 {
   /* *** Non-Animated *** */
@@ -1516,6 +1530,7 @@ void RNA_def_sculpt_paint(BlenderRNA *brna)
   rna_def_particle_edit(brna);
   rna_def_gpencil_guides(brna);
   rna_def_gpencil_sculpt(brna);
+  rna_def_curves_sculpt(brna);
   RNA_define_animate_sdna(true);
 }



More information about the Bf-blender-cvs mailing list