fix bug [#26315] Background and 3D view mistakes

The bug is caused by a fix for [#22111], commits r29356, r28545.

exiting localview would set the rv3d->view but use the original rv3d->viewquat.
This commit is contained in:
Campbell Barton 2011-03-08 07:44:30 +00:00
parent ae57e8c8c1
commit 092c3d8a85
4 changed files with 29 additions and 13 deletions

@ -177,6 +177,7 @@ struct ImBuf *ED_view3d_draw_offscreen_imbuf_simple(Scene *scene, int width, int
Base *ED_view3d_give_base_under_cursor(struct bContext *C, short *mval);
void ED_view3d_quadview_update(struct ScrArea *sa, struct ARegion *ar, short do_clip);
int ED_view3d_lock(struct RegionView3D *rv3d);
unsigned int ED_viewedit_datamask(struct bScreen *screen);

@ -66,6 +66,7 @@
#include "ED_armature.h"
#include "ED_screen_types.h"
#include "ED_keyframes_draw.h"
#include "ED_view3d.h"
#include "RNA_access.h"
#include "RNA_define.h"
@ -2464,26 +2465,36 @@ static int region_quadview_exec(bContext *C, wmOperator *op)
/* lock views and set them */
if(sa->spacetype==SPACE_VIEW3D) {
/* run ED_view3d_lock() so the correct 'rv3d->viewquat' is set,
* otherwise when restoring rv3d->localvd the 'viewquat' won't
* match the 'view', set on entering localview See: [#26315],
*
* We could avoid manipulating rv3d->localvd here if exiting
* localview with a 4-split would assign these view locks */
RegionView3D *rv3d;
rv3d= ar->regiondata;
rv3d->viewlock= RV3D_LOCKED; rv3d->view= RV3D_VIEW_FRONT; rv3d->persp= RV3D_ORTHO;
if (rv3d->localvd) { rv3d->localvd->view = rv3d->view; rv3d->localvd->persp = rv3d->persp; }
ED_view3d_lock(rv3d);
if (rv3d->localvd) { rv3d->localvd->view = rv3d->view; rv3d->localvd->persp = rv3d->persp; copy_qt_qt(rv3d->localvd->viewquat, rv3d->viewquat);}
ar= ar->next;
rv3d= ar->regiondata;
rv3d->viewlock= RV3D_LOCKED; rv3d->view= RV3D_VIEW_TOP; rv3d->persp= RV3D_ORTHO;
if (rv3d->localvd) { rv3d->localvd->view = rv3d->view; rv3d->localvd->persp = rv3d->persp; }
ED_view3d_lock(rv3d);
if (rv3d->localvd) { rv3d->localvd->view = rv3d->view; rv3d->localvd->persp = rv3d->persp; copy_qt_qt(rv3d->localvd->viewquat, rv3d->viewquat);}
ar= ar->next;
rv3d= ar->regiondata;
rv3d->viewlock= RV3D_LOCKED; rv3d->view= RV3D_VIEW_RIGHT; rv3d->persp= RV3D_ORTHO;
if (rv3d->localvd) { rv3d->localvd->view = rv3d->view; rv3d->localvd->persp = rv3d->persp; }
ED_view3d_lock(rv3d);
if (rv3d->localvd) { rv3d->localvd->view = rv3d->view; rv3d->localvd->persp = rv3d->persp; copy_qt_qt(rv3d->localvd->viewquat, rv3d->viewquat);}
ar= ar->next;
rv3d= ar->regiondata;
rv3d->view= RV3D_VIEW_CAMERA; rv3d->persp= RV3D_CAMOB;
if (rv3d->localvd) {rv3d->localvd->view = rv3d->view; rv3d->localvd->persp = rv3d->persp; }
ED_view3d_lock(rv3d);
if (rv3d->localvd) {rv3d->localvd->view = rv3d->view; rv3d->localvd->persp = rv3d->persp; copy_qt_qt(rv3d->localvd->viewquat, rv3d->viewquat);}
}
ED_area_tag_redraw(sa);
WM_event_add_notifier(C, NC_SCREEN|NA_EDITED, NULL);

@ -1179,33 +1179,37 @@ static void obmat_to_viewmat(View3D *v3d, RegionView3D *rv3d, Object *ob, short
#define QUATSET(a, b, c, d, e) a[0]=b; a[1]=c; a[2]=d; a[3]=e;
static void view3d_viewlock(RegionView3D *rv3d)
int ED_view3d_lock(RegionView3D *rv3d)
{
switch(rv3d->view) {
case RV3D_VIEW_BOTTOM :
QUATSET(rv3d->viewquat,0.0, -1.0, 0.0, 0.0);
break;
case RV3D_VIEW_BACK:
QUATSET(rv3d->viewquat,0.0, 0.0, (float)-cos(M_PI/4.0), (float)-cos(M_PI/4.0));
break;
case RV3D_VIEW_LEFT:
QUATSET(rv3d->viewquat,0.5, -0.5, 0.5, 0.5);
break;
case RV3D_VIEW_TOP:
QUATSET(rv3d->viewquat,1.0, 0.0, 0.0, 0.0);
break;
case RV3D_VIEW_FRONT:
QUATSET(rv3d->viewquat,(float)cos(M_PI/4.0), (float)-sin(M_PI/4.0), 0.0, 0.0);
break;
case RV3D_VIEW_RIGHT:
QUATSET(rv3d->viewquat, 0.5, -0.5, -0.5, -0.5);
break;
default:
return FALSE;
}
return TRUE;
}
/* dont set windows active in in here, is used by renderwin too */
@ -1224,7 +1228,7 @@ void setviewmatrixview3d(Scene *scene, View3D *v3d, RegionView3D *rv3d)
else {
/* should be moved to better initialize later on XXX */
if(rv3d->viewlock)
view3d_viewlock(rv3d);
ED_view3d_lock(rv3d);
quat_to_mat4( rv3d->viewmat,rv3d->viewquat);
if(rv3d->persp==RV3D_PERSP) rv3d->viewmat[3][2]-= rv3d->dist;

@ -112,7 +112,7 @@ typedef struct RegionView3D {
struct bGPdata *gpd; /* Grease-Pencil Data (annotation layers) */
struct RegionView3D *localvd;
struct RegionView3D *localvd; /* allocated backup of its self while in localview */
struct RenderInfo *ri;
struct ViewDepths *depths;
@ -151,7 +151,7 @@ typedef struct View3D {
struct ListBase bgpicbase;
struct BGpic *bgpic; /* deprecated, use bgpicbase, only kept for do_versions(...) */
struct View3D *localvd;
struct View3D *localvd; /* allocated backup of its self while in localview */
char ob_centre_bone[32]; /* optional string for armature bone to define center */