Page MenuHome

Viewport view resets after navigating within the Camera view
Confirmed, NormalPublic

Description

System Information
Operating system: Pop!_Os 20.04
Graphics card: Nvidia GTX 1080ti

Blender Version
Broken: 3.0 Beta, 7a5b8cb20284, master, 2021-11- 05, 2.83, 2.79... etc
Worked: Has never worked

Short description of error
When navigating in camera view, if the user goes back to Viewport view it will reset the Viewport back to the world origin

Exact steps for others to reproduce the error

  • New File
  • Add Camera
  • Navigate anywhere in Viewport view
  • Go into Camera view
  • Navigate again inside Camera view (use walk navigation)
  • Go back into Viewport view
  • Viewport will reset back to world origin
NOTE: this only happens if you navigate inside the camera, if you go back to Viewport view using the middle mouse button it wont happen
Blender 3.02.83.162.79

Event Timeline

Philipp Oeser (lichtwerk) changed the task status from Needs Triage to Confirmed.Nov 9 2021, 4:48 PM

Can confirm the behavior, not sure this could be classified as a bug.

Some aspects are correctly resored for me, so the View rotation [which is stored in RegionView3D->lviewquat] comes back as it was before.
But as soon as the view has been moved, restoring this is not enough.
So we might have to also store RegionView3D->ofs & RegionView3D->dist to be able to completely restore the previous view?
Had a quick doodle, and this seems to work, but code here is complex and used in a lot of places so it is better if User Interface devs can have a look.

1
2
3diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c
4index b85b424405e..65771442deb 100644
5--- a/source/blender/editors/space_view3d/view3d_edit.c
6+++ b/source/blender/editors/space_view3d/view3d_edit.c
7@@ -3893,13 +3893,13 @@ static void axis_set_view(bContext *C,
8 /* from camera */
9 float ofs[3], dist;
10
11- copy_v3_v3(ofs, rv3d->ofs);
12- dist = rv3d->dist;
13+ copy_v3_v3(ofs, rv3d->lofs);
14+ dist = rv3d->ldist;
15
16 /* so we animate _from_ the camera location */
17 Object *camera_eval = DEG_get_evaluated_object(CTX_data_ensure_evaluated_depsgraph(C),
18 v3d->camera);
19- ED_view3d_from_object(camera_eval, rv3d->ofs, NULL, &rv3d->dist, NULL);
20+ ED_view3d_from_object(camera_eval, rv3d->lofs, NULL, &rv3d->ldist, NULL);
21
22 ED_view3d_smooth_view(C,
23 v3d,
24diff --git a/source/blender/editors/space_view3d/view3d_utils.c b/source/blender/editors/space_view3d/view3d_utils.c
25index d6a1cd930fc..d51a9edecd7 100644
26--- a/source/blender/editors/space_view3d/view3d_utils.c
27+++ b/source/blender/editors/space_view3d/view3d_utils.c
28@@ -487,6 +487,8 @@ bool ED_view3d_offset_lock_check(const View3D *v3d, const RegionView3D *rv3d)
29 void ED_view3d_lastview_store(RegionView3D *rv3d)
30 {
31 copy_qt_qt(rv3d->lviewquat, rv3d->viewquat);
32+ rv3d->ldist = rv3d->dist;
33+ copy_v3_v3(rv3d->lofs, rv3d->ofs);
34 rv3d->lview = rv3d->view;
35 rv3d->lview_axis_roll = rv3d->view_axis_roll;
36 if (rv3d->persp != RV3D_CAMOB) {
37diff --git a/source/blender/makesdna/DNA_view3d_types.h b/source/blender/makesdna/DNA_view3d_types.h
38index 9b5ed133feb..346ea66a48f 100644
39--- a/source/blender/makesdna/DNA_view3d_types.h
40+++ b/source/blender/makesdna/DNA_view3d_types.h
41@@ -123,6 +123,8 @@ typedef struct RegionView3D {
42
43 /** Last view (use when switching out of camera view). */
44 float lviewquat[4];
45+ float ldist;
46+ float lofs[3];
47 /** Lpersp can never be set to 'RV3D_CAMOB'. */
48 char lpersp;
49 char lview;