From c6fb80cb9b8f5cc48216a784908811a31f6f6731 Mon Sep 17 00:00:00 2001 From: Germano Cavalcante Date: Mon, 31 Jul 2023 16:06:37 +0200 Subject: [PATCH] Transform: use transform Pivot for AutoDepth during navigation To avoid the small jumps during the Pan operation, a feature was implemented in the `ED_view3d_navigation_do` utility that replaces the point used for AutoDepth. As a result, the depth of the pivot point is now used during the transform. Also, to ensure minimal disruption to non-AutoDepth users, this feature is enabled only when "Auto Depth" is enabled. Pull Request: https://projects.blender.org/blender/blender/pulls/109451 --- source/blender/editors/include/ED_view3d.h | 3 ++- .../editors/space_view3d/view3d_navigate.cc | 16 ++++++++++++---- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/source/blender/editors/include/ED_view3d.h b/source/blender/editors/include/ED_view3d.h index 1c9d3cbe028..45cca579734 100644 --- a/source/blender/editors/include/ED_view3d.h +++ b/source/blender/editors/include/ED_view3d.h @@ -223,7 +223,8 @@ bool ED_view3d_depth_unproject_v3(const struct ARegion *region, struct ViewOpsData *ED_view3d_navigation_init(struct bContext *C, const bool use_alt_navigation); bool ED_view3d_navigation_do(struct bContext *C, struct ViewOpsData *vod, - const struct wmEvent *event); + const struct wmEvent *event, + const float depth_loc_override[3]); void ED_view3d_navigation_free(struct bContext *C, struct ViewOpsData *vod); /* Projection */ diff --git a/source/blender/editors/space_view3d/view3d_navigate.cc b/source/blender/editors/space_view3d/view3d_navigate.cc index b41e806c1eb..8a648038a25 100644 --- a/source/blender/editors/space_view3d/view3d_navigate.cc +++ b/source/blender/editors/space_view3d/view3d_navigate.cc @@ -12,6 +12,7 @@ #include "MEM_guardedalloc.h" #include "BLI_math.h" +#include "BLI_math_vector_types.hh" #include "BLI_rect.h" #include "BLT_translation.h" @@ -45,6 +46,8 @@ #include "view3d_navigate.hh" /* own include */ +using namespace blender; + /* Prototypes. */ static const ViewOpsType *view3d_navigation_type_from_idname(const char *idname); @@ -490,7 +493,8 @@ static int view3d_navigation_invoke_generic(bContext *C, ViewOpsData *vod, const wmEvent *event, PointerRNA *ptr, - const ViewOpsType *nav_type) + const float dyn_ofs_override[3], + const eV3D_OpMode nav_type) { if (!nav_type->init_fn) { return OPERATOR_CANCELLED; @@ -1020,16 +1024,20 @@ static int view3d_navigation_invoke(bContext *C, ViewOpsData *vod, const wmEvent *event, wmKeyMapItem *kmi, - const ViewOpsType *nav_type) + const float dyn_ofs_override[3], + eV3D_OpMode nav_type) { if (nav_type->poll_fn && !nav_type->poll_fn(C)) { return OPERATOR_CANCELLED; } - return view3d_navigation_invoke_generic(C, vod, event, kmi->ptr, nav_type); + return view3d_navigation_invoke_generic(C, vod, event, kmi->ptr, dyn_ofs_override, nav_type); } -bool ED_view3d_navigation_do(bContext *C, ViewOpsData *vod, const wmEvent *event) +bool ED_view3d_navigation_do(bContext *C, + ViewOpsData *vod, + const wmEvent *event, + const float depth_loc_override[3]) { if (!vod) { return false;