Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCian Jinks <cjinks99@gmail.com>2021-10-27 00:20:50 +0300
committerCian Jinks <cjinks99@gmail.com>2021-10-27 00:30:21 +0300
commit2c2d4bc3a33128d4c32a53a6b9e484309abba7bf (patch)
treedd61021f04592d92e4fcc65bf553014608cd84ff /source/blender/editors
parent3e3ff1a464b93c39cf31f30ef11b87e5b5786735 (diff)
Knife: Preserve right click cancel functionality
Currently, the knife does not use right click cancel. It causes users to accidentally delete entire cuts easily. This patch allows right click cancel when no cuts have been made. This makes it consistent with other tools when switching between them. More info: https://devtalk.blender.org/t/gsoc-2021-knife-tool-improvements-feedback/19047/175?u=hobbesos
Diffstat (limited to 'source/blender/editors')
-rw-r--r--source/blender/editors/mesh/editmesh_knife.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/source/blender/editors/mesh/editmesh_knife.c b/source/blender/editors/mesh/editmesh_knife.c
index 8e0a7dbd69b..09ae779138c 100644
--- a/source/blender/editors/mesh/editmesh_knife.c
+++ b/source/blender/editors/mesh/editmesh_knife.c
@@ -240,6 +240,7 @@ typedef struct KnifeTool_OpData {
BLI_mempool *kverts;
BLI_mempool *kedges;
+ bool no_cuts; /* A cut has not been made yet. */
BLI_Stack *undostack;
BLI_Stack *splitstack; /* Store edge splits by #knife_split_edge. */
@@ -4089,6 +4090,8 @@ static void knifetool_init(bContext *C,
knife_init_colors(&kcd->colors);
}
+ kcd->no_cuts = true;
+
kcd->axis_string[0] = ' ';
kcd->axis_string[1] = '\0';
@@ -4501,12 +4504,23 @@ static int knifetool_modal(bContext *C, wmOperator *op, const wmEvent *event)
handled = true;
break;
case KNF_MODAL_NEW_CUT:
+ /* If no cuts have been made, exit.
+ * Preserves right click cancel workflow which most tools use,
+ * but stops accidentally deleting entire cuts with right click.
+ */
+ if (kcd->no_cuts) {
+ ED_region_tag_redraw(kcd->region);
+ knifetool_exit(op);
+ ED_workspace_status_text(C, NULL);
+ return OPERATOR_CANCELLED;
+ }
ED_region_tag_redraw(kcd->region);
knife_finish_cut(kcd);
kcd->mode = MODE_IDLE;
handled = true;
break;
case KNF_MODAL_ADD_CUT:
+ kcd->no_cuts = false;
knife_recalc_ortho(kcd);
/* Get the value of the event which triggered this one. */