Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/space_view3d/view3d_view.c
| Show First 20 Lines • Show All 298 Lines • ▼ Show 20 Lines | |||||
| } | } | ||||
| void ED_view3d_smooth_view(bContext *C, | void ED_view3d_smooth_view(bContext *C, | ||||
| View3D *v3d, | View3D *v3d, | ||||
| ARegion *ar, | ARegion *ar, | ||||
| const int smooth_viewtx, | const int smooth_viewtx, | ||||
| const struct V3D_SmoothParams *sview) | const struct V3D_SmoothParams *sview) | ||||
| { | { | ||||
| const Depsgraph *depsgraph = CTX_data_depsgraph(C); | const Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); | ||||
| wmWindowManager *wm = CTX_wm_manager(C); | wmWindowManager *wm = CTX_wm_manager(C); | ||||
| wmWindow *win = CTX_wm_window(C); | wmWindow *win = CTX_wm_window(C); | ||||
| ScrArea *sa = CTX_wm_area(C); | ScrArea *sa = CTX_wm_area(C); | ||||
| ED_view3d_smooth_view_ex(depsgraph, wm, win, sa, v3d, ar, smooth_viewtx, sview); | ED_view3d_smooth_view_ex(depsgraph, wm, win, sa, v3d, ar, smooth_viewtx, sview); | ||||
| } | } | ||||
| /* only meant for timer usage */ | /* only meant for timer usage */ | ||||
| static void view3d_smoothview_apply(bContext *C, View3D *v3d, ARegion *ar, bool sync_boxview) | static void view3d_smoothview_apply(bContext *C, View3D *v3d, ARegion *ar, bool sync_boxview) | ||||
| { | { | ||||
| const Depsgraph *depsgraph = CTX_data_depsgraph(C); | |||||
| RegionView3D *rv3d = ar->regiondata; | RegionView3D *rv3d = ar->regiondata; | ||||
| struct SmoothView3DStore *sms = rv3d->sms; | struct SmoothView3DStore *sms = rv3d->sms; | ||||
| float step, step_inv; | float step, step_inv; | ||||
| if (sms->time_allowed != 0.0) { | if (sms->time_allowed != 0.0) { | ||||
| step = (float)((rv3d->smooth_timer->duration) / sms->time_allowed); | step = (float)((rv3d->smooth_timer->duration) / sms->time_allowed); | ||||
| } | } | ||||
| else { | else { | ||||
| step = 1.0f; | step = 1.0f; | ||||
| } | } | ||||
| /* end timer */ | /* end timer */ | ||||
| if (step >= 1.0f) { | if (step >= 1.0f) { | ||||
| /* if we went to camera, store the original */ | /* if we went to camera, store the original */ | ||||
| if (sms->to_camera) { | if (sms->to_camera) { | ||||
| rv3d->persp = RV3D_CAMOB; | rv3d->persp = RV3D_CAMOB; | ||||
| view3d_smooth_view_state_restore(&sms->org, v3d, rv3d); | view3d_smooth_view_state_restore(&sms->org, v3d, rv3d); | ||||
| } | } | ||||
| else { | else { | ||||
| const Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); | |||||
| view3d_smooth_view_state_restore(&sms->dst, v3d, rv3d); | view3d_smooth_view_state_restore(&sms->dst, v3d, rv3d); | ||||
| ED_view3d_camera_lock_sync(depsgraph, v3d, rv3d); | ED_view3d_camera_lock_sync(depsgraph, v3d, rv3d); | ||||
| ED_view3d_camera_lock_autokey(v3d, rv3d, C, true, true); | ED_view3d_camera_lock_autokey(v3d, rv3d, C, true, true); | ||||
| } | } | ||||
| if ((rv3d->viewlock & RV3D_LOCKED) == 0) { | if ((rv3d->viewlock & RV3D_LOCKED) == 0) { | ||||
| rv3d->view = sms->org_view; | rv3d->view = sms->org_view; | ||||
| Show All 20 Lines | else { | ||||
| } | } | ||||
| else { | else { | ||||
| interp_v3_v3v3(rv3d->ofs, sms->src.ofs, sms->dst.ofs, step); | interp_v3_v3v3(rv3d->ofs, sms->src.ofs, sms->dst.ofs, step); | ||||
| } | } | ||||
| rv3d->dist = sms->dst.dist * step + sms->src.dist * step_inv; | rv3d->dist = sms->dst.dist * step + sms->src.dist * step_inv; | ||||
| v3d->lens = sms->dst.lens * step + sms->src.lens * step_inv; | v3d->lens = sms->dst.lens * step + sms->src.lens * step_inv; | ||||
| const Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); | |||||
| ED_view3d_camera_lock_sync(depsgraph, v3d, rv3d); | ED_view3d_camera_lock_sync(depsgraph, v3d, rv3d); | ||||
| if (ED_screen_animation_playing(CTX_wm_manager(C))) { | if (ED_screen_animation_playing(CTX_wm_manager(C))) { | ||||
| ED_view3d_camera_lock_autokey(v3d, rv3d, C, true, true); | ED_view3d_camera_lock_autokey(v3d, rv3d, C, true, true); | ||||
| } | } | ||||
| /* Event handling won't know if a UI item has been moved under the pointer. */ | /* Event handling won't know if a UI item has been moved under the pointer. */ | ||||
| WM_event_add_mousemove(C); | WM_event_add_mousemove(C); | ||||
| } | } | ||||
| Show All 40 Lines | void ED_view3d_smooth_view_force_finish(bContext *C, View3D *v3d, ARegion *ar) | ||||
| RegionView3D *rv3d = ar->regiondata; | RegionView3D *rv3d = ar->regiondata; | ||||
| if (rv3d && rv3d->sms) { | if (rv3d && rv3d->sms) { | ||||
| rv3d->sms->time_allowed = 0.0; /* force finishing */ | rv3d->sms->time_allowed = 0.0; /* force finishing */ | ||||
| view3d_smoothview_apply(C, v3d, ar, false); | view3d_smoothview_apply(C, v3d, ar, false); | ||||
| /* force update of view matrix so tools that run immediately after | /* force update of view matrix so tools that run immediately after | ||||
| * can use them without redrawing first */ | * can use them without redrawing first */ | ||||
| Depsgraph *depsgraph = CTX_data_depsgraph(C); | Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); | ||||
| Scene *scene = CTX_data_scene(C); | Scene *scene = CTX_data_scene(C); | ||||
| ED_view3d_update_viewmat(depsgraph, scene, v3d, ar, NULL, NULL, NULL, false); | ED_view3d_update_viewmat(depsgraph, scene, v3d, ar, NULL, NULL, NULL, false); | ||||
| } | } | ||||
| } | } | ||||
| void VIEW3D_OT_smoothview(wmOperatorType *ot) | void VIEW3D_OT_smoothview(wmOperatorType *ot) | ||||
| { | { | ||||
| /* identifiers */ | /* identifiers */ | ||||
| Show All 12 Lines | |||||
| /** \} */ | /** \} */ | ||||
| /* -------------------------------------------------------------------- */ | /* -------------------------------------------------------------------- */ | ||||
| /** \name Camera to View Operator | /** \name Camera to View Operator | ||||
| * \{ */ | * \{ */ | ||||
| static int view3d_camera_to_view_exec(bContext *C, wmOperator *UNUSED(op)) | static int view3d_camera_to_view_exec(bContext *C, wmOperator *UNUSED(op)) | ||||
| { | { | ||||
| const Depsgraph *depsgraph = CTX_data_depsgraph(C); | const Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); | ||||
| View3D *v3d; | View3D *v3d; | ||||
| ARegion *ar; | ARegion *ar; | ||||
| RegionView3D *rv3d; | RegionView3D *rv3d; | ||||
| ObjectTfmProtectedChannels obtfm; | ObjectTfmProtectedChannels obtfm; | ||||
| ED_view3d_context_user_region(C, &v3d, &ar); | ED_view3d_context_user_region(C, &v3d, &ar); | ||||
| rv3d = ar->regiondata; | rv3d = ar->regiondata; | ||||
| ▲ Show 20 Lines • Show All 53 Lines • ▼ Show 20 Lines | |||||
| /* -------------------------------------------------------------------- */ | /* -------------------------------------------------------------------- */ | ||||
| /** \name Camera Fit Frame to Selected Operator | /** \name Camera Fit Frame to Selected Operator | ||||
| * \{ */ | * \{ */ | ||||
| /* unlike VIEW3D_OT_view_selected this is for framing a render and not | /* unlike VIEW3D_OT_view_selected this is for framing a render and not | ||||
| * meant to take into account vertex/bone selection for eg. */ | * meant to take into account vertex/bone selection for eg. */ | ||||
| static int view3d_camera_to_view_selected_exec(bContext *C, wmOperator *op) | static int view3d_camera_to_view_selected_exec(bContext *C, wmOperator *op) | ||||
| { | { | ||||
| Depsgraph *depsgraph = CTX_data_depsgraph(C); | Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); | ||||
| Scene *scene = CTX_data_scene(C); | Scene *scene = CTX_data_scene(C); | ||||
| View3D *v3d = CTX_wm_view3d(C); /* can be NULL */ | View3D *v3d = CTX_wm_view3d(C); /* can be NULL */ | ||||
| Object *camera_ob = v3d ? v3d->camera : scene->camera; | Object *camera_ob = v3d ? v3d->camera : scene->camera; | ||||
| Object *camera_ob_eval = DEG_get_evaluated_object(depsgraph, camera_ob); | Object *camera_ob_eval = DEG_get_evaluated_object(depsgraph, camera_ob); | ||||
| float r_co[3]; /* the new location to apply */ | float r_co[3]; /* the new location to apply */ | ||||
| float r_scale; /* only for ortho cameras */ | float r_scale; /* only for ortho cameras */ | ||||
| ▲ Show 20 Lines • Show All 869 Lines • ▼ Show 20 Lines | if (ar->regiontype == RGN_TYPE_WINDOW) { | ||||
| MEM_freeN(rv3d->localvd); | MEM_freeN(rv3d->localvd); | ||||
| rv3d->localvd = NULL; | rv3d->localvd = NULL; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| static int localview_exec(bContext *C, wmOperator *op) | static int localview_exec(bContext *C, wmOperator *op) | ||||
| { | { | ||||
| const Depsgraph *depsgraph = CTX_data_depsgraph(C); | const Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); | ||||
| const int smooth_viewtx = WM_operator_smooth_viewtx_get(op); | const int smooth_viewtx = WM_operator_smooth_viewtx_get(op); | ||||
| wmWindowManager *wm = CTX_wm_manager(C); | wmWindowManager *wm = CTX_wm_manager(C); | ||||
| wmWindow *win = CTX_wm_window(C); | wmWindow *win = CTX_wm_window(C); | ||||
| Main *bmain = CTX_data_main(C); | Main *bmain = CTX_data_main(C); | ||||
| Scene *scene = CTX_data_scene(C); | Scene *scene = CTX_data_scene(C); | ||||
| ViewLayer *view_layer = CTX_data_view_layer(C); | ViewLayer *view_layer = CTX_data_view_layer(C); | ||||
| ScrArea *sa = CTX_wm_area(C); | ScrArea *sa = CTX_wm_area(C); | ||||
| View3D *v3d = CTX_wm_view3d(C); | View3D *v3d = CTX_wm_view3d(C); | ||||
| ▲ Show 20 Lines • Show All 110 Lines • Show Last 20 Lines | |||||