[Bf-blender-cvs] [336082acba5] master: Curves: Curve Pen

Dilith Jayakody noreply at git.blender.org
Sun Apr 3 19:08:15 CEST 2022


Commit: 336082acba51b3a237338e2cc316b04320c05ad4
Author: Dilith Jayakody
Date:   Sun Apr 3 22:37:22 2022 +0530
Branches: master
https://developer.blender.org/rB336082acba51b3a237338e2cc316b04320c05ad4

Curves: Curve Pen

This tool can be used to rapidly edit curves. The current set of
functionalities for Bezier splines are as follows:

The functionalities are divided into three versions of the operator:
* Left-Click
* Ctrl + Left-Click
* Double Click

All current functionalities and their defaults are as follows:
* Extrude Point: Add a point connected to an existing point.
Enabled for Left-Click.
* Extrude Handle Type: Type of the handles of the extruded points.
Can be either Vector or Auto. Defaults to Vector.
* Delete Point: Delete existing point.
Enabled for Ctrl + Left-Click.
* Insert Point: Insert a point into a curve segment.
Enabled for Ctrl + Left-Click.
* Move Segment: Move curve segment.
Enabled for Left-Click.
* Select Point: Select a single point or handle at a time.
Enabled for Left-Click.
* Move point: Move existing points or handles.
Enabled for Left-Click.
* Close Spline: Close spline by clicking the endpoints consecutively.
Defaults to True.
* Close Spline Method: The condition for Close Spline to activate.
Can be one of None, On Press or On Click.
Defaults to On Click for Left-Click and None for the others.
  * None: Functionality is turned off.
  * On Press: Activate on mouse down.
  This makes it possible to move the handles by dragging immediately
  after closing the spline.
  * On Click: Activate on mouse release.
  This makes it possible to avoid triggering the Close Spline
  functionality by dragging afterward.
* Toggle Vector: Toggle handle between Vector and Auto handle types.
Enabled for Double Click on a handle.
* Cycle Handle Type: Cycle between all four handle types.
Enabled for Double Click on the middle point of a Bezier point.

The keybindings for the following functionalities can be adjusted from
the modal keymap
* Free-Align Toggle: Toggle between Free and Align handle types.
Defaults to Left Shift. Activated on hold.
* Move Adjacent Handle: Move the closer handle of the adjacent vertex.
Defaults to Left Ctrl. Activated on hold.
* Move Entire: Move the entire point by moving by grabbing on the handle
Defaults to Spacebar. Activated on hold.
* Link Handles: Mirror the movement of one handle onto the other.
Defaults to Right Ctrl. Activated on press.
* Lock Handle Angle: Move the handle along its current angle.
Defaults to Left Alt. Activated on hold.

All the above functionalities, except for Move Segment and
those that work with handles, work similarly in the case of Poly
and NURBS splines.

Reviewed By: HooglyBoogly, weasel, campbellbarton
Differential Revision: http://developer.blender.org/D12155

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

M	.clang-format
M	release/datafiles/icons/ops.curve.draw.dat
A	release/datafiles/icons/ops.curve.pen.dat
M	release/datafiles/locale
M	release/scripts/addons
M	release/scripts/modules/bl_keymap_utils/keymap_hierarchy.py
M	release/scripts/presets/keyconfig/keymap_data/blender_default.py
M	release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
M	source/blender/editors/curve/CMakeLists.txt
M	source/blender/editors/curve/curve_intern.h
M	source/blender/editors/curve/curve_ops.c
M	source/blender/editors/curve/editcurve.c
A	source/blender/editors/curve/editcurve_pen.c
M	source/blender/editors/curve/editcurve_query.c
M	source/blender/editors/datafiles/CMakeLists.txt
M	source/blender/editors/include/ED_curve.h
M	source/tools

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

diff --git a/.clang-format b/.clang-format
index 41f828787b2..44c8cb90b15 100644
--- a/.clang-format
+++ b/.clang-format
@@ -205,6 +205,7 @@ ForEachMacros:
   - FOREACH_SCENE_COLLECTION_BEGIN
   - FOREACH_SCENE_OBJECT_BEGIN
   - FOREACH_SELECTED_BASE_BEGIN
+  - FOREACH_SELECTED_BEZT_BEGIN
   - FOREACH_SELECTED_EDITABLE_OBJECT_BEGIN
   - FOREACH_SELECTED_OBJECT_BEGIN
   - FOREACH_TRANS_DATA_CONTAINER
diff --git a/release/datafiles/icons/ops.curve.draw.dat b/release/datafiles/icons/ops.curve.draw.dat
index cf2c8e31bcb..da4c7424756 100644
Binary files a/release/datafiles/icons/ops.curve.draw.dat and b/release/datafiles/icons/ops.curve.draw.dat differ
diff --git a/release/datafiles/icons/ops.curve.pen.dat b/release/datafiles/icons/ops.curve.pen.dat
new file mode 100644
index 00000000000..1007f7ea604
Binary files /dev/null and b/release/datafiles/icons/ops.curve.pen.dat differ
diff --git a/release/datafiles/locale b/release/datafiles/locale
index 2a5095eed30..716dc02ec30 160000
--- a/release/datafiles/locale
+++ b/release/datafiles/locale
@@ -1 +1 @@
-Subproject commit 2a5095eed3028e91624d27ca93e4c65f572b809d
+Subproject commit 716dc02ec30c0810513f7b4adc4ae865ae50c4e6
diff --git a/release/scripts/addons b/release/scripts/addons
index 67f1fbca148..787ea78f7fa 160000
--- a/release/scripts/addons
+++ b/release/scripts/addons
@@ -1 +1 @@
-Subproject commit 67f1fbca1482d9d9362a4001332e785c3fd5d230
+Subproject commit 787ea78f7fa6f0373d80ba1247768402df93f8ad
diff --git a/release/scripts/modules/bl_keymap_utils/keymap_hierarchy.py b/release/scripts/modules/bl_keymap_utils/keymap_hierarchy.py
index 938849d8e6e..6389efba049 100644
--- a/release/scripts/modules/bl_keymap_utils/keymap_hierarchy.py
+++ b/release/scripts/modules/bl_keymap_utils/keymap_hierarchy.py
@@ -100,6 +100,7 @@ _km_hierarchy = [
         ('Paint Stroke Modal', 'EMPTY', 'WINDOW', []),
         ('Sculpt Expand Modal', 'EMPTY', 'WINDOW', []),
         ('Paint Curve', 'EMPTY', 'WINDOW', []),
+        ('Curve Pen Modal Map', 'EMPTY', 'WINDOW', []),
 
         ('Object Non-modal', 'EMPTY', 'WINDOW', []),  # mode change
 
diff --git a/release/scripts/presets/keyconfig/keymap_data/blender_default.py b/release/scripts/presets/keyconfig/keymap_data/blender_default.py
index b626f6a237a..c9a378a101f 100644
--- a/release/scripts/presets/keyconfig/keymap_data/blender_default.py
+++ b/release/scripts/presets/keyconfig/keymap_data/blender_default.py
@@ -6158,6 +6158,25 @@ def km_sculpt_expand_modal(_params):
     return keymap
 
 
+def km_curve_pen_modal_map(_params):
+    items = []
+    keymap = (
+        "Curve Pen Modal Map",
+        {"space_type": 'EMPTY', "region_type": 'WINDOW', "modal": True},
+        {"items": items},
+    )
+
+    items.extend([
+        ("FREE_ALIGN_TOGGLE", {"type": 'LEFT_SHIFT', "value": 'ANY', "any": True}, None),
+        ("MOVE_ADJACENT", {"type": 'LEFT_CTRL', "value": 'ANY', "any": True}, None),
+        ("MOVE_ENTIRE", {"type": 'SPACE', "value": 'ANY', "any": True}, None),
+        ("LOCK_ANGLE", {"type": 'LEFT_ALT', "value": 'ANY', "any": True}, None),
+        ("LINK_HANDLES", {"type": 'RIGHT_CTRL', "value": 'PRESS', "any": True}, None),
+    ])
+
+    return keymap
+
+
 # Fallback for gizmos that don't have custom a custom key-map.
 def km_generic_gizmo(_params):
     keymap = (
@@ -7078,6 +7097,27 @@ def km_3d_view_tool_edit_curve_draw(params):
     )
 
 
+def km_3d_view_tool_edit_curve_pen(params):
+    return (
+        "3D View Tool: Edit Curve, Curve Pen",
+        {"space_type": 'VIEW_3D', "region_type": 'WINDOW'},
+        {"items": [
+            ("curve.pen", {"type": params.tool_mouse, "value": 'PRESS'},
+             {"properties": [
+                 ("extrude_point", True),
+                 ("move_segment", True),
+                 ("select_point", True),
+                 ("move_point", True),
+                 ("close_spline_method", "ON_CLICK"),
+                ]}),
+            ("curve.pen", {"type": params.tool_mouse, "value": 'PRESS', "ctrl": True},
+             {"properties": [("insert_point", True), ("delete_point", True)]}),
+            ("curve.pen", {"type": params.tool_mouse, "value": 'DOUBLE_CLICK'},
+             {"properties": [("toggle_vector", True), ("cycle_handle_type", True),]}),
+        ]},
+    )
+
+
 def km_3d_view_tool_edit_curve_tilt(params):
     return (
         "3D View Tool: Edit Curve, Tilt",
@@ -7882,6 +7922,7 @@ def generate_keymaps(params=None):
         km_view3d_dolly_modal(params),
         km_paint_stroke_modal(params),
         km_sculpt_expand_modal(params),
+        km_curve_pen_modal_map(params),
 
         # Gizmos.
         km_generic_gizmo(params),
@@ -7960,6 +8001,7 @@ def generate_keymaps(params=None):
         km_3d_view_tool_edit_mesh_rip_region(params),
         km_3d_view_tool_edit_mesh_rip_edge(params),
         km_3d_view_tool_edit_curve_draw(params),
+        km_3d_view_tool_edit_curve_pen(params),
         km_3d_view_tool_edit_curve_radius(params),
         km_3d_view_tool_edit_curve_tilt(params),
         km_3d_view_tool_edit_curve_randomize(params),
diff --git a/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py b/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
index aec3ec63a0c..fc621c5b51e 100644
--- a/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
+++ b/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
@@ -1201,6 +1201,22 @@ class _defs_edit_curve:
             keymap=(),
         )
 
+    @ToolDef.from_fn
+    def pen():
+        def draw_settings(_context, layout, tool):
+            props = tool.operator_properties("curve.pen")
+            layout.prop(props, "close_spline")
+            layout.prop(props, "extrude_handle")
+        return dict(
+            idname="builtin.pen",
+            label="Curve Pen",
+            cursor='CROSSHAIR',
+            icon="ops.curve.pen",
+            widget=None,
+            keymap=(),
+            draw_settings=draw_settings,
+        )
+
     @ToolDef.from_fn
     def tilt():
         return dict(
@@ -2881,6 +2897,7 @@ class VIEW3D_PT_tools_active(ToolSelectPanelHelper, Panel):
             *_tools_default,
             None,
             _defs_edit_curve.draw,
+            _defs_edit_curve.pen,
             (
                 _defs_edit_curve.extrude,
                 _defs_edit_curve.extrude_cursor,
diff --git a/source/blender/editors/curve/CMakeLists.txt b/source/blender/editors/curve/CMakeLists.txt
index 397725f770c..b21ae305dbe 100644
--- a/source/blender/editors/curve/CMakeLists.txt
+++ b/source/blender/editors/curve/CMakeLists.txt
@@ -25,6 +25,7 @@ set(SRC
   editcurve_paint.c
   editcurve_query.c
   editcurve_select.c
+  editcurve_pen.c
   editcurve_undo.c
   editfont.c
   editfont_undo.c
diff --git a/source/blender/editors/curve/curve_intern.h b/source/blender/editors/curve/curve_intern.h
index 8bfabe23ea1..09a0dbc541f 100644
--- a/source/blender/editors/curve/curve_intern.h
+++ b/source/blender/editors/curve/curve_intern.h
@@ -131,6 +131,16 @@ void CURVE_OT_match_texture_space(struct wmOperatorType *ot);
 struct GHash *ED_curve_keyindex_hash_duplicate(struct GHash *keyindex);
 void ED_curve_keyindex_update_nurb(struct EditNurb *editnurb, struct Nurb *nu, struct Nurb *newnu);
 
+/* exported for editcurve_pen.c */
+int ed_editcurve_addvert(Curve *cu, EditNurb *editnurb, View3D *v3d, const float location_init[3]);
+bool curve_toggle_cyclic(View3D *v3d, ListBase *editnurb, int direction);
+void ed_dissolve_bez_segment(BezTriple *bezt_prev,
+                             BezTriple *bezt_next,
+                             const Nurb *nu,
+                             const Curve *cu,
+                             const int span_len,
+                             const int span_step[2]);
+
 /* helper functions */
 void ed_editnurb_translate_flag(struct ListBase *editnurb,
                                 uint8_t flag,
@@ -189,8 +199,23 @@ bool ED_curve_pick_vert(struct ViewContext *vc,
                         struct BPoint **r_bp,
                         short *r_handle,
                         struct Base **r_base);
+/**
+ * \param sel_dist_mul: A multiplier on the default select distance.
+ */
+bool ED_curve_pick_vert_ex(struct ViewContext *vc,
+                           short sel,
+                           float dist_px,
+                           struct Nurb **r_nurb,
+                           struct BezTriple **r_bezt,
+                           struct BPoint **r_bp,
+                           short *r_handle,
+                           struct Base **r_base);
 void ED_curve_nurb_vert_selected_find(
     Curve *cu, View3D *v3d, Nurb **r_nu, BezTriple **r_bezt, BPoint **r_bp);
 
 /* editcurve_paint.c */
 void CURVE_OT_draw(struct wmOperatorType *ot);
+
+/* editcurve_pen.c */
+void CURVE_OT_pen(struct wmOperatorType *ot);
+struct wmKeyMap *curve_pen_modal_keymap(struct wmKeyConfig *keyconf);
diff --git a/source/blender/editors/curve/curve_ops.c b/source/blender/editors/curve/curve_ops.c
index 850b0cce955..2417947a25e 100644
--- a/source/blender/editors/curve/curve_ops.c
+++ b/source/blender/editors/curve/curve_ops.c
@@ -111,6 +111,7 @@ void ED_operatortypes_curve(void)
   WM_operatortype_append(CURVE_OT_spin);
   WM_operatortype_append(CURVE_OT_vertex_add);
   WM_operatortype_append(CURVE_OT_draw);
+  WM_operatortype_append(CURVE_OT_pen);
   WM_operatortype_append(CURVE_OT_extrude);
   WM_operatortype_append(CURVE_OT_cyclic_toggle);
 
@@ -150,4 +151,6 @@ void ED_keymap_curve(wmKeyConfig *keyconf)
   /* only set in editmode curve, by space_view3d listener */
   keymap = WM_keymap_ensure(keyconf, "Curve", 0, 0);
   keymap->poll = ED_operator_editsurfcurve;
+
+  curve_pen_modal_keymap(keyconf);
 }
diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c
index 38c14391273..c7c2468a6e4 100644
--- a/source/blender/editors/curve/editcurve.c
+++ b/source/blender/editors/curve/editcurve.c
@@ -4726,6 +4726,14 @@ void CURVE_OT_make_segment(wmOperatorType *ot)
 bool ED_curve_editnurb_select_pick(bContext *C,
                                    const int mval[2],
                                    const struct SelectPick_Params *params)
+{
+  return ED_curve_editnu

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list