diff options
author | Pratik Borhade <PratikPB2123> | 2022-08-05 08:53:04 +0300 |
---|---|---|
committer | Campbell Barton <campbell@blender.org> | 2022-08-06 05:57:06 +0300 |
commit | befe38fe1dfbbdac9ed9ef61853800426e5966c5 (patch) | |
tree | f76bb31b2ac108a33e4200262909f0e9d0ae4202 /source/blender/editors/space_view3d/view3d_utils.c | |
parent | 74f983738ab47ccc393885d31ccdb0dcdf898bef (diff) |
Fix T92099: No undo when moving viewport with camera locked to view
Supports undo step generation while navigating in locked camera view.
NDOF & track-pad navigation are not included for now.
Actions that uses smooth view can be supported but are outside
the scope of this change, includes undo push for:
- VIEW3D_OT_view_pan
- VIEW3D_OT_dolly
- VIEW3D_OT_fly
- VIEW3D_OT_move
- VIEW3D_OT_rotate
- VIEW3D_OT_walk
- VIEW3D_OT_zoom
Reviewed by: campbellbarton
Ref D15345
Diffstat (limited to 'source/blender/editors/space_view3d/view3d_utils.c')
-rw-r--r-- | source/blender/editors/space_view3d/view3d_utils.c | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/source/blender/editors/space_view3d/view3d_utils.c b/source/blender/editors/space_view3d/view3d_utils.c index 85b1af8e55d..99f8cbc975b 100644 --- a/source/blender/editors/space_view3d/view3d_utils.c +++ b/source/blender/editors/space_view3d/view3d_utils.c @@ -44,6 +44,7 @@ #include "ED_keyframing.h" #include "ED_screen.h" +#include "ED_undo.h" #include "ED_view3d.h" #include "UI_resources.h" @@ -688,6 +689,43 @@ bool ED_view3d_camera_lock_autokey(View3D *v3d, return false; } +/** + * Create a MEMFILE undo-step for locked camera movement when transforming the view. + * Edit and texture paint mode don't use MEMFILE undo so undo push is skipped for them. + * NDOF and track-pad navigation would create an undo step on every gesture and we may end up with + * unnecessary undo steps so undo push for them is not supported for now. Also operators that uses + * smooth view for navigation are excluded too, but they can be supported, see: D15345. + */ +static bool view3d_camera_lock_undo_ex( + const char *str, View3D *v3d, RegionView3D *rv3d, struct bContext *C, bool undo_group) +{ + if (ED_view3d_camera_lock_check(v3d, rv3d)) { + if (ED_undo_is_memfile_compatible(C)) { + if (undo_group) { + ED_undo_grouped_push(C, str); + } + else { + ED_undo_push(C, str); + } + return true; + } + } + return false; +} + +bool ED_view3d_camera_lock_undo_push(const char *str, View3D *v3d, RegionView3D *rv3d, bContext *C) +{ + return view3d_camera_lock_undo_ex(str, v3d, rv3d, C, false); +} + +bool ED_view3d_camera_lock_undo_grouped_push(const char *str, + View3D *v3d, + RegionView3D *rv3d, + bContext *C) +{ + return view3d_camera_lock_undo_ex(str, v3d, rv3d, C, true); +} + /** \} */ /* -------------------------------------------------------------------- */ |