Commit: 6e77afe6ec7b6a73f218f1fef264758abcbc778a Author: Cian Jinks Date: Wed Sep 22 21:23:44 2021 -0400 Branches: master https://developer.blender.org/rB6e77afe6ec7b6a73f218f1fef264758abcbc778a
Applying patch D12600, GSOC Knife Tools branch This adds constrained angle mode improvements, snapping to global and local orientation, visible distance and angle measurements, undo capability, x-ray mode, multi-object edit mode. See https://developer.blender.org/D12600 for more details. Note: this project moved some of the default keymappings around a bit, as discussed with users in the thread https://devtalk.blender.org/t/gsoc-2021-knife-tool-improvements-feedback/19047 We'll change the manual documentation in the next couple of days. =================================================================== M release/scripts/presets/keyconfig/keymap_data/blender_default.py M release/scripts/presets/keyconfig/keymap_data/industry_compatible_data.py M release/scripts/startup/bl_ui/space_toolsystem_toolbar.py M source/blender/editors/mesh/CMakeLists.txt M source/blender/editors/mesh/editmesh_knife.c M source/blender/editors/mesh/editmesh_knife_project.c M source/blender/editors/mesh/mesh_intern.h =================================================================== diff --git a/release/scripts/presets/keyconfig/keymap_data/blender_default.py b/release/scripts/presets/keyconfig/keymap_data/blender_default.py index 1b0da23aa4a..5ecbe7715e3 100644 --- a/release/scripts/presets/keyconfig/keymap_data/blender_default.py +++ b/release/scripts/presets/keyconfig/keymap_data/blender_default.py @@ -5626,21 +5626,24 @@ def km_knife_tool_modal_map(_params): ("PANNING", {"type": 'MIDDLEMOUSE', "value": 'ANY', "any": True}, None), ("ADD_CUT_CLOSED", {"type": 'LEFTMOUSE', "value": 'DOUBLE_CLICK', "any": True}, None), ("ADD_CUT", {"type": 'LEFTMOUSE', "value": 'ANY', "any": True}, None), - ("CANCEL", {"type": 'RIGHTMOUSE', "value": 'PRESS', "any": True}, None), + ("UNDO", {"type": 'Z', "value": 'PRESS', "ctrl": True}, None), ("CONFIRM", {"type": 'RET', "value": 'PRESS', "any": True}, None), ("CONFIRM", {"type": 'NUMPAD_ENTER', "value": 'PRESS', "any": True}, None), ("CONFIRM", {"type": 'SPACE', "value": 'PRESS', "any": True}, None), - ("NEW_CUT", {"type": 'E', "value": 'PRESS'}, None), - ("SNAP_MIDPOINTS_ON", {"type": 'LEFT_CTRL', "value": 'PRESS', "any": True}, None), - ("SNAP_MIDPOINTS_OFF", {"type": 'LEFT_CTRL', "value": 'RELEASE', "any": True}, None), - ("SNAP_MIDPOINTS_ON", {"type": 'RIGHT_CTRL', "value": 'PRESS', "any": True}, None), - ("SNAP_MIDPOINTS_OFF", {"type": 'RIGHT_CTRL', "value": 'RELEASE', "any": True}, None), - ("IGNORE_SNAP_ON", {"type": 'LEFT_SHIFT', "value": 'PRESS', "any": True}, None), - ("IGNORE_SNAP_OFF", {"type": 'LEFT_SHIFT', "value": 'RELEASE', "any": True}, None), - ("IGNORE_SNAP_ON", {"type": 'RIGHT_SHIFT', "value": 'PRESS', "any": True}, None), - ("IGNORE_SNAP_OFF", {"type": 'RIGHT_SHIFT', "value": 'RELEASE', "any": True}, None), - ("ANGLE_SNAP_TOGGLE", {"type": 'C', "value": 'PRESS'}, None), - ("CUT_THROUGH_TOGGLE", {"type": 'Z', "value": 'PRESS'}, None), + ("NEW_CUT", {"type": 'RIGHTMOUSE', "value": 'PRESS'}, None), + ("SNAP_MIDPOINTS_ON", {"type": 'LEFT_SHIFT', "value": 'PRESS', "any": True}, None), + ("SNAP_MIDPOINTS_OFF", {"type": 'LEFT_SHIFT', "value": 'RELEASE', "any": True}, None), + ("SNAP_MIDPOINTS_ON", {"type": 'RIGHT_SHIFT', "value": 'PRESS', "any": True}, None), + ("SNAP_MIDPOINTS_OFF", {"type": 'RIGHT_SHIFT', "value": 'RELEASE', "any": True}, None), + ("IGNORE_SNAP_ON", {"type": 'LEFT_CTRL', "value": 'PRESS', "any": True}, None), + ("IGNORE_SNAP_OFF", {"type": 'LEFT_CTRL', "value": 'RELEASE', "any": True}, None), + ("IGNORE_SNAP_ON", {"type": 'RIGHT_CTRL', "value": 'PRESS', "any": True}, None), + ("IGNORE_SNAP_OFF", {"type": 'RIGHT_CTRL', "value": 'RELEASE', "any": True}, None), + ("ANGLE_SNAP_TOGGLE", {"type": 'A', "value": 'PRESS'}, None), + ("CYCLE_ANGLE_SNAP_EDGE", {"type": 'R', "value": 'PRESS'}, None), + ("CUT_THROUGH_TOGGLE", {"type": 'C', "value": 'PRESS'}, None), + ("SHOW_DISTANCE_ANGLE_TOGGLE", {"type": 'S', "value": 'PRESS'}, None), + ("DEPTH_TEST_TOGGLE", {"type": 'V', "value": 'PRESS'}, None), ]) return keymap diff --git a/release/scripts/presets/keyconfig/keymap_data/industry_compatible_data.py b/release/scripts/presets/keyconfig/keymap_data/industry_compatible_data.py index dbe351eb10c..6a24f072ed0 100644 --- a/release/scripts/presets/keyconfig/keymap_data/industry_compatible_data.py +++ b/release/scripts/presets/keyconfig/keymap_data/industry_compatible_data.py @@ -3866,7 +3866,8 @@ def km_knife_tool_modal_map(_params): ("CONFIRM", {"type": 'NUMPAD_ENTER', "value": 'PRESS', "any": True}, None), ("ADD_CUT_CLOSED", {"type": 'LEFTMOUSE', "value": 'DOUBLE_CLICK', "any": True}, None), ("ADD_CUT", {"type": 'LEFTMOUSE', "value": 'ANY', "any": True}, None), - ("NEW_CUT", {"type": 'E', "value": 'PRESS'}, None), + ("UNDO", {"type": 'Z', "value": 'PRESS', "ctrl": True}, None), + ("NEW_CUT", {"type": 'RIGHTMOUSE', "value": 'PRESS'}, None), ("SNAP_MIDPOINTS_ON", {"type": 'LEFT_CTRL', "value": 'PRESS'}, None), ("SNAP_MIDPOINTS_OFF", {"type": 'LEFT_CTRL', "value": 'RELEASE'}, None), ("SNAP_MIDPOINTS_ON", {"type": 'RIGHT_CTRL', "value": 'PRESS'}, None), @@ -3875,11 +3876,13 @@ def km_knife_tool_modal_map(_params): ("IGNORE_SNAP_OFF", {"type": 'LEFT_SHIFT', "value": 'RELEASE', "any": True}, None), ("IGNORE_SNAP_ON", {"type": 'RIGHT_SHIFT', "value": 'PRESS', "any": True}, None), ("IGNORE_SNAP_OFF", {"type": 'RIGHT_SHIFT', "value": 'RELEASE', "any": True}, None), - ("ANGLE_SNAP_TOGGLE", {"type": 'C', "value": 'PRESS'}, None), - ("CUT_THROUGH_TOGGLE", {"type": 'X', "value": 'PRESS'}, None), + ("ANGLE_SNAP_TOGGLE", {"type": 'A', "value": 'PRESS'}, None), + ("CYCLE_ANGLE_SNAP_EDGE", {"type": 'R', "value": 'PRESS'}, None), + ("CUT_THROUGH_TOGGLE", {"type": 'C', "value": 'PRESS'}, None), ("PANNING", {"type": 'MIDDLEMOUSE', "value": 'PRESS', "alt": True}, None), ("PANNING", {"type": 'RIGHTMOUSE', "value": 'PRESS', "alt": True}, None), - ("CONFIRM", {"type": 'RIGHTMOUSE', "value": 'PRESS'}, None), + ("SHOW_DISTANCE_ANGLE_TOGGLE", {"type": 'D', "value": 'PRESS'}, None), + ("DEPTH_TEST_TOGGLE", {"type": 'V', "value": 'PRESS'}, None), ]) return keymap diff --git a/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py b/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py index 77a6ff79598..a4a51cb9910 100644 --- a/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py +++ b/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py @@ -1087,11 +1087,29 @@ class _defs_edit_mesh: @ToolDef.from_fn def knife(): - def draw_settings(_context, layout, tool): + def draw_settings(_context, layout, tool, *, extra=False): + show_extra = False props = tool.operator_properties("mesh.knife_tool") - layout.prop(props, "use_occlude_geometry") - layout.prop(props, "only_selected") - + if not extra: + row = layout.row() + layout.prop(props, "use_occlude_geometry") + row = layout.row() + layout.prop(props, "only_selected") + row = layout.row() + layout.prop(props, "xray") + region_is_header = bpy.context.region.type == 'TOOL_HEADER' + if region_is_header: + show_extra = True + else: + extra = True + if extra: + layout.use_property_split = True + layout.prop(props, "visible_measurements") + layout.prop(props, "angle_snapping") + layout.label(text="Angle Snapping Increment") + layout.row().prop(props, "angle_snapping_increment", text="", expand=True) + if show_extra: + layout.popover("TOPBAR_PT_tool_settings_extra", text="...") return dict( idname="builtin.knife", label="Knife", diff --git a/source/blender/editors/mesh/CMakeLists.txt b/source/blender/editors/mesh/CMakeLists.txt index 35bf295a678..4ad2e57d266 100644 --- a/source/blender/editors/mesh/CMakeLists.txt +++ b/source/blender/editors/mesh/CMakeLists.txt @@ -18,6 +18,7 @@ set(INC ../include ../uvedit + ../../blenfont ../../blenkernel ../../blenlib ../../blentranslation diff --git a/source/blender/editors/mesh/editmesh_knife.c b/source/blender/editors/mesh/editmesh_knife.c index 3e3593d18fd..eee4aec7459 100644 --- a/source/blender/editors/mesh/editmesh_knife.c +++ b/source/blender/editors/mesh/editmesh_knife.c @@ -29,6 +29,8 @@ #include "MEM_guardedalloc.h" +#include "BLF_api.h" + #include "BLI_alloca.h" #include "BLI_array.h" #include "BLI_linklist.h" @@ -36,6 +38,7 @@ #include "BLI_math.h" #include "BLI_memarena.h" #include "BLI_smallhash.h" +#include "BLI_stack.h" #include "BLI_string.h" #include "BLT_translation.h" @@ -44,15 +47,20 @@ #include "BKE_context.h" #include "BKE_editmesh.h" #include "BKE_editmesh_bvh.h" +#include "BKE_layer.h" #include "BKE_report.h" +#include "BKE_scene.h" +#include "BKE_unit.h" #include "GPU_immediate.h" #include "GPU_matrix.h" #include "GPU_state.h" #include "ED_mesh.h" +#include "ED_numinput.h" #include "ED_screen.h" #include "ED_space_api.h" +#include "ED_transform.h" #include "ED_view3d.h" #include "WM_api.h" @@ -69,15 +77,15 @@ #include "DEG_depsgraph.h" #include "DEG_depsgraph_query.h" -#include "mesh_intern.h" /* own include */ +#include "mesh_intern.h" /* Own include. */ -/* detect isolated holes and fill them */ +/* Detect isolated holes and fill them. */ #define USE_NET_ISLAND_CONNECT -#define KMAXDIST (10 * U.dpi_fac) /* max mouse distance from edge before not detecting it */ +#define KMAXDIST (10 * U.dpi_fac) /* Max mouse distance from edge before not detecting it. */ -/* WARNING: knife float precision is fragile: - * be careful before making changes here see: (T43229, T42864, T42459, T41164). +/* WARNING: Knife float precision is fragile: + * Be careful before making changes here see: (T43229, T42864, T42459, T41164). */ #define KNIFE_FLT_EPS 0.00001f #define KNIFE_FLT_EPS_SQUARED (KNIFE_FLT_EPS * KNIFE_FLT_EPS) @@ -87,24 +95,37 @@ #define KNIFE_FLT_EPS_PX_EDGE 0.05f #define KNIFE_FLT_EPS_PX_FACE 0.05f +#define KNIFE_DEFAULT_ANGLE_SNAPPING_INCREMENT 30.0f +#define KNIFE_MIN_ANGLE_SNAPPING_INCREMENT 0.0f +#define KNIFE_MAX_ANGLE_SNAPPING_INCREMENT 90.0f + typedef struct KnifeColors { uchar line[3]; uchar edge[3]; + uchar edge_extra[3]; uchar curpoint[3]; uchar curpoint_a[4]; uchar point[3]; uchar point_a[4]; + uchar xaxis[3]; + uchar yaxis[3]; + uchar zaxis[3]; + uchar axis_extra[3]; } KnifeColors; -/* knifetool operator */ +/* Knifetool Operator. */ typedef struct KnifeVert { - BMVert *v; /* non-NULL if this is an original vert */ + Object *ob; + uint base_index; + BMVert *v; /* Non-NULL if this is an original vert. */ ListBase edges; ListBase faces; float co @@ Diff output truncated at 10240 characters. @@ _______________________________________________ Bf-blender-cvs mailing list [email protected] List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
