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:
authorGermano Cavalcante <mano-wii>2021-11-17 03:05:30 +0300
committerGermano Cavalcante <germano.costa@ig.com.br>2021-11-18 19:14:18 +0300
commit1d1855e95f916685fed970904fc37701a4a0e031 (patch)
treea62ec25eb008f5b5b1d83bc2bc523ee1c8b3885f /source/blender/editors/transform/transform_generics.c
parentcb3ba68ec4470a170905a2dc9ea64b8fa1f8ace3 (diff)
Allow navigating while transforming
This feature has been desired for some time: - https://rightclickselect.com/p/ui/Tqbbbc/allow-navigating-while-transforming (See comments); - D1583; - T37427; In short, blocking navigation during transform limits the user to move the object only to visible areas within the screen and hinders the allocation of objects within closed meshes. The node editor is also impaired because some nodes are far between them and the connectors are too small. The only disadvantage of this patch (as I see it) is the conflict with the existing key map: MIDDLEMOUSE: - enable axis constrain in 3D view; WHEELDOWNMOUSE, WHEELUPMOUSE, PAGEUPKEY, PAGEDOWNKEY: - change the threshold of the proportional edit; So the patch solution was to change these keymaps: - MIDDLEMOUSE to Alt+MIDDLEMOUSE; - WHEELDOWNMOUSE, WHEELUPMOUSE, PAGEUPKEY, PAGEDOWNKEY to Alt+(corresponding key); When you use this new keymap for the first time in the proportional edit, it may seem strange due to the custom of using it (both in View2D and View3D). But quickly the user gets used to it. Alternatively we can add an option to the user preferences ([] Allow navigating while transforming). (I'm not much fan of this option). The patch was done on branch2.8. But maybe it's a good idea to apply it to 2.79 Differential Revision: https://developer.blender.org/D2624
Diffstat (limited to 'source/blender/editors/transform/transform_generics.c')
-rw-r--r--source/blender/editors/transform/transform_generics.c72
1 files changed, 58 insertions, 14 deletions
diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c
index 4194fb2a0ad..7846fa93f03 100644
--- a/source/blender/editors/transform/transform_generics.c
+++ b/source/blender/editors/transform/transform_generics.c
@@ -679,6 +679,8 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve
}
setTransformViewMatrices(t);
+ calculateCenter2D(t);
+ calculateCenterLocal(t, t->center_global);
initNumInput(&t->num);
}
@@ -1140,6 +1142,33 @@ static void calculateCenter_FromAround(TransInfo *t, int around, float r_center[
}
}
+static void calculateZfac(TransInfo *t)
+{
+ /* ED_view3d_calc_zfac() defines a factor for perspective depth correction,
+ * used in ED_view3d_win_to_delta() */
+
+ /* zfac is only used convertViewVec only in cases operator was invoked in RGN_TYPE_WINDOW
+ * and never used in other cases.
+ *
+ * We need special case here as well, since ED_view3d_calc_zfac will crash when called
+ * for a region different from RGN_TYPE_WINDOW.
+ */
+ if (t->spacetype == SPACE_VIEW3D) {
+ t->zfac = ED_view3d_calc_zfac(t->region->regiondata, t->center_global, NULL);
+ }
+ else if (t->spacetype == SPACE_IMAGE) {
+ SpaceImage *sima = t->area->spacedata.first;
+ t->zfac = 1.0f / sima->zoom;
+ }
+ else {
+ View2D *v2d = &t->region->v2d;
+ /* Get zoom fac the same way as in
+ * `ui_view2d_curRect_validate_resize` - better keep in sync! */
+ const float zoomx = (float)(BLI_rcti_size_x(&v2d->mask) + 1) / BLI_rctf_size_x(&v2d->cur);
+ t->zfac = 1.0f / zoomx;
+ }
+}
+
void calculateCenter(TransInfo *t)
{
if ((t->flag & T_OVERRIDE_CENTER) == 0) {
@@ -1174,23 +1203,38 @@ void calculateCenter(TransInfo *t)
}
}
+ calculateZfac(t);
+}
+
+/* Called every time the view changes due to navigation.
+ * Adjusts the mouse position relative to the object. */
+void tranformViewUpdate(TransInfo *t)
+{
if (t->spacetype == SPACE_VIEW3D) {
- /* ED_view3d_calc_zfac() defines a factor for perspective depth correction,
- * used in ED_view3d_win_to_delta() */
-
- /* zfac is only used convertViewVec only in cases operator was invoked in RGN_TYPE_WINDOW
- * and never used in other cases.
- *
- * We need special case here as well, since ED_view3d_calc_zfac will crash when called
- * for a region different from RGN_TYPE_WINDOW.
- */
- if (t->region->regiontype == RGN_TYPE_WINDOW) {
- t->zfac = ED_view3d_calc_zfac(t->region->regiondata, t->center_global, NULL);
- }
- else {
- t->zfac = 0.0f;
+ setTransformViewMatrices(t);
+
+ for (int i = 0; i < ARRAY_SIZE(t->orient); i++) {
+ if (t->orient[i].type == V3D_ORIENT_VIEW) {
+ copy_m3_m4(t->orient[i].matrix, t->viewinv);
+ normalize_m3(t->orient[i].matrix);
+ if (t->orient_curr == i) {
+ copy_m3_m3(t->spacemtx, t->orient[i].matrix);
+ invert_m3_m3_safe_ortho(t->spacemtx_inv, t->spacemtx);
+ }
+ }
}
}
+
+ float fac = 1.0f;
+ if (ELEM(t->spacetype, SPACE_VIEW3D, SPACE_IMAGE, SPACE_NODE)) {
+ float zfac_prev = t->zfac;
+ calculateZfac(t);
+ fac = zfac_prev / t->zfac;
+ }
+
+ calculateCenter2D(t);
+ transform_input_update(t, fac);
+ t->flag &= ~T_VIEW_DIRTY;
}
void calculatePropRatio(TransInfo *t)