diff options
author | Campbell Barton <ideasman42@gmail.com> | 2018-02-09 14:14:17 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2018-02-09 14:14:39 +0300 |
commit | 5db950e860b2f64078cfc8cf00cb4f430b8a1baf (patch) | |
tree | b9a734351e0cfa849c3c136e4fc6f26276c7c5c0 /source/blender/editors/space_view3d/view3d_edit.c | |
parent | 25074be697cb5726328aa5d064a60788c1da6aeb (diff) |
Cleanup: use workspace for object_mode when possible
Diffstat (limited to 'source/blender/editors/space_view3d/view3d_edit.c')
-rw-r--r-- | source/blender/editors/space_view3d/view3d_edit.c | 33 |
1 files changed, 14 insertions, 19 deletions
diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index 20eb65197e5..47778623561 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -244,24 +244,22 @@ void view3d_orbit_apply_dyn_ofs( static bool view3d_orbit_calc_center(bContext *C, float r_dyn_ofs[3]) { static float lastofs[3] = {0, 0, 0}; - - EvaluationContext eval_ctx; - CTX_data_eval_ctx(C, &eval_ctx); + const WorkSpace *workspace = CTX_wm_workspace(C); bool is_set = false; Scene *scene = CTX_data_scene(C); ViewLayer *view_layer = CTX_data_view_layer(C); Object *ob_act = OBACT(view_layer); - if (ob_act && (eval_ctx.object_mode & OB_MODE_ALL_PAINT) && + if (ob_act && (workspace->object_mode & OB_MODE_ALL_PAINT) && /* with weight-paint + pose-mode, fall through to using calculateTransformCenter */ - ((eval_ctx.object_mode & OB_MODE_WEIGHT_PAINT) && BKE_object_pose_armature_get(ob_act)) == 0) + ((workspace->object_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 * center, in other cases it's not clear what rotation center shall be * so just rotate around object origin */ - if (eval_ctx.object_mode & (OB_MODE_SCULPT | OB_MODE_TEXTURE_PAINT | OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT)) { + if (workspace->object_mode & (OB_MODE_SCULPT | OB_MODE_TEXTURE_PAINT | OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT)) { float stroke[3]; BKE_paint_stroke_get_average(scene, ob_act, stroke); copy_v3_v3(lastofs, stroke); @@ -271,7 +269,7 @@ static bool view3d_orbit_calc_center(bContext *C, float r_dyn_ofs[3]) } is_set = true; } - else if (ob_act && (eval_ctx.object_mode & OB_MODE_EDIT) && (ob_act->type == OB_FONT)) { + else if (ob_act && (workspace->object_mode & OB_MODE_EDIT) && (ob_act->type == OB_FONT)) { Curve *cu = ob_act->data; EditFont *ef = cu->editfont; int i; @@ -286,7 +284,7 @@ static bool view3d_orbit_calc_center(bContext *C, float r_dyn_ofs[3]) is_set = true; } - else if (ob_act == NULL || eval_ctx.object_mode == OB_MODE_OBJECT) { + else if (ob_act == NULL || workspace->object_mode == OB_MODE_OBJECT) { /* object mode use boundbox centers */ Base *base; unsigned int tot = 0; @@ -2795,8 +2793,7 @@ void VIEW3D_OT_view_all(wmOperatorType *ot) /* like a localview without local!, was centerview() in 2.4x */ static int viewselected_exec(bContext *C, wmOperator *op) { - EvaluationContext eval_ctx; - CTX_data_eval_ctx(C, &eval_ctx); + const WorkSpace *workspace = CTX_wm_workspace(C); ARegion *ar = CTX_wm_region(C); View3D *v3d = CTX_wm_view3d(C); Scene *scene = CTX_data_scene(C); @@ -2820,7 +2817,7 @@ static int viewselected_exec(bContext *C, wmOperator *op) ob = NULL; } - if (ob && (eval_ctx.object_mode & OB_MODE_WEIGHT_PAINT)) { + if (ob && (workspace->object_mode & OB_MODE_WEIGHT_PAINT)) { Object *ob_armature = BKE_object_pose_armature_get_visible(ob, view_layer); if (ob_armature) { ob = ob_armature; @@ -2845,17 +2842,17 @@ static int viewselected_exec(bContext *C, wmOperator *op) else if (obedit) { ok = ED_view3d_minmax_verts(obedit, min, max); /* only selected */ } - else if (ob && (eval_ctx.object_mode & OB_MODE_POSE)) { + else if (ob && (workspace->object_mode & OB_MODE_POSE)) { ok = BKE_pose_minmax(ob, min, max, true, true); } - else if (BKE_paint_select_face_test(&eval_ctx, ob)) { + else if (BKE_paint_select_face_test(ob, workspace->object_mode)) { ok = paintface_minmax(ob, min, max); } - else if (ob && (eval_ctx.object_mode & OB_MODE_PARTICLE_EDIT)) { + else if (ob && (workspace->object_mode & OB_MODE_PARTICLE_EDIT)) { ok = PE_minmax(scene, view_layer, min, max); } else if (ob && - (eval_ctx.object_mode & (OB_MODE_SCULPT | OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT | OB_MODE_TEXTURE_PAINT))) + (workspace->object_mode & (OB_MODE_SCULPT | OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT | OB_MODE_TEXTURE_PAINT))) { BKE_paint_stroke_get_average(scene, ob, min); copy_v3_v3(max, min); @@ -2962,15 +2959,13 @@ static int view_lock_to_active_exec(bContext *C, wmOperator *UNUSED(op)) Object *obact = CTX_data_active_object(C); if (v3d) { - EvaluationContext eval_ctx; - CTX_data_eval_ctx(C, &eval_ctx); - ED_view3d_lock_clear(v3d); v3d->ob_centre = obact; /* can be NULL */ if (obact && obact->type == OB_ARMATURE) { - if (eval_ctx.object_mode & OB_MODE_POSE) { + const WorkSpace *workspace = CTX_wm_workspace(C); + if (workspace->object_mode & OB_MODE_POSE) { bPoseChannel *pcham_act = BKE_pose_channel_active(obact); if (pcham_act) { BLI_strncpy(v3d->ob_centre_bone, pcham_act->name, sizeof(v3d->ob_centre_bone)); |