[Bf-blender-cvs] [ac8cde69f50] blender2.8: GP: Primitive: Add RMB behaviour to Grab/Move

Charlie Jolly noreply at git.blender.org
Wed Dec 19 13:29:20 CET 2018


Commit: ac8cde69f50ec5e8b3af7e8538006dc011b1c541
Author: Charlie Jolly
Date:   Wed Dec 19 10:17:14 2018 +0000
Branches: blender2.8
https://developer.blender.org/rBac8cde69f50ec5e8b3af7e8538006dc011b1c541

GP: Primitive: Add RMB behaviour to Grab/Move

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

M	source/blender/editors/gpencil/gpencil_intern.h
M	source/blender/editors/gpencil/gpencil_primitive.c

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

diff --git a/source/blender/editors/gpencil/gpencil_intern.h b/source/blender/editors/gpencil/gpencil_intern.h
index e2cbeda2733..7d386c18c64 100644
--- a/source/blender/editors/gpencil/gpencil_intern.h
+++ b/source/blender/editors/gpencil/gpencil_intern.h
@@ -162,6 +162,7 @@ typedef struct tGPDprimitive {
 	int point_count;                  /* number of edges allocated */
 	int tot_stored_edges;             /* stored number of polygon edges */
 	int tot_edges;                    /* number of polygon edges */
+	float move[2];                    /* move distance */
 	float origin[2];                  /* initial box corner */
 	float start[2];                   /* first box corner */
 	float end[2];                     /* last box corner */
diff --git a/source/blender/editors/gpencil/gpencil_primitive.c b/source/blender/editors/gpencil/gpencil_primitive.c
index f13235926f1..d856c1859bb 100644
--- a/source/blender/editors/gpencil/gpencil_primitive.c
+++ b/source/blender/editors/gpencil/gpencil_primitive.c
@@ -1302,10 +1302,19 @@ static void gpencil_primitive_edit_event_handling(bContext *C, wmOperator *op, w
 }
 
 /* move */
-static void gpencil_primitive_move(tGPDprimitive *tgpi)
+static void gpencil_primitive_move(tGPDprimitive *tgpi, bool reset)
 {
 	float move[2];
-	sub_v2_v2v2(move, tgpi->mval, tgpi->mvalo);
+	zero_v2(move);
+
+	if (reset) {
+		sub_v2_v2(move, tgpi->move);
+		zero_v2(tgpi->move);
+	}
+	else {
+		sub_v2_v2v2(move, tgpi->mval, tgpi->mvalo);
+		add_v2_v2(tgpi->move, move);
+	}
 
 	bGPDstroke *gps = tgpi->gpf->strokes.first;
 	tGPspoint *points2D = tgpi->points;
@@ -1335,14 +1344,21 @@ static int gpencil_primitive_modal(bContext *C, wmOperator *op, const wmEvent *e
 
 		switch (event->type) {
 			case MOUSEMOVE:
-				gpencil_primitive_move(tgpi);
+				gpencil_primitive_move(tgpi, false);
 				gpencil_primitive_update(C, op, tgpi);
 				break;
 			case ESCKEY:
-			case RIGHTMOUSE:
 			case LEFTMOUSE:
+				zero_v2(tgpi->move);
 				tgpi->flag = IN_CURVE_EDIT;
 				break;
+			case RIGHTMOUSE:
+				if (event->val == KM_RELEASE) {
+					tgpi->flag = IN_CURVE_EDIT;
+					gpencil_primitive_move(tgpi, true);
+					gpencil_primitive_update(C, op, tgpi);
+				}
+				break;
 		}
 		copy_v2_v2(tgpi->mvalo, tgpi->mval);
 		return OPERATOR_RUNNING_MODAL;



More information about the Bf-blender-cvs mailing list