Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/space_view3d/view3d_edit.c
| Show First 20 Lines • Show All 618 Lines • ▼ Show 20 Lines | |||||
| } | } | ||||
| 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; | ||||
| Scene *scene = CTX_data_scene(C); | Scene *scene = CTX_data_scene(C); | ||||
| SceneLayer *sl = CTX_data_scene_layer(C); | ViewLayer *sl = CTX_data_view_layer(C); | ||||
| Object *ob_act = OBACT(sl); | Object *ob_act = OBACT(sl); | ||||
| 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 */ | ||||
| ((ob_act->mode & OB_MODE_WEIGHT_PAINT) && BKE_object_pose_armature_get(ob_act)) == 0) | ((ob_act->mode & OB_MODE_WEIGHT_PAINT) && BKE_object_pose_armature_get(ob_act)) == 0) | ||||
| { | { | ||||
| /* in case of sculpting use last average stroke position as a rotation | /* in case of sculpting use last average stroke position as a rotation | ||||
| * center, in other cases it's not clear what rotation center shall be | * center, in other cases it's not clear what rotation center shall be | ||||
| ▲ Show 20 Lines • Show All 2,349 Lines • ▼ Show 20 Lines | static void view3d_from_minmax_multi(bContext *C, View3D *v3d, | ||||
| } | } | ||||
| } | } | ||||
| static int view3d_all_exec(bContext *C, wmOperator *op) /* was view3d_home() in 2.4x */ | static int view3d_all_exec(bContext *C, wmOperator *op) /* was view3d_home() in 2.4x */ | ||||
| { | { | ||||
| 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); | ||||
| SceneLayer *sl = CTX_data_scene_layer(C); | ViewLayer *sl = CTX_data_view_layer(C); | ||||
| Base *base; | Base *base; | ||||
| float *curs; | float *curs; | ||||
| 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 68 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); | ||||
| Scene *scene = CTX_data_scene(C); | Scene *scene = CTX_data_scene(C); | ||||
| SceneLayer *sl = CTX_data_scene_layer(C); | ViewLayer *view_layer = CTX_data_view_layer(C); | ||||
| bGPdata *gpd = CTX_data_gpencil_data(C); | bGPdata *gpd = CTX_data_gpencil_data(C); | ||||
| const bool is_gp_edit = ((gpd) && (gpd->flag & GP_DATA_STROKE_EDITMODE)); | const bool is_gp_edit = ((gpd) && (gpd->flag & GP_DATA_STROKE_EDITMODE)); | ||||
| const bool is_face_map = ((is_gp_edit == false) && ar->manipulator_map && | const bool is_face_map = ((is_gp_edit == false) && ar->manipulator_map && | ||||
| WM_manipulatormap_is_any_selected(ar->manipulator_map)); | WM_manipulatormap_is_any_selected(ar->manipulator_map)); | ||||
| Object *ob = OBACT(sl); | Object *ob = OBACT(view_layer); | ||||
| Object *obedit = CTX_data_edit_object(C); | Object *obedit = CTX_data_edit_object(C); | ||||
| float min[3], max[3]; | float min[3], max[3]; | ||||
| bool ok = false, ok_dist = true; | bool ok = false, ok_dist = true; | ||||
| 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 int smooth_viewtx = WM_operator_smooth_viewtx_get(op); | const int smooth_viewtx = WM_operator_smooth_viewtx_get(op); | ||||
| INIT_MINMAX(min, max); | INIT_MINMAX(min, max); | ||||
| if (is_gp_edit || is_face_map) { | if (is_gp_edit || is_face_map) { | ||||
| ob = NULL; | ob = NULL; | ||||
| } | } | ||||
| if (ob && (ob->mode & OB_MODE_WEIGHT_PAINT)) { | if (ob && (ob->mode & OB_MODE_WEIGHT_PAINT)) { | ||||
| /* hard-coded exception, we look for the one selected armature */ | /* hard-coded exception, we look for the one selected armature */ | ||||
| /* this is weak code this way, we should make a generic active/selection callback interface once... */ | /* this is weak code this way, we should make a generic active/selection callback interface once... */ | ||||
| Base *base; | Base *base; | ||||
| for (base = sl->object_bases.first; base; base = base->next) { | for (base = view_layer->object_bases.first; base; base = base->next) { | ||||
| if (TESTBASELIB(base)) { | if (TESTBASELIB(base)) { | ||||
| if (base->object->type == OB_ARMATURE) | if (base->object->type == OB_ARMATURE) | ||||
| if (base->object->mode & OB_MODE_POSE) | if (base->object->mode & OB_MODE_POSE) | ||||
| break; | break; | ||||
| } | } | ||||
| } | } | ||||
| if (base) | if (base) | ||||
| ob = base->object; | ob = base->object; | ||||
| Show All 20 Lines | static int viewselected_exec(bContext *C, wmOperator *op) | ||||
| } | } | ||||
| else if (ob && (ob->mode & OB_MODE_POSE)) { | else if (ob && (ob->mode & OB_MODE_POSE)) { | ||||
| ok = BKE_pose_minmax(ob, min, max, true, true); | ok = BKE_pose_minmax(ob, min, max, true, true); | ||||
| } | } | ||||
| else if (BKE_paint_select_face_test(ob)) { | else if (BKE_paint_select_face_test(ob)) { | ||||
| ok = paintface_minmax(ob, min, max); | ok = paintface_minmax(ob, min, max); | ||||
| } | } | ||||
| else if (ob && (ob->mode & OB_MODE_PARTICLE_EDIT)) { | else if (ob && (ob->mode & OB_MODE_PARTICLE_EDIT)) { | ||||
| ok = PE_minmax(scene, sl, min, max); | ok = PE_minmax(scene, view_layer, min, max); | ||||
| } | } | ||||
| else if (ob && | else if (ob && | ||||
| (ob->mode & (OB_MODE_SCULPT | OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT | OB_MODE_TEXTURE_PAINT))) | (ob->mode & (OB_MODE_SCULPT | OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT | OB_MODE_TEXTURE_PAINT))) | ||||
| { | { | ||||
| BKE_paint_stroke_get_average(scene, ob, min); | BKE_paint_stroke_get_average(scene, ob, min); | ||||
| copy_v3_v3(max, min); | copy_v3_v3(max, min); | ||||
| ok = true; | ok = true; | ||||
| ok_dist = 0; /* don't zoom */ | ok_dist = 0; /* don't zoom */ | ||||
| } | } | ||||
| else { | else { | ||||
| Base *base; | Base *base; | ||||
| for (base = FIRSTBASE(sl); base; base = base->next) { | for (base = FIRSTBASE(view_layer); base; base = base->next) { | ||||
| if (TESTBASE(base)) { | if (TESTBASE(base)) { | ||||
| if (skip_camera && base->object == v3d->camera) { | if (skip_camera && base->object == v3d->camera) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| /* account for duplis */ | /* account for duplis */ | ||||
| if (BKE_object_minmax_dupli(scene, base->object, min, max, false) == 0) | if (BKE_object_minmax_dupli(scene, base->object, min, max, false) == 0) | ||||
| ▲ Show 20 Lines • Show All 750 Lines • ▼ Show 20 Lines | |||||
| } | } | ||||
| 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); | Scene *scene = CTX_data_scene(C); | ||||
| SceneLayer *scene_layer = CTX_data_scene_layer(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 18 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 - */ | ||||
| if (rv3d->persp != RV3D_CAMOB) { | if (rv3d->persp != RV3D_CAMOB) { | ||||
| Object *ob = OBACT(scene_layer); | Object *ob = OBACT(view_layer); | ||||
| 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 18 Lines | #endif | ||||
| } | } | ||||
| } | } | ||||
| /* 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 && ob->type == OB_CAMERA) | ||||
| v3d->camera = ob; | v3d->camera = ob; | ||||
| if (v3d->camera == NULL) | if (v3d->camera == NULL) | ||||
| v3d->camera = BKE_scene_layer_camera_find(scene_layer); | v3d->camera = BKE_view_layer_camera_find(view_layer); | ||||
| /* 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 1,202 Lines • Show Last 20 Lines | |||||