[Bf-blender-cvs] [d2e473f01c5] blender2.8: GP: Reorganize Reproject options

Antonioya noreply at git.blender.org
Tue Nov 20 16:30:08 CET 2018


Commit: d2e473f01c5db04d0e77ac911c9e34a1acb6aeb6
Author: Antonioya
Date:   Tue Nov 20 16:29:33 2018 +0100
Branches: blender2.8
https://developer.blender.org/rBd2e473f01c5db04d0e77ac911c9e34a1acb6aeb6

GP: Reorganize Reproject options

The options depend of drawing mode and this was very strange. Now, the options are listed in the menu.

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

M	source/blender/editors/gpencil/gpencil_edit.c

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

diff --git a/source/blender/editors/gpencil/gpencil_edit.c b/source/blender/editors/gpencil/gpencil_edit.c
index f2caba026ca..b56d46fdc1e 100644
--- a/source/blender/editors/gpencil/gpencil_edit.c
+++ b/source/blender/editors/gpencil/gpencil_edit.c
@@ -2840,10 +2840,12 @@ void GPENCIL_OT_stroke_flip(wmOperatorType *ot)
 /* ***************** Reproject Strokes ********************** */
 
 typedef enum eGP_ReprojectModes {
-	/* Axis (equal to lock axis) */
-	GP_REPROJECT_AXIS = 0,
+	/* Axis */
+	GP_REPROJECT_FRONT = 0,
+	GP_REPROJECT_SIDE,
+	GP_REPROJECT_TOP,
 	/* On same plane, parallel to viewplane */
-	GP_REPROJECT_PLANAR,
+	GP_REPROJECT_VIEW,
 	/* Reprojected on to the scene geometry */
 	GP_REPROJECT_SURFACE,
 } eGP_ReprojectModes;
@@ -2863,14 +2865,8 @@ static int gp_strokes_reproject_exec(bContext *C, wmOperator *op)
 	GP_SpaceConversion gsc = {NULL};
 	eGP_ReprojectModes mode = RNA_enum_get(op->ptr, "type");
 
-	int lock_axis = ts->gp_sculpt.lock_axis;
 	float origin[3];
 
-	if ((mode == GP_REPROJECT_AXIS) && (lock_axis == GP_LOCKAXIS_VIEW)) {
-		BKE_report(op->reports, RPT_ERROR, "To reproject by axis, a lock axis must be set before");
-		return OPERATOR_CANCELLED;
-	}
-
 	/* init space conversion stuff */
 	gp_point_conversion_init(C, &gsc);
 
@@ -2907,24 +2903,47 @@ static int gp_strokes_reproject_exec(bContext *C, wmOperator *op)
 				gp_point_to_parent_space(pt, gpstroke_iter.diff_mat, &pt2);
 				gp_point_to_xy_fl(&gsc, gps, &pt2, &xy[0], &xy[1]);
 
-				/* Project stroke in the axis locked */
-				if (mode == GP_REPROJECT_AXIS) {
-					if (lock_axis > GP_LOCKAXIS_VIEW) {
-						ED_gp_get_drawing_reference(v3d, scene, ob, gpl,
-							ts->gpencil_v3d_align, origin);
-						ED_gp_project_point_to_plane(ob, rv3d, origin,
-							lock_axis - 1, &pt2);
+				/* Project stroke in one axis */
+				if (ELEM(mode, GP_REPROJECT_FRONT, GP_REPROJECT_SIDE, GP_REPROJECT_TOP)) {
+					ED_gp_get_drawing_reference(v3d, scene, ob, gpl,
+						ts->gpencil_v3d_align, origin);
+
+					int axis = 0;
+					switch (mode) {
+						case GP_REPROJECT_FRONT:
+						{
+							axis = 1;
+							break;
+						}
+						case GP_REPROJECT_SIDE:
+						{
+							axis = 0;
+							break;
+						}
+						case GP_REPROJECT_TOP:
+						{
+							axis = 2;
+							break;
+						}
+						default:
+						{
+							axis = 1;
+							break;
+						}
+					}
+
+					ED_gp_project_point_to_plane(ob, rv3d, origin,
+						axis, &pt2);
 
-						copy_v3_v3(&pt->x, &pt2.x);
+					copy_v3_v3(&pt->x, &pt2.x);
 
-						/* apply parent again */
-						gp_apply_parent_point(depsgraph, ob, gpd, gpl, pt);
-					}
+					/* apply parent again */
+					gp_apply_parent_point(depsgraph, ob, gpd, gpl, pt);
 				}
 				/* Project screenspace back to 3D space (from current perspective)
 				 * so that all points have been treated the same way
 				 */
-				else if (mode == GP_REPROJECT_PLANAR) {
+				else if (mode == GP_REPROJECT_VIEW) {
 					/* Planar - All on same plane parallel to the viewplane */
 					gp_point_xy_to_3d(&gsc, scene, xy, &pt->x);
 				}
@@ -2947,7 +2966,7 @@ static int gp_strokes_reproject_exec(bContext *C, wmOperator *op)
 				}
 
 				/* Unapply parent corrections */
-				if (mode != GP_REPROJECT_AXIS) {
+				if (!ELEM(mode, GP_REPROJECT_FRONT, GP_REPROJECT_SIDE, GP_REPROJECT_TOP)) {
 					mul_m4_v3(inverse_diff_mat, &pt->x);
 				}
 			}
@@ -2963,10 +2982,13 @@ static int gp_strokes_reproject_exec(bContext *C, wmOperator *op)
 void GPENCIL_OT_reproject(wmOperatorType *ot)
 {
 	static const EnumPropertyItem reproject_type[] = {
-		{GP_REPROJECT_AXIS, "AXIS", 0, "Axis",
-		"Reproject the strokes using the current lock axis configuration. This is the same projection using while"
-		"drawing new strokes"},
-		{GP_REPROJECT_PLANAR, "PLANAR", 0, "Planar",
+		{GP_REPROJECT_FRONT, "FRONT", 0, "Front",
+		"Reproject the strokes using the X-Z plane"},
+		{GP_REPROJECT_SIDE, "SIDE", 0, "Side",
+		"Reproject the strokes using the Y-Z plane"},
+		{GP_REPROJECT_TOP, "TOP", 0, "Top",
+		"Reproject the strokes using the X-Y plane"},
+		{GP_REPROJECT_VIEW, "VIEW", 0, "View",
 		 "Reproject the strokes to end up on the same plane, as if drawn from the current viewpoint "
 		 "using 'Cursor' Stroke Placement"},
 		{GP_REPROJECT_SURFACE, "SURFACE", 0, "Surface",
@@ -2990,7 +3012,7 @@ void GPENCIL_OT_reproject(wmOperatorType *ot)
 	ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_USE_EVAL_DATA;
 
 	/* properties */
-	ot->prop = RNA_def_enum(ot->srna, "type", reproject_type, GP_REPROJECT_PLANAR, "Projection Type", "");
+	ot->prop = RNA_def_enum(ot->srna, "type", reproject_type, GP_REPROJECT_VIEW, "Projection Type", "");
 }
 
 /* ******************* Stroke subdivide ************************** */



More information about the Bf-blender-cvs mailing list