[Bf-blender-cvs] [497a266] master: Knife: double clicking now closes the loop

Campbell Barton noreply at git.blender.org
Sun Nov 16 13:00:12 CET 2014


Commit: 497a26665c4900b9f1673a09f8216a698cd01312
Author: Campbell Barton
Date:   Sun Nov 16 01:11:26 2014 +0100
Branches: master
https://developer.blender.org/rB497a26665c4900b9f1673a09f8216a698cd01312

Knife: double clicking now closes the loop

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

M	source/blender/editors/mesh/editmesh_knife.c

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

diff --git a/source/blender/editors/mesh/editmesh_knife.c b/source/blender/editors/mesh/editmesh_knife.c
index 6681526..b1fc18e 100644
--- a/source/blender/editors/mesh/editmesh_knife.c
+++ b/source/blender/editors/mesh/editmesh_knife.c
@@ -174,8 +174,10 @@ typedef struct KnifeTool_OpData {
 	KnifeLineHit *linehits;
 	int totlinehit;
 
-	/* Data for mouse-position-derived data (cur) and previous click (prev) */
-	KnifePosData curr, prev;
+	/* Data for mouse-position-derived data */
+	KnifePosData curr;  /* current point under the cursor */
+	KnifePosData prev;  /* last added cut (a line draws from the cursor to this) */
+	KnifePosData init;  /* the first point in the cut-list, used for closing the loop */
 
 	int totkedge, totkvert;
 
@@ -2852,7 +2854,8 @@ enum {
 	KNF_MODAL_ADD_CUT,
 	KNF_MODAL_ANGLE_SNAP_TOGGLE,
 	KNF_MODAL_CUT_THROUGH_TOGGLE,
-	KNF_MODAL_PANNING
+	KNF_MODAL_PANNING,
+	KNF_MODAL_ADD_CUT_CLOSED,
 };
 
 wmKeyMap *knifetool_modal_keymap(wmKeyConfig *keyconf)
@@ -2883,6 +2886,7 @@ wmKeyMap *knifetool_modal_keymap(wmKeyConfig *keyconf)
 	/* items for modal map */
 	WM_modalkeymap_add_item(keymap, ESCKEY, KM_PRESS, KM_ANY, 0, KNF_MODAL_CANCEL);
 	WM_modalkeymap_add_item(keymap, MIDDLEMOUSE, KM_ANY, KM_ANY, 0, KNF_MODAL_PANNING);
+	WM_modalkeymap_add_item(keymap, LEFTMOUSE, KM_DBL_CLICK, KM_ANY, 0, KNF_MODAL_ADD_CUT_CLOSED);
 	WM_modalkeymap_add_item(keymap, LEFTMOUSE, KM_ANY, KM_ANY, 0, KNF_MODAL_ADD_CUT);
 	WM_modalkeymap_add_item(keymap, RIGHTMOUSE, KM_PRESS, KM_ANY, 0, KNF_MODAL_CANCEL);
 	WM_modalkeymap_add_item(keymap, RETKEY, KM_PRESS, KM_ANY, 0, KNF_MODAL_CONFIRM);
@@ -3002,6 +3006,7 @@ static int knifetool_modal(bContext *C, wmOperator *op, const wmEvent *event)
 					else if (kcd->mode != MODE_PANNING) {
 						knife_start_cut(kcd);
 						kcd->mode = MODE_DRAGGING;
+						kcd->init = kcd->curr;
 					}
 
 					/* freehand drawing is incompatible with cut-through */
@@ -3015,6 +3020,21 @@ static int knifetool_modal(bContext *C, wmOperator *op, const wmEvent *event)
 
 				ED_region_tag_redraw(kcd->ar);
 				break;
+			case KNF_MODAL_ADD_CUT_CLOSED:
+				if (kcd->mode == MODE_DRAGGING) {
+					kcd->prev = kcd->curr;
+					kcd->curr = kcd->init;
+
+					knife_project_v2(kcd, kcd->curr.cage, kcd->curr.mval);
+					knifetool_update_mval(kcd, kcd->curr.mval);
+
+					knife_add_cut(kcd);
+
+					/* KNF_MODAL_NEW_CUT */
+					knife_finish_cut(kcd);
+					kcd->mode = MODE_IDLE;
+				}
+				break;
 			case KNF_MODAL_PANNING:
 				if (event->val != KM_RELEASE) {
 					if (kcd->mode != MODE_PANNING) {




More information about the Bf-blender-cvs mailing list