Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/space_view3d/view3d_edit.c
| Show First 20 Lines • Show All 213 Lines • ▼ Show 20 Lines | |||||
| */ | */ | ||||
| static void viewops_data_alloc(bContext *C, wmOperator *op) | static void viewops_data_alloc(bContext *C, wmOperator *op) | ||||
| { | { | ||||
| ViewOpsData *vod = MEM_callocN(sizeof(ViewOpsData), "viewops data"); | ViewOpsData *vod = MEM_callocN(sizeof(ViewOpsData), "viewops data"); | ||||
| /* store data */ | /* store data */ | ||||
| op->customdata = vod; | op->customdata = vod; | ||||
| vod->bmain = CTX_data_main(C); | vod->bmain = CTX_data_main(C); | ||||
| vod->depsgraph = CTX_data_depsgraph(C); | vod->depsgraph = CTX_data_ensure_evaluated_depsgraph(C); | ||||
| vod->scene = CTX_data_scene(C); | vod->scene = CTX_data_scene(C); | ||||
| vod->sa = CTX_wm_area(C); | vod->sa = CTX_wm_area(C); | ||||
| vod->ar = CTX_wm_region(C); | vod->ar = CTX_wm_region(C); | ||||
| vod->v3d = vod->sa->spacedata.first; | vod->v3d = vod->sa->spacedata.first; | ||||
| vod->rv3d = vod->ar->regiondata; | vod->rv3d = vod->ar->regiondata; | ||||
| } | } | ||||
| void view3d_orbit_apply_dyn_ofs(float r_ofs[3], | void view3d_orbit_apply_dyn_ofs(float r_ofs[3], | ||||
| Show All 13 Lines | void view3d_orbit_apply_dyn_ofs(float r_ofs[3], | ||||
| add_v3_v3(r_ofs, dyn_ofs); | add_v3_v3(r_ofs, dyn_ofs); | ||||
| } | } | ||||
| static bool view3d_orbit_calc_center(bContext *C, float r_dyn_ofs[3]) | static bool view3d_orbit_calc_center(bContext *C, float r_dyn_ofs[3]) | ||||
| { | { | ||||
| static float lastofs[3] = {0, 0, 0}; | static float lastofs[3] = {0, 0, 0}; | ||||
| bool is_set = false; | bool is_set = false; | ||||
| const Depsgraph *depsgraph = CTX_data_depsgraph(C); | const Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); | ||||
| Scene *scene = CTX_data_scene(C); | Scene *scene = CTX_data_scene(C); | ||||
| ViewLayer *view_layer_eval = DEG_get_evaluated_view_layer(depsgraph); | ViewLayer *view_layer_eval = DEG_get_evaluated_view_layer(depsgraph); | ||||
| View3D *v3d = CTX_wm_view3d(C); | View3D *v3d = CTX_wm_view3d(C); | ||||
| Object *ob_act_eval = OBACT(view_layer_eval); | Object *ob_act_eval = OBACT(view_layer_eval); | ||||
| Object *ob_act = DEG_get_original_object(ob_act_eval); | Object *ob_act = DEG_get_original_object(ob_act_eval); | ||||
| if (ob_act && (ob_act->mode & OB_MODE_ALL_PAINT) && | if (ob_act && (ob_act->mode & OB_MODE_ALL_PAINT) && | ||||
| /* with weight-paint + pose-mode, fall through to using calculateTransformCenter */ | /* with weight-paint + pose-mode, fall through to using calculateTransformCenter */ | ||||
| ▲ Show 20 Lines • Show All 107 Lines • ▼ Show 20 Lines | |||||
| /** | /** | ||||
| * Calculate the values for #ViewOpsData | * Calculate the values for #ViewOpsData | ||||
| */ | */ | ||||
| static void viewops_data_create(bContext *C, | static void viewops_data_create(bContext *C, | ||||
| wmOperator *op, | wmOperator *op, | ||||
| const wmEvent *event, | const wmEvent *event, | ||||
| enum eViewOpsFlag viewops_flag) | enum eViewOpsFlag viewops_flag) | ||||
| { | { | ||||
| Depsgraph *depsgraph = CTX_data_depsgraph(C); | Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); | ||||
| ViewOpsData *vod = op->customdata; | ViewOpsData *vod = op->customdata; | ||||
| RegionView3D *rv3d = vod->rv3d; | RegionView3D *rv3d = vod->rv3d; | ||||
| /* Could do this more nicely. */ | /* Could do this more nicely. */ | ||||
| if ((viewops_flag & VIEWOPS_FLAG_USE_MOUSE_INIT) == 0) { | if ((viewops_flag & VIEWOPS_FLAG_USE_MOUSE_INIT) == 0) { | ||||
| viewops_flag &= ~VIEWOPS_FLAG_DEPTH_NAVIGATE; | viewops_flag &= ~VIEWOPS_FLAG_DEPTH_NAVIGATE; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 927 Lines • ▼ Show 20 Lines | |||||
| * \{ */ | * \{ */ | ||||
| static int ndof_orbit_invoke(bContext *C, wmOperator *op, const wmEvent *event) | static int ndof_orbit_invoke(bContext *C, wmOperator *op, const wmEvent *event) | ||||
| { | { | ||||
| if (event->type != NDOF_MOTION) { | if (event->type != NDOF_MOTION) { | ||||
| return OPERATOR_CANCELLED; | return OPERATOR_CANCELLED; | ||||
| } | } | ||||
| const Depsgraph *depsgraph = CTX_data_depsgraph(C); | const Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); | ||||
| ViewOpsData *vod; | ViewOpsData *vod; | ||||
| View3D *v3d; | View3D *v3d; | ||||
| RegionView3D *rv3d; | RegionView3D *rv3d; | ||||
| char xform_flag = 0; | char xform_flag = 0; | ||||
| const wmNDOFMotionData *ndof = event->customdata; | const wmNDOFMotionData *ndof = event->customdata; | ||||
| viewops_data_alloc(C, op); | viewops_data_alloc(C, op); | ||||
| ▲ Show 20 Lines • Show All 63 Lines • ▼ Show 20 Lines | |||||
| * \{ */ | * \{ */ | ||||
| static int ndof_orbit_zoom_invoke(bContext *C, wmOperator *op, const wmEvent *event) | static int ndof_orbit_zoom_invoke(bContext *C, wmOperator *op, const wmEvent *event) | ||||
| { | { | ||||
| if (event->type != NDOF_MOTION) { | if (event->type != NDOF_MOTION) { | ||||
| return OPERATOR_CANCELLED; | return OPERATOR_CANCELLED; | ||||
| } | } | ||||
| const Depsgraph *depsgraph = CTX_data_depsgraph(C); | const Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); | ||||
| ViewOpsData *vod; | ViewOpsData *vod; | ||||
| View3D *v3d; | View3D *v3d; | ||||
| RegionView3D *rv3d; | RegionView3D *rv3d; | ||||
| char xform_flag = 0; | char xform_flag = 0; | ||||
| const wmNDOFMotionData *ndof = event->customdata; | const wmNDOFMotionData *ndof = event->customdata; | ||||
| viewops_data_alloc(C, op); | viewops_data_alloc(C, op); | ||||
| ▲ Show 20 Lines • Show All 97 Lines • ▼ Show 20 Lines | |||||
| * \{ */ | * \{ */ | ||||
| static int ndof_pan_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *event) | static int ndof_pan_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *event) | ||||
| { | { | ||||
| if (event->type != NDOF_MOTION) { | if (event->type != NDOF_MOTION) { | ||||
| return OPERATOR_CANCELLED; | return OPERATOR_CANCELLED; | ||||
| } | } | ||||
| const Depsgraph *depsgraph = CTX_data_depsgraph(C); | const Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); | ||||
| View3D *v3d = CTX_wm_view3d(C); | View3D *v3d = CTX_wm_view3d(C); | ||||
| RegionView3D *rv3d = CTX_wm_region_view3d(C); | RegionView3D *rv3d = CTX_wm_region_view3d(C); | ||||
| const wmNDOFMotionData *ndof = event->customdata; | const wmNDOFMotionData *ndof = event->customdata; | ||||
| char xform_flag = 0; | char xform_flag = 0; | ||||
| const bool has_translate = NDOF_HAS_TRANSLATE; | const bool has_translate = NDOF_HAS_TRANSLATE; | ||||
| const bool has_zoom = (ndof->tvec[2] != 0.0f) && !rv3d->is_persp; | const bool has_zoom = (ndof->tvec[2] != 0.0f) && !rv3d->is_persp; | ||||
| ▲ Show 20 Lines • Show All 660 Lines • ▼ Show 20 Lines | if (ret & OPERATOR_FINISHED) { | ||||
| viewops_data_free(C, op); | viewops_data_free(C, op); | ||||
| } | } | ||||
| return ret; | return ret; | ||||
| } | } | ||||
| static int viewzoom_exec(bContext *C, wmOperator *op) | static int viewzoom_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; | View3D *v3d; | ||||
| RegionView3D *rv3d; | RegionView3D *rv3d; | ||||
| ScrArea *sa; | ScrArea *sa; | ||||
| ARegion *ar; | ARegion *ar; | ||||
| bool use_cam_zoom; | bool use_cam_zoom; | ||||
| float dist_range[2]; | float dist_range[2]; | ||||
| ▲ Show 20 Lines • Show All 348 Lines • ▼ Show 20 Lines | static int viewdolly_exec(bContext *C, wmOperator *op) | ||||
| view_dolly_to_vector_3d(ar, rv3d->ofs, mousevec, delta < 0 ? 0.2f : 1.8f); | view_dolly_to_vector_3d(ar, rv3d->ofs, mousevec, delta < 0 ? 0.2f : 1.8f); | ||||
| if (rv3d->viewlock & RV3D_BOXVIEW) { | if (rv3d->viewlock & RV3D_BOXVIEW) { | ||||
| view3d_boxview_sync(sa, ar); | view3d_boxview_sync(sa, ar); | ||||
| } | } | ||||
| ED_view3d_depth_tag_update(rv3d); | ED_view3d_depth_tag_update(rv3d); | ||||
| ED_view3d_camera_lock_sync(CTX_data_depsgraph(C), v3d, rv3d); | ED_view3d_camera_lock_sync(CTX_data_ensure_evaluated_depsgraph(C), v3d, rv3d); | ||||
| ED_region_tag_redraw(ar); | ED_region_tag_redraw(ar); | ||||
| viewops_data_free(C, op); | viewops_data_free(C, op); | ||||
| return OPERATOR_FINISHED; | return OPERATOR_FINISHED; | ||||
| } | } | ||||
| Show All 18 Lines | static int viewdolly_invoke(bContext *C, wmOperator *op, const wmEvent *event) | ||||
| ED_view3d_smooth_view_force_finish(C, vod->v3d, vod->ar); | ED_view3d_smooth_view_force_finish(C, vod->v3d, vod->ar); | ||||
| /* needs to run before 'viewops_data_create' so the backup 'rv3d->ofs' is correct */ | /* needs to run before 'viewops_data_create' so the backup 'rv3d->ofs' is correct */ | ||||
| /* switch from camera view when: */ | /* switch from camera view when: */ | ||||
| if (vod->rv3d->persp != RV3D_PERSP) { | if (vod->rv3d->persp != RV3D_PERSP) { | ||||
| if (vod->rv3d->persp == RV3D_CAMOB) { | if (vod->rv3d->persp == RV3D_CAMOB) { | ||||
| /* ignore rv3d->lpersp because dolly only makes sense in perspective mode */ | /* ignore rv3d->lpersp because dolly only makes sense in perspective mode */ | ||||
| const Depsgraph *depsgraph = CTX_data_depsgraph(C); | const Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); | ||||
| ED_view3d_persp_switch_from_camera(depsgraph, vod->v3d, vod->rv3d, RV3D_PERSP); | ED_view3d_persp_switch_from_camera(depsgraph, vod->v3d, vod->rv3d, RV3D_PERSP); | ||||
| } | } | ||||
| else { | else { | ||||
| vod->rv3d->persp = RV3D_PERSP; | vod->rv3d->persp = RV3D_PERSP; | ||||
| } | } | ||||
| ED_region_tag_redraw(vod->ar); | ED_region_tag_redraw(vod->ar); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 144 Lines • ▼ Show 20 Lines | else { /* ortho */ | ||||
| } | } | ||||
| else { | else { | ||||
| /* adjust zoom so it looks nicer */ | /* adjust zoom so it looks nicer */ | ||||
| persp = RV3D_ORTHO; | persp = RV3D_ORTHO; | ||||
| } | } | ||||
| } | } | ||||
| if (ok_dist) { | if (ok_dist) { | ||||
| Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); | |||||
| new_dist = ED_view3d_radius_to_dist( | new_dist = ED_view3d_radius_to_dist( | ||||
| v3d, ar, CTX_data_depsgraph(C), persp, true, (size / 2) * VIEW3D_MARGIN); | v3d, ar, depsgraph, persp, true, (size / 2) * VIEW3D_MARGIN); | ||||
| if (rv3d->is_persp) { | if (rv3d->is_persp) { | ||||
| /* don't zoom closer than the near clipping plane */ | /* don't zoom closer than the near clipping plane */ | ||||
| new_dist = max_ff(new_dist, v3d->clip_start * 1.5f); | new_dist = max_ff(new_dist, v3d->clip_start * 1.5f); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| mid_v3_v3v3(new_ofs, min, max); | mid_v3_v3v3(new_ofs, min, max); | ||||
| ▲ Show 20 Lines • Show All 50 Lines • ▼ Show 20 Lines | |||||
| } | } | ||||
| static int view3d_all_exec(bContext *C, wmOperator *op) | static int view3d_all_exec(bContext *C, wmOperator *op) | ||||
| { | { | ||||
| ARegion *ar = CTX_wm_region(C); | ARegion *ar = CTX_wm_region(C); | ||||
| View3D *v3d = CTX_wm_view3d(C); | View3D *v3d = CTX_wm_view3d(C); | ||||
| RegionView3D *rv3d = CTX_wm_region_view3d(C); | RegionView3D *rv3d = CTX_wm_region_view3d(C); | ||||
| Scene *scene = CTX_data_scene(C); | Scene *scene = CTX_data_scene(C); | ||||
| const Depsgraph *depsgraph = CTX_data_depsgraph(C); | const Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); | ||||
| ViewLayer *view_layer_eval = DEG_get_evaluated_view_layer(depsgraph); | ViewLayer *view_layer_eval = DEG_get_evaluated_view_layer(depsgraph); | ||||
| Base *base_eval; | Base *base_eval; | ||||
| const bool use_all_regions = RNA_boolean_get(op->ptr, "use_all_regions"); | const bool use_all_regions = RNA_boolean_get(op->ptr, "use_all_regions"); | ||||
| const bool skip_camera = (ED_view3d_camera_lock_check(v3d, ar->regiondata) || | const bool skip_camera = (ED_view3d_camera_lock_check(v3d, ar->regiondata) || | ||||
| /* any one of the regions may be locked */ | /* any one of the regions may be locked */ | ||||
| (use_all_regions && v3d->flag2 & V3D_LOCK_CAMERA)); | (use_all_regions && v3d->flag2 & V3D_LOCK_CAMERA)); | ||||
| const bool center = RNA_boolean_get(op->ptr, "center"); | const bool center = RNA_boolean_get(op->ptr, "center"); | ||||
| const int smooth_viewtx = WM_operator_smooth_viewtx_get(op); | const int smooth_viewtx = WM_operator_smooth_viewtx_get(op); | ||||
| ▲ Show 20 Lines • Show All 88 Lines • ▼ Show 20 Lines | |||||
| /* like a localview without local!, was centerview() in 2.4x */ | /* like a localview without local!, was centerview() in 2.4x */ | ||||
| static int viewselected_exec(bContext *C, wmOperator *op) | static int viewselected_exec(bContext *C, wmOperator *op) | ||||
| { | { | ||||
| ARegion *ar = CTX_wm_region(C); | ARegion *ar = CTX_wm_region(C); | ||||
| View3D *v3d = CTX_wm_view3d(C); | View3D *v3d = CTX_wm_view3d(C); | ||||
| RegionView3D *rv3d = CTX_wm_region_view3d(C); | RegionView3D *rv3d = CTX_wm_region_view3d(C); | ||||
| Scene *scene = CTX_data_scene(C); | Scene *scene = CTX_data_scene(C); | ||||
| Depsgraph *depsgraph = CTX_data_depsgraph(C); | Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); | ||||
| ViewLayer *view_layer_eval = DEG_get_evaluated_view_layer(depsgraph); | ViewLayer *view_layer_eval = DEG_get_evaluated_view_layer(depsgraph); | ||||
| bGPdata *gpd = CTX_data_gpencil_data(C); | bGPdata *gpd = CTX_data_gpencil_data(C); | ||||
| const bool is_gp_edit = GPENCIL_ANY_MODE(gpd); | const bool is_gp_edit = GPENCIL_ANY_MODE(gpd); | ||||
| const bool is_face_map = ((is_gp_edit == false) && ar->gizmo_map && | const bool is_face_map = ((is_gp_edit == false) && ar->gizmo_map && | ||||
| WM_gizmomap_is_any_selected(ar->gizmo_map)); | WM_gizmomap_is_any_selected(ar->gizmo_map)); | ||||
| Object *ob_eval = OBACT(view_layer_eval); | Object *ob_eval = OBACT(view_layer_eval); | ||||
| Object *obedit = CTX_data_edit_object(C); | Object *obedit = CTX_data_edit_object(C); | ||||
| float min[3], max[3]; | float min[3], max[3]; | ||||
| ▲ Show 20 Lines • Show All 181 Lines • ▼ Show 20 Lines | static int view_lock_to_active_exec(bContext *C, wmOperator *UNUSED(op)) | ||||
| if (v3d) { | if (v3d) { | ||||
| ED_view3d_lock_clear(v3d); | ED_view3d_lock_clear(v3d); | ||||
| v3d->ob_centre = obact; /* can be NULL */ | v3d->ob_centre = obact; /* can be NULL */ | ||||
| if (obact && obact->type == OB_ARMATURE) { | if (obact && obact->type == OB_ARMATURE) { | ||||
| if (obact->mode & OB_MODE_POSE) { | if (obact->mode & OB_MODE_POSE) { | ||||
| Object *obact_eval = DEG_get_evaluated_object(CTX_data_depsgraph(C), obact); | Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); | ||||
| Object *obact_eval = DEG_get_evaluated_object(depsgraph, obact); | |||||
| bPoseChannel *pcham_act = BKE_pose_channel_active(obact_eval); | bPoseChannel *pcham_act = BKE_pose_channel_active(obact_eval); | ||||
| if (pcham_act) { | if (pcham_act) { | ||||
| BLI_strncpy(v3d->ob_centre_bone, pcham_act->name, sizeof(v3d->ob_centre_bone)); | BLI_strncpy(v3d->ob_centre_bone, pcham_act->name, sizeof(v3d->ob_centre_bone)); | ||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| EditBone *ebone_act = ((bArmature *)obact->data)->act_edbone; | EditBone *ebone_act = ((bArmature *)obact->data)->act_edbone; | ||||
| if (ebone_act) { | if (ebone_act) { | ||||
| ▲ Show 20 Lines • Show All 79 Lines • ▼ Show 20 Lines | |||||
| static int viewcenter_pick_invoke(bContext *C, wmOperator *op, const wmEvent *event) | static int viewcenter_pick_invoke(bContext *C, wmOperator *op, const wmEvent *event) | ||||
| { | { | ||||
| View3D *v3d = CTX_wm_view3d(C); | View3D *v3d = CTX_wm_view3d(C); | ||||
| RegionView3D *rv3d = CTX_wm_region_view3d(C); | RegionView3D *rv3d = CTX_wm_region_view3d(C); | ||||
| ARegion *ar = CTX_wm_region(C); | ARegion *ar = CTX_wm_region(C); | ||||
| if (rv3d) { | if (rv3d) { | ||||
| struct Depsgraph *depsgraph = CTX_data_depsgraph(C); | struct Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); | ||||
| float new_ofs[3]; | float new_ofs[3]; | ||||
| const int smooth_viewtx = WM_operator_smooth_viewtx_get(op); | const int smooth_viewtx = WM_operator_smooth_viewtx_get(op); | ||||
| ED_view3d_smooth_view_force_finish(C, v3d, ar); | ED_view3d_smooth_view_force_finish(C, v3d, ar); | ||||
| view3d_operator_needs_opengl(C); | view3d_operator_needs_opengl(C); | ||||
| if (ED_view3d_autodist(depsgraph, ar, v3d, event->mval, new_ofs, false, NULL)) { | if (ED_view3d_autodist(depsgraph, ar, v3d, event->mval, new_ofs, false, NULL)) { | ||||
| Show All 29 Lines | |||||
| /** \} */ | /** \} */ | ||||
| /* -------------------------------------------------------------------- */ | /* -------------------------------------------------------------------- */ | ||||
| /** \name View Camera Center Operator | /** \name View Camera Center Operator | ||||
| * \{ */ | * \{ */ | ||||
| static int view3d_center_camera_exec(bContext *C, wmOperator *UNUSED(op)) | static int view3d_center_camera_exec(bContext *C, wmOperator *UNUSED(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); | ||||
| float xfac, yfac; | float xfac, yfac; | ||||
| float size[2]; | float size[2]; | ||||
| View3D *v3d; | View3D *v3d; | ||||
| ARegion *ar; | ARegion *ar; | ||||
| RegionView3D *rv3d; | RegionView3D *rv3d; | ||||
| ▲ Show 20 Lines • Show All 82 Lines • ▼ Show 20 Lines | static int render_border_exec(bContext *C, wmOperator *op) | ||||
| rctf vb, border; | rctf vb, border; | ||||
| /* get box select values using rna */ | /* get box select values using rna */ | ||||
| WM_operator_properties_border_to_rcti(op, &rect); | WM_operator_properties_border_to_rcti(op, &rect); | ||||
| /* calculate range */ | /* calculate range */ | ||||
| if (rv3d->persp == RV3D_CAMOB) { | if (rv3d->persp == RV3D_CAMOB) { | ||||
| Depsgraph *depsgraph = CTX_data_depsgraph(C); | Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); | ||||
| ED_view3d_calc_camera_border(scene, depsgraph, ar, v3d, rv3d, &vb, false); | ED_view3d_calc_camera_border(scene, depsgraph, ar, v3d, rv3d, &vb, false); | ||||
| } | } | ||||
| else { | else { | ||||
| vb.xmin = 0; | vb.xmin = 0; | ||||
| vb.ymin = 0; | vb.ymin = 0; | ||||
| vb.xmax = ar->winx; | vb.xmax = ar->winx; | ||||
| vb.ymax = ar->winy; | vb.ymax = ar->winy; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 152 Lines • ▼ Show 20 Lines | static int view3d_zoom_border_exec(bContext *C, wmOperator *op) | ||||
| WM_operator_properties_border_to_rcti(op, &rect); | WM_operator_properties_border_to_rcti(op, &rect); | ||||
| /* check if zooming in/out view */ | /* check if zooming in/out view */ | ||||
| const bool zoom_in = !RNA_boolean_get(op->ptr, "zoom_out"); | const bool zoom_in = !RNA_boolean_get(op->ptr, "zoom_out"); | ||||
| ED_view3d_dist_range_get(v3d, dist_range); | ED_view3d_dist_range_get(v3d, dist_range); | ||||
| /* Get Z Depths, needed for perspective, nice for ortho */ | /* Get Z Depths, needed for perspective, nice for ortho */ | ||||
| ED_view3d_draw_depth(CTX_data_depsgraph(C), ar, v3d, true); | ED_view3d_draw_depth(CTX_data_ensure_evaluated_depsgraph(C), ar, v3d, true); | ||||
| { | { | ||||
| /* avoid allocating the whole depth buffer */ | /* avoid allocating the whole depth buffer */ | ||||
| ViewDepths depth_temp = {0}; | ViewDepths depth_temp = {0}; | ||||
| /* avoid view3d_update_depths() for speed. */ | /* avoid view3d_update_depths() for speed. */ | ||||
| view3d_update_depths_rect(ar, &depth_temp, &rect); | view3d_update_depths_rect(ar, &depth_temp, &rect); | ||||
| ▲ Show 20 Lines • Show All 72 Lines • ▼ Show 20 Lines | static int view3d_zoom_border_exec(bContext *C, wmOperator *op) | ||||
| } | } | ||||
| /* clamp after because we may have been zooming out */ | /* clamp after because we may have been zooming out */ | ||||
| CLAMP(new_dist, dist_range[0], dist_range[1]); | CLAMP(new_dist, dist_range[0], dist_range[1]); | ||||
| /* TODO(campbell): 'is_camera_lock' not currently working well. */ | /* TODO(campbell): 'is_camera_lock' not currently working well. */ | ||||
| const bool is_camera_lock = ED_view3d_camera_lock_check(v3d, rv3d); | const bool is_camera_lock = ED_view3d_camera_lock_check(v3d, rv3d); | ||||
| if ((rv3d->persp == RV3D_CAMOB) && (is_camera_lock == false)) { | if ((rv3d->persp == RV3D_CAMOB) && (is_camera_lock == false)) { | ||||
| Depsgraph *depsgraph = CTX_data_depsgraph(C); | Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); | ||||
| ED_view3d_persp_switch_from_camera(depsgraph, v3d, rv3d, RV3D_PERSP); | ED_view3d_persp_switch_from_camera(depsgraph, v3d, rv3d, RV3D_PERSP); | ||||
| } | } | ||||
| ED_view3d_smooth_view(C, | ED_view3d_smooth_view(C, | ||||
| v3d, | v3d, | ||||
| ar, | ar, | ||||
| smooth_viewtx, | smooth_viewtx, | ||||
| &(const V3D_SmoothParams){ | &(const V3D_SmoothParams){ | ||||
| ▲ Show 20 Lines • Show All 50 Lines • ▼ Show 20 Lines | static void view3d_set_1_to_1_viewborder(Scene *scene, | ||||
| ED_view3d_calc_camera_border_size(scene, depsgraph, ar, v3d, rv3d, size); | ED_view3d_calc_camera_border_size(scene, depsgraph, ar, v3d, rv3d, size); | ||||
| rv3d->camzoom = BKE_screen_view3d_zoom_from_fac((float)im_width / size[0]); | rv3d->camzoom = BKE_screen_view3d_zoom_from_fac((float)im_width / size[0]); | ||||
| CLAMP(rv3d->camzoom, RV3D_CAMZOOM_MIN, RV3D_CAMZOOM_MAX); | CLAMP(rv3d->camzoom, RV3D_CAMZOOM_MIN, RV3D_CAMZOOM_MAX); | ||||
| } | } | ||||
| static int view3d_zoom_1_to_1_camera_exec(bContext *C, wmOperator *UNUSED(op)) | static int view3d_zoom_1_to_1_camera_exec(bContext *C, wmOperator *UNUSED(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; | View3D *v3d; | ||||
| ARegion *ar; | ARegion *ar; | ||||
| /* no NULL check is needed, poll checks */ | /* no NULL check is needed, poll checks */ | ||||
| ED_view3d_context_user_region(C, &v3d, &ar); | ED_view3d_context_user_region(C, &v3d, &ar); | ||||
| ▲ Show 20 Lines • Show All 91 Lines • ▼ Show 20 Lines | static void axis_set_view(bContext *C, | ||||
| else if (orig_persp == RV3D_CAMOB && v3d->camera) { | else if (orig_persp == RV3D_CAMOB && v3d->camera) { | ||||
| /* from camera */ | /* from camera */ | ||||
| float ofs[3], dist; | float ofs[3], dist; | ||||
| copy_v3_v3(ofs, rv3d->ofs); | copy_v3_v3(ofs, rv3d->ofs); | ||||
| dist = rv3d->dist; | dist = rv3d->dist; | ||||
| /* so we animate _from_ the camera location */ | /* so we animate _from_ the camera location */ | ||||
| Object *camera_eval = DEG_get_evaluated_object(CTX_data_depsgraph(C), v3d->camera); | Object *camera_eval = DEG_get_evaluated_object(CTX_data_ensure_evaluated_depsgraph(C), | ||||
| v3d->camera); | |||||
| ED_view3d_from_object(camera_eval, rv3d->ofs, NULL, &rv3d->dist, NULL); | ED_view3d_from_object(camera_eval, rv3d->ofs, NULL, &rv3d->dist, NULL); | ||||
| ED_view3d_smooth_view(C, | ED_view3d_smooth_view(C, | ||||
| v3d, | v3d, | ||||
| ar, | ar, | ||||
| smooth_viewtx, | smooth_viewtx, | ||||
| &(const V3D_SmoothParams){ | &(const V3D_SmoothParams){ | ||||
| .ofs = ofs, | .ofs = ofs, | ||||
| ▲ Show 20 Lines • Show All 313 Lines • ▼ Show 20 Lines | static int vieworbit_exec(bContext *C, wmOperator *op) | ||||
| if ((rv3d->viewlock & RV3D_LOCKED) == 0 || (view_opposite != RV3D_VIEW_USER)) { | if ((rv3d->viewlock & RV3D_LOCKED) == 0 || (view_opposite != RV3D_VIEW_USER)) { | ||||
| if ((rv3d->persp != RV3D_CAMOB) || ED_view3d_camera_lock_check(v3d, rv3d)) { | if ((rv3d->persp != RV3D_CAMOB) || ED_view3d_camera_lock_check(v3d, rv3d)) { | ||||
| int smooth_viewtx = WM_operator_smooth_viewtx_get(op); | int smooth_viewtx = WM_operator_smooth_viewtx_get(op); | ||||
| float quat_mul[4]; | float quat_mul[4]; | ||||
| float quat_new[4]; | float quat_new[4]; | ||||
| if (view_opposite == RV3D_VIEW_USER) { | if (view_opposite == RV3D_VIEW_USER) { | ||||
| const Depsgraph *depsgraph = CTX_data_depsgraph(C); | const Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); | ||||
| ED_view3d_persp_ensure(depsgraph, v3d, ar); | ED_view3d_persp_ensure(depsgraph, v3d, ar); | ||||
| } | } | ||||
| if (ELEM(orbitdir, V3D_VIEW_STEPLEFT, V3D_VIEW_STEPRIGHT)) { | if (ELEM(orbitdir, V3D_VIEW_STEPLEFT, V3D_VIEW_STEPRIGHT)) { | ||||
| if (orbitdir == V3D_VIEW_STEPRIGHT) { | if (orbitdir == V3D_VIEW_STEPRIGHT) { | ||||
| angle = -angle; | angle = -angle; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 733 Lines • ▼ Show 20 Lines | void ED_view3d_cursor3d_position(bContext *C, | ||||
| /* reset the depth based on the view offset (we _know_ the offset is infront of us) */ | /* reset the depth based on the view offset (we _know_ the offset is infront of us) */ | ||||
| if (flip) { | if (flip) { | ||||
| negate_v3_v3(cursor_co, rv3d->ofs); | negate_v3_v3(cursor_co, rv3d->ofs); | ||||
| /* re initialize, no need to check flip again */ | /* re initialize, no need to check flip again */ | ||||
| ED_view3d_calc_zfac(rv3d, cursor_co, NULL /* &flip */); | ED_view3d_calc_zfac(rv3d, cursor_co, NULL /* &flip */); | ||||
| } | } | ||||
| if (use_depth) { /* maybe this should be accessed some other way */ | if (use_depth) { /* maybe this should be accessed some other way */ | ||||
| struct Depsgraph *depsgraph = CTX_data_depsgraph(C); | struct Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); | ||||
| view3d_operator_needs_opengl(C); | view3d_operator_needs_opengl(C); | ||||
| if (ED_view3d_autodist(depsgraph, ar, v3d, mval, cursor_co, true, NULL)) { | if (ED_view3d_autodist(depsgraph, ar, v3d, mval, cursor_co, true, NULL)) { | ||||
| depth_used = true; | depth_used = true; | ||||
| } | } | ||||
| } | } | ||||
| if (depth_used == false) { | if (depth_used == false) { | ||||
| Show All 39 Lines | else if (orientation == V3D_CURSOR_ORIENT_GEOM) { | ||||
| copy_qt_qt(cursor_quat, rv3d->viewquat); | copy_qt_qt(cursor_quat, rv3d->viewquat); | ||||
| cursor_quat[0] *= -1.0f; | cursor_quat[0] *= -1.0f; | ||||
| const float mval_fl[2] = {UNPACK2(mval)}; | const float mval_fl[2] = {UNPACK2(mval)}; | ||||
| float ray_no[3]; | float ray_no[3]; | ||||
| float ray_co[3]; | float ray_co[3]; | ||||
| struct SnapObjectContext *snap_context = ED_transform_snap_object_context_create_view3d( | struct SnapObjectContext *snap_context = ED_transform_snap_object_context_create_view3d( | ||||
| bmain, scene, CTX_data_depsgraph(C), 0, ar, v3d); | bmain, scene, CTX_data_ensure_evaluated_depsgraph(C), 0, ar, v3d); | ||||
| float obmat[4][4]; | float obmat[4][4]; | ||||
| Object *ob_dummy = NULL; | Object *ob_dummy = NULL; | ||||
| float dist_px = 0; | float dist_px = 0; | ||||
| if (ED_transform_snap_object_project_view3d_ex(snap_context, | if (ED_transform_snap_object_project_view3d_ex(snap_context, | ||||
| SCE_SNAP_MODE_FACE, | SCE_SNAP_MODE_FACE, | ||||
| &(const struct SnapObjectParams){ | &(const struct SnapObjectParams){ | ||||
| .snap_select = SNAP_ALL, | .snap_select = SNAP_ALL, | ||||
| ▲ Show 20 Lines • Show All 295 Lines • Show Last 20 Lines | |||||