Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/space_view3d/view3d_edit.c
| Show First 20 Lines • Show All 56 Lines • ▼ Show 20 Lines | |||||
| #include "BKE_object.h" | #include "BKE_object.h" | ||||
| #include "BKE_paint.h" | #include "BKE_paint.h" | ||||
| #include "BKE_report.h" | #include "BKE_report.h" | ||||
| #include "BKE_scene.h" | #include "BKE_scene.h" | ||||
| #include "BKE_screen.h" | #include "BKE_screen.h" | ||||
| #include "BKE_action.h" | #include "BKE_action.h" | ||||
| #include "DEG_depsgraph.h" | #include "DEG_depsgraph.h" | ||||
| #include "DEG_depsgraph_query.h" | |||||
| #include "WM_api.h" | #include "WM_api.h" | ||||
| #include "WM_types.h" | #include "WM_types.h" | ||||
| #include "WM_message.h" | #include "WM_message.h" | ||||
| #include "RNA_access.h" | #include "RNA_access.h" | ||||
| #include "RNA_define.h" | #include "RNA_define.h" | ||||
| ▲ Show 20 Lines • Show All 2,626 Lines • ▼ Show 20 Lines | static void view3d_from_minmax_multi( | ||||
| } | } | ||||
| } | } | ||||
| 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); | ||||
| Scene *scene = CTX_data_scene(C); | Scene *scene = CTX_data_scene(C); | ||||
| ViewLayer *view_layer = CTX_data_view_layer(C); | const Depsgraph *depsgraph = CTX_data_depsgraph(C); | ||||
| Base *base; | ViewLayer *view_layer_eval = DEG_get_evaluated_view_layer(depsgraph); | ||||
| 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); | ||||
| float min[3], max[3]; | float min[3], max[3]; | ||||
| bool changed = false; | bool changed = false; | ||||
| if (center) { | if (center) { | ||||
| /* in 2.4x this also move the cursor to (0, 0, 0) (with shift+c). */ | /* in 2.4x this also move the cursor to (0, 0, 0) (with shift+c). */ | ||||
| View3DCursor *cursor = ED_view3d_cursor3d_get(scene, v3d); | View3DCursor *cursor = ED_view3d_cursor3d_get(scene, v3d); | ||||
| zero_v3(min); | zero_v3(min); | ||||
| zero_v3(max); | zero_v3(max); | ||||
| zero_v3(cursor->location); | zero_v3(cursor->location); | ||||
| unit_qt(cursor->rotation); | unit_qt(cursor->rotation); | ||||
| } | } | ||||
| else { | else { | ||||
| INIT_MINMAX(min, max); | INIT_MINMAX(min, max); | ||||
| } | } | ||||
| for (base = view_layer->object_bases.first; base; base = base->next) { | for (base_eval = view_layer_eval->object_bases.first; base_eval; base_eval = base_eval->next) { | ||||
| if (BASE_VISIBLE(base)) { | if (BASE_VISIBLE(base_eval)) { | ||||
| changed = true; | changed = true; | ||||
| if (skip_camera && base->object == v3d->camera) { | if (skip_camera && base_eval->object == v3d->camera) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| BKE_object_minmax(base->object, min, max, false); | BKE_object_minmax(base_eval->object, min, max, false); | ||||
| } | } | ||||
| } | } | ||||
| if (!changed) { | if (!changed) { | ||||
| ED_region_tag_redraw(ar); | ED_region_tag_redraw(ar); | ||||
| /* TODO - should this be cancel? | /* TODO - should this be cancel? | ||||
| * I think no, because we always move the cursor, with or without | * I think no, because we always move the cursor, with or without | ||||
| * object, but in this case there is no change in the scene, | * object, but in this case there is no change in the scene, | ||||
| * only the cursor so I choice a ED_region_tag like | * only the cursor so I choice a ED_region_tag like | ||||
| ▲ Show 20 Lines • Show All 941 Lines • ▼ Show 20 Lines | static void axis_set_view( | ||||
| } | } | ||||
| } | } | ||||
| static int viewnumpad_exec(bContext *C, wmOperator *op) | static int viewnumpad_exec(bContext *C, wmOperator *op) | ||||
| { | { | ||||
| View3D *v3d; | View3D *v3d; | ||||
| ARegion *ar; | ARegion *ar; | ||||
| RegionView3D *rv3d; | RegionView3D *rv3d; | ||||
| Scene *scene = CTX_data_scene(C); | |||||
| ViewLayer *view_layer = CTX_data_view_layer(C); | |||||
| static int perspo = RV3D_PERSP; | static int perspo = RV3D_PERSP; | ||||
| int viewnum, nextperspo; | int viewnum, nextperspo; | ||||
| bool align_active; | bool align_active; | ||||
| const int smooth_viewtx = WM_operator_smooth_viewtx_get(op); | const int smooth_viewtx = WM_operator_smooth_viewtx_get(op); | ||||
| /* 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); | ||||
| rv3d = ar->regiondata; | rv3d = ar->regiondata; | ||||
| Show All 17 Lines | if (RV3D_VIEW_IS_AXIS(viewnum)) { | ||||
| ED_view3d_quat_from_axis_view(viewnum, quat); | ED_view3d_quat_from_axis_view(viewnum, quat); | ||||
| axis_set_view(C, v3d, ar, quat, viewnum, nextperspo, align_active, smooth_viewtx); | axis_set_view(C, v3d, ar, quat, viewnum, nextperspo, align_active, smooth_viewtx); | ||||
| } | } | ||||
| else if (viewnum == RV3D_VIEW_CAMERA) { | else if (viewnum == RV3D_VIEW_CAMERA) { | ||||
| if ((rv3d->viewlock & RV3D_LOCKED) == 0) { | if ((rv3d->viewlock & RV3D_LOCKED) == 0) { | ||||
| /* lastview - */ | /* lastview - */ | ||||
| const Depsgraph *depsgraph = CTX_data_depsgraph(C); | |||||
brita_: Moved down to the one place where it's actually used, to avoid asking for evaluated stuff.
Let… | |||||
| ViewLayer *view_layer_eval = DEG_get_evaluated_view_layer(depsgraph); | |||||
| Scene *scene = CTX_data_scene(C); | |||||
| if (rv3d->persp != RV3D_CAMOB) { | if (rv3d->persp != RV3D_CAMOB) { | ||||
| Object *ob = OBACT(view_layer); | Object *ob_eval = OBACT(view_layer_eval); | ||||
| if (!rv3d->smooth_timer) { | if (!rv3d->smooth_timer) { | ||||
| /* store settings of current view before allowing overwriting with camera view | /* store settings of current view before allowing overwriting with camera view | ||||
| * only if we're not currently in a view transition */ | * only if we're not currently in a view transition */ | ||||
| ED_view3d_lastview_store(rv3d); | ED_view3d_lastview_store(rv3d); | ||||
| } | } | ||||
| Show All 14 Lines | #endif | ||||
| else { | else { | ||||
| /* use scene camera if one is not set (even though we're unlocked) */ | /* use scene camera if one is not set (even though we're unlocked) */ | ||||
| if (v3d->camera == NULL) { | if (v3d->camera == NULL) { | ||||
| v3d->camera = scene->camera; | v3d->camera = scene->camera; | ||||
| } | } | ||||
| } | } | ||||
| /* if the camera isn't found, check a number of options */ | /* if the camera isn't found, check a number of options */ | ||||
| if (v3d->camera == NULL && ob && ob->type == OB_CAMERA) | if (v3d->camera == NULL && ob_eval && ob_eval->type == OB_CAMERA) | ||||
| v3d->camera = ob; | v3d->camera = ob_eval; | ||||
aligorithUnsubmitted Not Done Inline ActionsAFAIK, we really shouldn't be storing the evaluated data back to the original scene data. Have you tried just changing the ED_view3d_smooth_view() -> .camera parameter a few lines down instead? aligorith: AFAIK, we really shouldn't be storing the evaluated data back to the original scene data. Have… | |||||
brita_AuthorUnsubmitted Not Done Inline ActionsI think you're absolutely right. I was wrongly assuming that v3d->camera was some sort of runtime 'current view'. brita_: I think you're absolutely right. I was wrongly assuming that v3d->camera was some sort of… | |||||
| if (v3d->camera == NULL) | if (v3d->camera == NULL) | ||||
| v3d->camera = BKE_view_layer_camera_find(view_layer); | v3d->camera = BKE_view_layer_camera_find(view_layer_eval); | ||||
| /* couldnt find any useful camera, bail out */ | /* couldnt find any useful camera, bail out */ | ||||
| if (v3d->camera == NULL) | if (v3d->camera == NULL) | ||||
| return OPERATOR_CANCELLED; | return OPERATOR_CANCELLED; | ||||
| /* important these don't get out of sync for locked scenes */ | /* important these don't get out of sync for locked scenes */ | ||||
| if (v3d->scenelock) | if (v3d->scenelock) | ||||
| scene->camera = v3d->camera; | scene->camera = v3d->camera; | ||||
| ▲ Show 20 Lines • Show All 950 Lines • Show Last 20 Lines | |||||
Moved down to the one place where it's actually used, to avoid asking for evaluated stuff.
Let me know if you'd rather I don't do this.