diff options
author | Campbell Barton <ideasman42@gmail.com> | 2011-04-28 11:55:29 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2011-04-28 11:55:29 +0400 |
commit | 49238a323de8d901296cd7c8e5090911c9962168 (patch) | |
tree | 5217d7021b52e5b778038bc7520b8f8449b67d1a /source/blender/editors | |
parent | d97a1da261169d9e64c83ebc26f0460907e007d4 (diff) |
smooth view now takes the v3d and region as arguments. (no functional change)
Diffstat (limited to 'source/blender/editors')
-rw-r--r-- | source/blender/editors/space_view3d/view3d_edit.c | 26 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_intern.h | 2 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_view.c | 30 |
3 files changed, 32 insertions, 26 deletions
diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index 56aae79f145..fe90b8daa97 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -1635,10 +1635,10 @@ static int view3d_all_exec(bContext *C, wmOperator *op) /* was view3d_home() in if (rv3d->persp==RV3D_CAMOB) { rv3d->persp= RV3D_PERSP; - smooth_view(C, v3d->camera, NULL, new_ofs, NULL, &new_dist, NULL); + smooth_view(C, v3d, ar, v3d->camera, NULL, new_ofs, NULL, &new_dist, NULL); } else { - smooth_view(C, NULL, NULL, new_ofs, NULL, &new_dist, NULL); + smooth_view(C, v3d, ar, NULL, NULL, new_ofs, NULL, &new_dist, NULL); } } // XXX BIF_view3d_previewrender_signal(curarea, PR_DBASE|PR_DISPRECT); @@ -1778,10 +1778,10 @@ static int viewselected_exec(bContext *C, wmOperator *UNUSED(op)) /* like a loca if (rv3d->persp==RV3D_CAMOB) { rv3d->persp= RV3D_PERSP; - smooth_view(C, v3d->camera, NULL, new_ofs, NULL, &new_dist, NULL); + smooth_view(C, v3d, ar, v3d->camera, NULL, new_ofs, NULL, &new_dist, NULL); } else { - smooth_view(C, NULL, NULL, new_ofs, NULL, ok_dist ? &new_dist : NULL, NULL); + smooth_view(C, v3d, ar, NULL, NULL, new_ofs, NULL, ok_dist ? &new_dist : NULL, NULL); } /* smooth view does viewlock RV3D_BOXVIEW copy */ @@ -1814,10 +1814,12 @@ static int viewcenter_cursor_exec(bContext *C, wmOperator *UNUSED(op)) Scene *scene= CTX_data_scene(C); if (rv3d) { + ARegion *ar= CTX_wm_region(C); + /* non camera center */ float new_ofs[3]; negate_v3_v3(new_ofs, give_cursor(scene, v3d)); - smooth_view(C, NULL, NULL, new_ofs, NULL, NULL, NULL); + smooth_view(C, v3d, ar, NULL, NULL, new_ofs, NULL, NULL, NULL); /* smooth view does viewlock RV3D_BOXVIEW copy */ } @@ -2047,7 +2049,7 @@ static int view3d_zoom_border_exec(bContext *C, wmOperator *op) new_dist = ((new_dist*scale) >= 0.001f * v3d->grid)? new_dist*scale:0.001f * v3d->grid; } - smooth_view(C, NULL, NULL, new_ofs, NULL, &new_dist, NULL); + smooth_view(C, v3d, ar, NULL, NULL, new_ofs, NULL, &new_dist, NULL); if(rv3d->viewlock & RV3D_BOXVIEW) view3d_boxview_sync(CTX_wm_area(C), ar); @@ -2149,6 +2151,7 @@ static EnumPropertyItem prop_view_items[] = { static void axis_set_view(bContext *C, float q1, float q2, float q3, float q4, short view, int perspo, int align_active) { View3D *v3d = CTX_wm_view3d(C); + ARegion *ar= CTX_wm_region(C); RegionView3D *rv3d= CTX_wm_region_view3d(C); float new_quat[4]; @@ -2194,7 +2197,7 @@ static void axis_set_view(bContext *C, float q1, float q2, float q3, float q4, s } if(rv3d->viewlock) { - ED_region_tag_redraw(CTX_wm_region(C)); + ED_region_tag_redraw(ar); return; } @@ -2203,14 +2206,14 @@ static void axis_set_view(bContext *C, float q1, float q2, float q3, float q4, s if (U.uiflag & USER_AUTOPERSP) rv3d->persp= view ? RV3D_ORTHO : RV3D_PERSP; else if(rv3d->persp==RV3D_CAMOB) rv3d->persp= perspo; - smooth_view(C, v3d->camera, NULL, rv3d->ofs, new_quat, NULL, NULL); + smooth_view(C, v3d, ar, v3d->camera, NULL, rv3d->ofs, new_quat, NULL, NULL); } else { if (U.uiflag & USER_AUTOPERSP) rv3d->persp= view ? RV3D_ORTHO : RV3D_PERSP; else if(rv3d->persp==RV3D_CAMOB) rv3d->persp= perspo; - smooth_view(C, NULL, NULL, NULL, new_quat, NULL, NULL); + smooth_view(C, v3d, ar, NULL, NULL, NULL, new_quat, NULL, NULL); } } @@ -2218,6 +2221,7 @@ static void axis_set_view(bContext *C, float q1, float q2, float q3, float q4, s static int viewnumpad_exec(bContext *C, wmOperator *op) { View3D *v3d = CTX_wm_view3d(C); + ARegion *ar= CTX_wm_region(C); RegionView3D *rv3d= CTX_wm_region_view3d(C); Scene *scene= CTX_data_scene(C); static int perspo=RV3D_PERSP; @@ -2316,7 +2320,7 @@ static int viewnumpad_exec(bContext *C, wmOperator *op) /* finally do snazzy view zooming */ rv3d->persp= RV3D_CAMOB; - smooth_view(C, NULL, v3d->camera, rv3d->ofs, rv3d->viewquat, &rv3d->dist, &v3d->lens); + smooth_view(C, v3d, ar, NULL, v3d->camera, rv3d->ofs, rv3d->viewquat, &rv3d->dist, &v3d->lens); } else{ @@ -2398,7 +2402,7 @@ static int vieworbit_exec(bContext *C, wmOperator *op) rv3d->view= 0; } - smooth_view(C, NULL, NULL, NULL, new_quat, NULL, NULL); + smooth_view(C, CTX_wm_view3d(C), CTX_wm_region(C), NULL, NULL, NULL, new_quat, NULL, NULL); } } diff --git a/source/blender/editors/space_view3d/view3d_intern.h b/source/blender/editors/space_view3d/view3d_intern.h index a3b9188ab81..717e46800b1 100644 --- a/source/blender/editors/space_view3d/view3d_intern.h +++ b/source/blender/editors/space_view3d/view3d_intern.h @@ -158,7 +158,7 @@ int boundbox_clip(RegionView3D *rv3d, float obmat[][4], struct BoundBox *bb); void centerview(struct ARegion *ar, View3D *v3d); -void smooth_view(struct bContext *C, struct Object *, struct Object *, float *ofs, float *quat, float *dist, float *lens); +void smooth_view(struct bContext *C, struct View3D *v3d, struct ARegion *ar, struct Object *, struct Object *, float *ofs, float *quat, float *dist, float *lens); void setwinmatrixview3d(ARegion *ar, View3D *v3d, rctf *rect); /* rect: for picking */ void setviewmatrixview3d(Scene *scene, View3D *v3d, RegionView3D *rv3d); diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c index ccf250c53b6..faec04917a0 100644 --- a/source/blender/editors/space_view3d/view3d_view.c +++ b/source/blender/editors/space_view3d/view3d_view.c @@ -190,10 +190,13 @@ struct SmoothViewStore { /* will start timer if appropriate */ /* the arguments are the desired situation */ -void smooth_view(bContext *C, Object *oldcamera, Object *camera, float *ofs, float *quat, float *dist, float *lens) +void smooth_view(bContext *C, View3D *v3d, ARegion *ar, Object *oldcamera, Object *camera, float *ofs, float *quat, float *dist, float *lens) { - View3D *v3d = CTX_wm_view3d(C); - RegionView3D *rv3d= CTX_wm_region_view3d(C); + wmWindowManager *wm= CTX_wm_manager(C); + wmWindow *win= CTX_wm_window(C); + ScrArea *sa= CTX_wm_area(C); + + RegionView3D *rv3d= ar->regiondata; struct SmoothViewStore sms= {0}; short ok= FALSE; @@ -281,9 +284,9 @@ void smooth_view(bContext *C, Object *oldcamera, Object *camera, float *ofs, flo rv3d->sms= MEM_mallocN(sizeof(struct SmoothViewStore), "smoothview v3d"); *rv3d->sms= sms; if(rv3d->smooth_timer) - WM_event_remove_timer(CTX_wm_manager(C), CTX_wm_window(C), rv3d->smooth_timer); + WM_event_remove_timer(wm, win, rv3d->smooth_timer); /* 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 */ + rv3d->smooth_timer= WM_event_add_timer(wm, win, TIMER1, 1.0/100.0); /* max 30 frs/sec */ ok= TRUE; } @@ -291,8 +294,6 @@ void smooth_view(bContext *C, Object *oldcamera, Object *camera, float *ofs, flo /* if we get here nothing happens */ 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); @@ -301,7 +302,7 @@ void smooth_view(bContext *C, Object *oldcamera, Object *camera, float *ofs, flo } if(rv3d->viewlock & RV3D_BOXVIEW) - view3d_boxview_copy(CTX_wm_area(C), ar); + view3d_boxview_copy(sa, ar); ED_region_tag_redraw(ar); } @@ -465,7 +466,8 @@ void VIEW3D_OT_setcameratoview(wmOperatorType *ot) static int view3d_setobjectascamera_exec(bContext *C, wmOperator *UNUSED(op)) { View3D *v3d = CTX_wm_view3d(C); - RegionView3D *rv3d= CTX_wm_region_view3d(C); + ARegion *ar= CTX_wm_region(C); + RegionView3D *rv3d= ar->regiondata; Scene *scene= CTX_data_scene(C); Object *ob = CTX_data_active_object(C); @@ -477,7 +479,7 @@ static int view3d_setobjectascamera_exec(bContext *C, wmOperator *UNUSED(op)) scene->camera= ob; if(camera_old != ob) /* unlikely but looks like a glitch when set to the same */ - smooth_view(C, camera_old, v3d->camera, rv3d->ofs, rv3d->viewquat, &rv3d->dist, &v3d->lens); + smooth_view(C, v3d, ar, camera_old, v3d->camera, rv3d->ofs, rv3d->viewquat, &rv3d->dist, &v3d->lens); WM_event_add_notifier(C, NC_SCENE|ND_RENDER_OPTIONS|NC_OBJECT|ND_DRAW, CTX_data_scene(C)); } @@ -1189,13 +1191,13 @@ static void obmat_to_viewmat(View3D *v3d, RegionView3D *rv3d, Object *ob, short rv3d->dist= 0.0; view3d_apply_ob(v3d->camera, rv3d->ofs, NULL, NULL, &v3d->lens); - smooth_view(NULL, NULL, NULL, orig_ofs, new_quat, &orig_dist, &orig_lens); // XXX + smooth_view(NULL, NULL, NULL, NULL, NULL, orig_ofs, new_quat, &orig_dist, &orig_lens); // XXX rv3d->persp=RV3D_CAMOB; /* just to be polite, not needed */ } else { mat3_to_quat( new_quat,tmat); - smooth_view(NULL, NULL, NULL, NULL, new_quat, NULL, NULL); // XXX + smooth_view(NULL, NULL, NULL, NULL, NULL, NULL, new_quat, NULL, NULL); // XXX } } else { mat3_to_quat( rv3d->viewquat,tmat); @@ -1932,10 +1934,10 @@ void view3d_align_axis_to_vector(View3D *v3d, RegionView3D *rv3d, int axisidx, f rv3d->persp= RV3D_PERSP; rv3d->dist= 0.0; view3d_apply_ob(v3d->camera, rv3d->ofs, NULL, NULL, &v3d->lens); - smooth_view(NULL, NULL, NULL, orig_ofs, new_quat, &orig_dist, &orig_lens); // XXX + smooth_view(NULL, NULL, NULL, NULL, NULL, orig_ofs, new_quat, &orig_dist, &orig_lens); // XXX } else { if (rv3d->persp==RV3D_CAMOB) rv3d->persp= RV3D_PERSP; /* switch out of camera mode */ - smooth_view(NULL, NULL, NULL, NULL, new_quat, NULL, NULL); // XXX + smooth_view(NULL, NULL, NULL, NULL, NULL, NULL, new_quat, NULL, NULL); // XXX } } |