[Bf-blender-cvs] [61aaeb3745a] master: Curves: initial brush system integration for curves sculpt mode

Jacques Lucke noreply at git.blender.org
Fri Feb 18 09:45:47 CET 2022


Commit: 61aaeb3745ad72c681c17f4535dd06ffaaf78c58
Author: Jacques Lucke
Date:   Fri Feb 18 09:12:41 2022 +0100
Branches: master
https://developer.blender.org/rB61aaeb3745ad72c681c17f4535dd06ffaaf78c58

Curves: initial brush system integration for curves sculpt mode

This adds the boilerplate code that is necessary to use the tool/brush/paint
systems in the new sculpt curves mode.

Two temporary dummy tools are part of this patch. They do nothing and
only serve to test the boilerplate. When the first actual tool is added,
those dummy tools will be removed.

Differential Revision: https://developer.blender.org/D14117

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

M	release/scripts/modules/bl_keymap_utils/keymap_from_toolbar.py
M	release/scripts/presets/keyconfig/keymap_data/blender_default.py
M	release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
M	source/blender/blenkernel/BKE_paint.h
M	source/blender/blenkernel/intern/paint.c
M	source/blender/blenkernel/intern/paint_toolslots.c
M	source/blender/blenkernel/intern/scene.c
M	source/blender/draw/engines/overlay/overlay_engine.c
M	source/blender/editors/curves/CMakeLists.txt
M	source/blender/editors/curves/intern/curves_ops.cc
A	source/blender/editors/include/ED_curves_sculpt.h
M	source/blender/editors/sculpt_paint/CMakeLists.txt
A	source/blender/editors/sculpt_paint/curves_sculpt_intern.h
A	source/blender/editors/sculpt_paint/curves_sculpt_ops.cc
M	source/blender/editors/sculpt_paint/paint_ops.c
M	source/blender/editors/space_api/spacetypes.c
M	source/blender/editors/space_view3d/space_view3d.c
M	source/blender/editors/util/CMakeLists.txt
M	source/blender/makesdna/DNA_brush_enums.h
M	source/blender/makesdna/DNA_brush_types.h
M	source/blender/makesdna/DNA_scene_types.h
M	source/blender/makesrna/RNA_enum_items.h
M	source/blender/makesrna/intern/rna_brush.c
M	source/blender/makesrna/intern/rna_sculpt_paint.c
M	source/blender/windowmanager/intern/wm_keymap_utils.c
M	source/blender/windowmanager/intern/wm_toolsystem.c

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

diff --git a/release/scripts/modules/bl_keymap_utils/keymap_from_toolbar.py b/release/scripts/modules/bl_keymap_utils/keymap_from_toolbar.py
index 604d1ffd547..6d41e290512 100644
--- a/release/scripts/modules/bl_keymap_utils/keymap_from_toolbar.py
+++ b/release/scripts/modules/bl_keymap_utils/keymap_from_toolbar.py
@@ -189,6 +189,7 @@ def generate(context, space_type, *, use_fallback_keys=True, use_reset=True):
                             'VERTEX_GPENCIL': "gpencil_vertex_tool",
                             'SCULPT_GPENCIL': "gpencil_sculpt_tool",
                             'WEIGHT_GPENCIL': "gpencil_weight_tool",
+                            'SCULPT_CURVES': "curves_sculpt_tool",
                         }.get(mode, None)
                     else:
                         attr = None
diff --git a/release/scripts/presets/keyconfig/keymap_data/blender_default.py b/release/scripts/presets/keyconfig/keymap_data/blender_default.py
index 8884b835130..7373615d5ff 100644
--- a/release/scripts/presets/keyconfig/keymap_data/blender_default.py
+++ b/release/scripts/presets/keyconfig/keymap_data/blender_default.py
@@ -5450,6 +5450,21 @@ def km_font(params):
     return keymap
 
 
+def km_sculpt_curves(params):
+    items = []
+    keymap = (
+        "Sculpt Curves",
+        {"space_type": 'EMPTY', "region_type": 'WINDOW'},
+        {"items": items},
+    )
+
+    items.extend([
+        ("sculpt_curves.brush_stroke", {"type": 'LEFTMOUSE', "value": 'PRESS'}, None),
+    ])
+
+    return keymap
+
+
 def km_object_non_modal(params):
     items = []
     keymap = (
@@ -7771,6 +7786,7 @@ def generate_keymaps(params=None):
         km_lattice(params),
         km_particle(params),
         km_font(params),
+        km_sculpt_curves(params),
         km_object_non_modal(params),
 
         # Modal maps.
diff --git a/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py b/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
index 338bf5a9d5d..f4aa4c50d76 100644
--- a/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
+++ b/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
@@ -2306,6 +2306,19 @@ class _defs_gpencil_weight:
         )
 
 
+class _defs_curves_sculpt:
+
+    @staticmethod
+    def generate_from_brushes(context):
+        return generate_from_enum_ex(
+            context,
+            idname_prefix="builtin_brush.",
+            icon_prefix="ops.curves.sculpt_",
+            type= bpy.types.Brush,
+            attr="curves_sculpt_tool",
+        )
+
+
 class _defs_gpencil_vertex:
 
     @staticmethod
@@ -3065,6 +3078,9 @@ class VIEW3D_PT_tools_active(ToolSelectPanelHelper, Panel):
                 else ()
             ),
         ],
+        'SCULPT_CURVES': [
+            _defs_curves_sculpt.generate_from_brushes,
+        ],
     }
 
 
diff --git a/source/blender/blenkernel/BKE_paint.h b/source/blender/blenkernel/BKE_paint.h
index 1f37e95a023..8ab89b6c244 100644
--- a/source/blender/blenkernel/BKE_paint.h
+++ b/source/blender/blenkernel/BKE_paint.h
@@ -74,9 +74,11 @@ typedef enum ePaintMode {
   PAINT_MODE_VERTEX_GPENCIL = 7,
   PAINT_MODE_SCULPT_GPENCIL = 8,
   PAINT_MODE_WEIGHT_GPENCIL = 9,
+  /** Curves. */
+  PAINT_MODE_SCULPT_CURVES = 10,
 
   /** Keep last. */
-  PAINT_MODE_INVALID = 10,
+  PAINT_MODE_INVALID = 11,
 } ePaintMode;
 
 #define PAINT_MODE_HAS_BRUSH(mode) !ELEM(mode, PAINT_MODE_SCULPT_UV)
diff --git a/source/blender/blenkernel/intern/paint.c b/source/blender/blenkernel/intern/paint.c
index ffd0a03fc51..d42c8ea37d5 100644
--- a/source/blender/blenkernel/intern/paint.c
+++ b/source/blender/blenkernel/intern/paint.c
@@ -327,6 +327,9 @@ bool BKE_paint_ensure_from_paintmode(Scene *sce, ePaintMode mode)
     case PAINT_MODE_WEIGHT_GPENCIL:
       paint_ptr = (Paint **)&ts->gp_weightpaint;
       break;
+    case PAINT_MODE_SCULPT_CURVES:
+      paint_ptr = (Paint **)&ts->curves_sculpt;
+      break;
     case PAINT_MODE_INVALID:
       break;
   }
@@ -362,6 +365,8 @@ Paint *BKE_paint_get_active_from_paintmode(Scene *sce, ePaintMode mode)
         return &ts->gp_sculptpaint->paint;
       case PAINT_MODE_WEIGHT_GPENCIL:
         return &ts->gp_weightpaint->paint;
+      case PAINT_MODE_SCULPT_CURVES:
+        return &ts->curves_sculpt->paint;
       case PAINT_MODE_INVALID:
         return NULL;
       default:
@@ -394,6 +399,8 @@ const EnumPropertyItem *BKE_paint_get_tool_enum_from_paintmode(ePaintMode mode)
       return rna_enum_brush_gpencil_sculpt_types_items;
     case PAINT_MODE_WEIGHT_GPENCIL:
       return rna_enum_brush_gpencil_weight_types_items;
+    case PAINT_MODE_SCULPT_CURVES:
+      return rna_enum_brush_curves_sculpt_tool_items;
     case PAINT_MODE_INVALID:
       break;
   }
@@ -422,6 +429,8 @@ const char *BKE_paint_get_tool_prop_id_from_paintmode(ePaintMode mode)
       return "gpencil_sculpt_tool";
     case PAINT_MODE_WEIGHT_GPENCIL:
       return "gpencil_weight_tool";
+    case PAINT_MODE_SCULPT_CURVES:
+      return "curves_sculpt_tool";
     case PAINT_MODE_INVALID:
       break;
   }
@@ -453,6 +462,8 @@ Paint *BKE_paint_get_active(Scene *sce, ViewLayer *view_layer)
           return &ts->gp_sculptpaint->paint;
         case OB_MODE_WEIGHT_GPENCIL:
           return &ts->gp_weightpaint->paint;
+        case OB_MODE_SCULPT_CURVES:
+          return &ts->curves_sculpt->paint;
         case OB_MODE_EDIT:
           return ts->uvsculpt ? &ts->uvsculpt->paint : NULL;
         default:
@@ -573,6 +584,8 @@ ePaintMode BKE_paintmode_get_from_tool(const struct bToolRef *tref)
         return PAINT_MODE_SCULPT_GPENCIL;
       case CTX_MODE_WEIGHT_GPENCIL:
         return PAINT_MODE_WEIGHT_GPENCIL;
+      case CTX_MODE_SCULPT_CURVES:
+        return PAINT_MODE_SCULPT_CURVES;
     }
   }
   else if (tref->space_type == SPACE_IMAGE) {
@@ -641,6 +654,10 @@ void BKE_paint_runtime_init(const ToolSettings *ts, Paint *paint)
     paint->runtime.tool_offset = offsetof(Brush, gpencil_weight_tool);
     paint->runtime.ob_mode = OB_MODE_WEIGHT_GPENCIL;
   }
+  else if (ts->curves_sculpt && paint == &ts->curves_sculpt->paint) {
+    paint->runtime.tool_offset = offsetof(Brush, curves_sculpt_tool);
+    paint->runtime.ob_mode = OB_MODE_SCULPT_CURVES;
+  }
   else {
     BLI_assert_unreachable();
   }
@@ -668,6 +685,8 @@ uint BKE_paint_get_brush_tool_offset_from_paintmode(const ePaintMode mode)
       return offsetof(Brush, gpencil_sculpt_tool);
     case PAINT_MODE_WEIGHT_GPENCIL:
       return offsetof(Brush, gpencil_weight_tool);
+    case PAINT_MODE_SCULPT_CURVES:
+      return offsetof(Brush, curves_sculpt_tool);
     case PAINT_MODE_INVALID:
       break; /* We don't use these yet. */
   }
@@ -1028,6 +1047,7 @@ bool BKE_paint_ensure(ToolSettings *ts, struct Paint **r_paint)
                       (Paint *)ts->vpaint,
                       (Paint *)ts->wpaint,
                       (Paint *)ts->uvsculpt,
+                      (Paint *)ts->curves_sculpt,
                       (Paint *)&ts->imapaint));
 #ifdef DEBUG
       struct Paint paint_test = **r_paint;
@@ -1075,6 +1095,10 @@ bool BKE_paint_ensure(ToolSettings *ts, struct Paint **r_paint)
     UvSculpt *data = MEM_callocN(sizeof(*data), __func__);
     paint = &data->paint;
   }
+  else if ((CurvesSculpt **)r_paint == &ts->curves_sculpt) {
+    CurvesSculpt *data = MEM_callocN(sizeof(*data), __func__);
+    paint = &data->paint;
+  }
   else if (*r_paint == &ts->imapaint.paint) {
     paint = &ts->imapaint.paint;
   }
diff --git a/source/blender/blenkernel/intern/paint_toolslots.c b/source/blender/blenkernel/intern/paint_toolslots.c
index 04b70aae199..f35755021d2 100644
--- a/source/blender/blenkernel/intern/paint_toolslots.c
+++ b/source/blender/blenkernel/intern/paint_toolslots.c
@@ -98,6 +98,9 @@ void BKE_paint_toolslots_init_from_main(struct Main *bmain)
     if (ts->gp_weightpaint) {
       paint_toolslots_init_with_runtime(bmain, ts, &ts->gp_weightpaint->paint);
     }
+    if (ts->curves_sculpt) {
+      paint_toolslots_init_with_runtime(bmain, ts, &ts->curves_sculpt->paint);
+    }
   }
 }
 
diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c
index 7827c40e2c2..2eb4497aa0e 100644
--- a/source/blender/blenkernel/intern/scene.c
+++ b/source/blender/blenkernel/intern/scene.c
@@ -718,6 +718,16 @@ static void scene_foreach_toolsettings(LibraryForeachIDData *data,
                             reader,
                             &toolsett_old->gp_weightpaint->paint));
   }
+  if (toolsett->curves_sculpt) {
+    BKE_LIB_FOREACHID_UNDO_PRESERVE_PROCESS_FUNCTION_CALL(
+        data,
+        do_undo_restore,
+        scene_foreach_paint(data,
+                            &toolsett->curves_sculpt->paint,
+                            do_undo_restore,
+                            reader,
+                            &toolsett_old->curves_sculpt->paint));
+  }
 
   BKE_LIB_FOREACHID_UNDO_PRESERVE_PROCESS_IDSUPER(data,
                                                   toolsett->gp_sculpt.guide.reference_object,
@@ -972,6 +982,10 @@ static void scene_blend_write(BlendWriter *writer, ID *id, const void *id_addres
     BLO_write_struct(writer, GpWeightPaint, tos->gp_weightpaint);
     BKE_paint_blend_write(writer, &tos->gp_weightpaint->paint);
   }
+  if (tos->curves_sculpt) {
+    BLO_write_struct(writer, CurvesSculpt, tos->curves_sculpt);
+    BKE_paint_blend_write(writer, &tos->curves_sculpt->paint);
+  }
   /* write grease-pencil custom ipo curve to file */
   if (tos->gp_interpolate.custom_ipo) {
     BKE_curvemapping_blend_write(writer, tos->gp_interpolate.custom_ipo);
@@ -1148,6 +1162,7 @@ static void scene_blend_read_data(BlendDataReader *reader, ID *id)
     direct_link_paint_helper(reader, sce, (Paint **)&sce->toolsettings->gp_vertexpaint);
     direct_link_paint_helper(reader, sce, (Paint **)&sce->toolsettings->gp_sculptpaint);
     direct_link_paint_helper(reader, sce, (Paint **)&sce->toolsettings->gp_weightpaint);
+    direct_link_paint_helper(reader, sce, (Paint **)&sce->toolsettings->curves_sculpt);
 
     BKE_paint_blend_read_data(reader, sce, &sce->toolsettings->imapaint.paint);
 
@@ -1406,6 +1421,9 @@ static void scene_blend_read_lib(BlendLibReader *reader, ID *id)
   if (sce->toolsettings-

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list