fix for glitches with quad-split view.

- Home or Numpad Period with smoothview disabled were not syncing up the other views.
- Disabling clip only disabled clip syncing but left clip enabled for all views.
- Clip was being calculated for every update even when not enabled.
- The perspective view was being used to copy settings from when changing box & clip settings, resetting the distance each time. Now use one of the aligned views instead.
This commit is contained in:
Campbell Barton 2010-11-08 03:44:52 +00:00
parent c300d58497
commit 85b9652258
4 changed files with 62 additions and 17 deletions

@ -167,7 +167,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);
void ED_view3d_quadview_update(struct ScrArea *sa, struct ARegion *ar, short do_clip);
#endif /* ED_VIEW3D_H */

@ -159,6 +159,7 @@ static void view3d_boxview_sync(ScrArea *sa, ARegion *ar)
{
ARegion *artest;
RegionView3D *rv3d= ar->regiondata;
short clip= 0;
for(artest= sa->regionbase.first; artest; artest= artest->next) {
if(artest!=ar && artest->regiontype==RGN_TYPE_WINDOW) {
@ -186,11 +187,16 @@ static void view3d_boxview_sync(ScrArea *sa, ARegion *ar)
rv3dtest->ofs[2]= rv3d->ofs[2];
}
clip |= rv3dtest->viewlock & RV3D_BOXCLIP;
ED_region_tag_redraw(artest);
}
}
}
view3d_boxview_clip(sa);
if(clip) {
view3d_boxview_clip(sa);
}
}
/* for home, center etc */
@ -198,6 +204,7 @@ void view3d_boxview_copy(ScrArea *sa, ARegion *ar)
{
ARegion *artest;
RegionView3D *rv3d= ar->regiondata;
short clip= 0;
for(artest= sa->regionbase.first; artest; artest= artest->next) {
if(artest!=ar && artest->regiontype==RGN_TYPE_WINDOW) {
@ -207,17 +214,23 @@ void view3d_boxview_copy(ScrArea *sa, ARegion *ar)
rv3dtest->dist= rv3d->dist;
copy_v3_v3(rv3dtest->ofs, rv3d->ofs);
ED_region_tag_redraw(artest);
clip |= rv3dtest->viewlock & RV3D_BOXCLIP;
}
}
}
view3d_boxview_clip(sa);
if(clip) {
view3d_boxview_clip(sa);
}
}
void ED_view3d_quadview_update(ScrArea *sa, ARegion *ar)
/* 'clip' is used to know if our clip setting has changed */
void ED_view3d_quadview_update(ScrArea *sa, ARegion *ar, short do_clip)
{
ARegion *arsync= NULL;
RegionView3D *rv3d= ar->regiondata;
short viewlock;
/* this function copies flags from the first of the 3 other quadview
regions to the 2 other, so it assumes this is the region whose
properties are always being edited, weak */
@ -225,18 +238,30 @@ void ED_view3d_quadview_update(ScrArea *sa, ARegion *ar)
if((viewlock & RV3D_LOCKED)==0)
viewlock= 0;
else if((viewlock & RV3D_BOXVIEW)==0)
else if((viewlock & RV3D_BOXVIEW)==0) {
viewlock &= ~RV3D_BOXCLIP;
do_clip= TRUE;
}
for(; ar; ar= ar->prev) {
if(ar->alignment==RGN_ALIGN_QSPLIT) {
rv3d= ar->regiondata;
rv3d->viewlock= viewlock;
if(do_clip && (viewlock & RV3D_BOXCLIP)==0) {
rv3d->rflag &= ~RV3D_BOXCLIP;
}
/* use arsync so we sync with one of the aligned views below
* else the view jumps on changing view settings like 'clip'
* since it copies from the perspective view */
arsync= ar;
}
}
if(rv3d->viewlock & RV3D_BOXVIEW)
view3d_boxview_copy(sa, sa->regionbase.last);
if(rv3d->viewlock & RV3D_BOXVIEW) {
view3d_boxview_copy(sa, arsync ? arsync : sa->regionbase.last);
}
ED_area_tag_redraw(sa);
}

@ -180,6 +180,7 @@ void smooth_view(bContext *C, Object *oldcamera, Object *camera, float *ofs, flo
View3D *v3d = CTX_wm_view3d(C);
RegionView3D *rv3d= CTX_wm_region_view3d(C);
struct SmoothViewStore sms= {0};
short ok= FALSE;
/* initialize sms */
copy_v3_v3(sms.new_ofs, rv3d->ofs);
@ -269,18 +270,26 @@ void smooth_view(bContext *C, Object *oldcamera, Object *camera, float *ofs, flo
/* TIMER1 is hardcoded in keymap */
rv3d->smooth_timer= WM_event_add_timer(CTX_wm_manager(C), CTX_wm_window(C), TIMER1, 1.0/100.0); /* max 30 frs/sec */
return;
ok= TRUE;
}
}
/* if we get here nothing happens */
if(sms.to_camera==0) {
copy_v3_v3(rv3d->ofs, sms.new_ofs);
copy_qt_qt(rv3d->viewquat, sms.new_quat);
rv3d->dist = sms.new_dist;
v3d->lens = sms.new_lens;
if(ok == FALSE) {
ARegion *ar= CTX_wm_region(C);
if(sms.to_camera==0) {
copy_v3_v3(rv3d->ofs, sms.new_ofs);
copy_qt_qt(rv3d->viewquat, sms.new_quat);
rv3d->dist = sms.new_dist;
v3d->lens = sms.new_lens;
}
if(rv3d->viewlock & RV3D_BOXVIEW)
view3d_boxview_copy(CTX_wm_area(C), ar);
ED_region_tag_redraw(ar);
}
ED_region_tag_redraw(CTX_wm_region(C));
}
/* only meant for timer usage */

@ -348,7 +348,18 @@ static void rna_RegionView3D_quadview_update(Main *main, Scene *scene, PointerRN
rna_area_region_from_regiondata(ptr, &sa, &ar);
if(sa && ar && ar->alignment==RGN_ALIGN_QSPLIT)
ED_view3d_quadview_update(sa, ar);
ED_view3d_quadview_update(sa, ar, FALSE);
}
/* same as above but call clip==TRUE */
static void rna_RegionView3D_quadview_clip_update(Main *main, Scene *scene, PointerRNA *ptr)
{
ScrArea *sa;
ARegion *ar;
rna_area_region_from_regiondata(ptr, &sa, &ar);
if(sa && ar && ar->alignment==RGN_ALIGN_QSPLIT)
ED_view3d_quadview_update(sa, ar, TRUE);
}
static void rna_RegionView3D_view_location_get(PointerRNA *ptr, float *values)
@ -1246,7 +1257,7 @@ static void rna_def_space_view3d(BlenderRNA *brna)
prop= RNA_def_property(srna, "use_box_clip", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "viewlock", RV3D_BOXCLIP);
RNA_def_property_ui_text(prop, "Clip", "Clip objects based on what's visible in other side views");
RNA_def_property_update(prop, NC_SPACE|ND_SPACE_VIEW3D, "rna_RegionView3D_quadview_update");
RNA_def_property_update(prop, NC_SPACE|ND_SPACE_VIEW3D, "rna_RegionView3D_quadview_clip_update");
prop= RNA_def_property(srna, "perspective_matrix", PROP_FLOAT, PROP_MATRIX);
RNA_def_property_float_sdna(prop, NULL, "persmat");