[Bf-blender-cvs] [35c0ea7b937] asset-greasepencil: GPencil: Use Shift key to keep pivot in Center for scale

Antonio Vazquez noreply at git.blender.org
Sun Jul 18 23:07:06 CEST 2021


Commit: 35c0ea7b9371b29bb38b7c83ba0abbc8264635af
Author: Antonio Vazquez
Date:   Sun Jul 18 17:27:41 2021 +0200
Branches: asset-greasepencil
https://developer.blender.org/rB35c0ea7b9371b29bb38b7c83ba0abbc8264635af

GPencil: Use Shift key to keep pivot in Center for scale

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

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

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

diff --git a/source/blender/editors/gpencil/gpencil_asset.c b/source/blender/editors/gpencil/gpencil_asset.c
index 04a71bfc002..062cc18b5cc 100644
--- a/source/blender/editors/gpencil/gpencil_asset.c
+++ b/source/blender/editors/gpencil/gpencil_asset.c
@@ -606,7 +606,9 @@ static void gpencil_2d_cage_area_detect(tGPDasset *tgpa, const int mouse[2])
 }
 
 /* Helper: Transfrom the stroke with mouse movements. */
-static void gpencil_asset_transform_strokes(tGPDasset *tgpa, const int mouse[2])
+static void gpencil_asset_transform_strokes(tGPDasset *tgpa,
+                                            const int mouse[2],
+                                            const bool shift_key)
 {
   /* Get the vector with the movement done by the mouse since last event. */
   float origin_pt[3], dest_pt[3];
@@ -631,17 +633,19 @@ static void gpencil_asset_transform_strokes(tGPDasset *tgpa, const int mouse[2])
   /* Determine pivot point. */
   float pivot[3];
   copy_v3_v3(pivot, tgpa->asset_center);
-  if (tgpa->manipulator_index == CAGE_CORNER_N) {
-    gpencil_point_xy_to_3d(&tgpa->gsc, tgpa->scene, tgpa->manipulator[CAGE_CORNER_S], pivot);
-  }
-  else if (tgpa->manipulator_index == CAGE_CORNER_E) {
-    gpencil_point_xy_to_3d(&tgpa->gsc, tgpa->scene, tgpa->manipulator[CAGE_CORNER_W], pivot);
-  }
-  else if (tgpa->manipulator_index == CAGE_CORNER_S) {
-    gpencil_point_xy_to_3d(&tgpa->gsc, tgpa->scene, tgpa->manipulator[CAGE_CORNER_N], pivot);
-  }
-  else if (tgpa->manipulator_index == CAGE_CORNER_W) {
-    gpencil_point_xy_to_3d(&tgpa->gsc, tgpa->scene, tgpa->manipulator[CAGE_CORNER_E], pivot);
+  if (!shift_key) {
+    if (tgpa->manipulator_index == CAGE_CORNER_N) {
+      gpencil_point_xy_to_3d(&tgpa->gsc, tgpa->scene, tgpa->manipulator[CAGE_CORNER_S], pivot);
+    }
+    else if (tgpa->manipulator_index == CAGE_CORNER_E) {
+      gpencil_point_xy_to_3d(&tgpa->gsc, tgpa->scene, tgpa->manipulator[CAGE_CORNER_W], pivot);
+    }
+    else if (tgpa->manipulator_index == CAGE_CORNER_S) {
+      gpencil_point_xy_to_3d(&tgpa->gsc, tgpa->scene, tgpa->manipulator[CAGE_CORNER_N], pivot);
+    }
+    else if (tgpa->manipulator_index == CAGE_CORNER_W) {
+      gpencil_point_xy_to_3d(&tgpa->gsc, tgpa->scene, tgpa->manipulator[CAGE_CORNER_E], pivot);
+    }
   }
 
   GHashIterator gh_iter;
@@ -979,7 +983,7 @@ static int gpencil_asset_import_modal(bContext *C, wmOperator *op, const wmEvent
     {
       /* Apply transform. */
       if (tgpa->flag & GP_ASSET_FLAG_RUNNING) {
-        gpencil_asset_transform_strokes(tgpa, event->mval);
+        gpencil_asset_transform_strokes(tgpa, event->mval, event->shift);
         gpencil_2d_cage_calc(tgpa);
         ED_area_tag_redraw(tgpa->area);
       }



More information about the Bf-blender-cvs mailing list