Merge branch 'master' into blender2.8
authorCampbell Barton <ideasman42@gmail.com>
Thu, 8 Mar 2018 06:52:10 +0000 (17:52 +1100)
committerCampbell Barton <ideasman42@gmail.com>
Thu, 8 Mar 2018 06:54:52 +0000 (17:54 +1100)
22 files changed:
1  2 
source/blender/editors/armature/armature_select.c
source/blender/editors/armature/editarmature_sketch.c
source/blender/editors/curve/editcurve.c
source/blender/editors/curve/editcurve_paint.c
source/blender/editors/curve/editfont.c
source/blender/editors/include/ED_view3d.h
source/blender/editors/mesh/editmesh_select.c
source/blender/editors/mesh/meshtools.c
source/blender/editors/metaball/mball_edit.c
source/blender/editors/object/object_lattice.c
source/blender/editors/object/object_transform.c
source/blender/editors/physics/particle_edit.c
source/blender/editors/sculpt_paint/paint_cursor.c
source/blender/editors/sculpt_paint/paint_hide.c
source/blender/editors/sculpt_paint/paint_image.c
source/blender/editors/sculpt_paint/paint_mask.c
source/blender/editors/sculpt_paint/paint_stroke.c
source/blender/editors/sculpt_paint/paint_utils.c
source/blender/editors/sculpt_paint/paint_vertex.c
source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c
source/blender/editors/sculpt_paint/sculpt.c
source/blender/editors/space_view3d/view3d_select.c

index f178ad640b63fb8c5b00b43eb9778a1b8a84d7e1,2e2c184e43d395cc85cf5b6c358e3b5a259b4298..397691a409b635e2cfa5683c04a1bd47fe81a911
@@@ -172,9 -170,8 +172,9 @@@ void *get_nearest_bone(bContext *C, con
        rcti rect;
        unsigned int buffer[MAXPICKBUF];
        short hits;
 -      
 +
 +      CTX_data_eval_ctx(C, &eval_ctx);
-       view3d_set_viewcontext(C, &vc);
+       ED_view3d_viewcontext_init(C, &vc);
        
        // rect.xmin = ... mouseco!
        rect.xmin = rect.xmax = xy[0];
@@@ -490,9 -486,8 +490,9 @@@ bool ED_armature_select_pick(bContext *
        EditBone *nearBone = NULL;
        int selmask;
  
-       view3d_set_viewcontext(C, &vc);
 +      CTX_data_eval_ctx(C, &eval_ctx);
 -      
+       ED_view3d_viewcontext_init(C, &vc);
 +
        if (BIF_sk_selectStroke(C, mval, extend)) {
                return true;
        }
index f17a83dec8f0299f721d9ebe01942c9d6dee6da1,79b538b4f4abaf2964d1c67bdfceeaf5aae8dad8..f01eed21996167e3f115fb30c0537b390ffe8c1f
@@@ -1931,8 -1905,7 +1931,8 @@@ static bool sk_selectStroke(bContext *C
        unsigned int buffer[MAXPICKBUF];
        short hits;
  
-       view3d_set_viewcontext(C, &vc);
 +      CTX_data_eval_ctx(C, &eval_ctx);
+       ED_view3d_viewcontext_init(C, &vc);
  
        BLI_rcti_init_pt_radius(&rect, mval, 5);
  
index 169afb140fb3b0e55a66cc2ddd5e63050c2596a8,0d7cb089c4f6a4aa00d61f2e35bd0dd4229fef1c..36eb4c6c5bc0d24c5f5e9ceb9ae99f43af43b90c
@@@ -605,10 -580,8 +605,10 @@@ static bool curve_draw_init(bContext *C
  
        struct CurveDrawData *cdd = MEM_callocN(sizeof(*cdd), __func__);
  
 +      cdd->depsgraph = CTX_data_depsgraph(C);
 +
        if (is_invoke) {
-               view3d_set_viewcontext(C, &cdd->vc);
+               ED_view3d_viewcontext_init(C, &cdd->vc);
                if (ELEM(NULL, cdd->vc.ar, cdd->vc.rv3d, cdd->vc.v3d, cdd->vc.win, cdd->vc.scene)) {
                        MEM_freeN(cdd);
                        BKE_report(op->reports, RPT_ERROR, "Unable to access 3D viewport");
index 4daa4a234703b1c0fe2cacdb94838c610250221f,b66821c4e378c254ce4dbe2fb53738b94c45ef9b..aebfd46a554309191fa1fc1bd284ddb7241e60bb
@@@ -1101,8 -1088,7 +1101,8 @@@ bool ED_mesh_pick_face(bContext *C, Obj
        if (!me || me->totpoly == 0)
                return false;
  
-       view3d_set_viewcontext(C, &vc);
 +      CTX_data_eval_ctx(C, &eval_ctx);
+       ED_view3d_viewcontext_init(C, &vc);
  
        if (size) {
                /* sample rect to increase chances of selecting, so that when clicking
index 935f1a5ea4aeed730c3b8c1134e9800abc00407d,e948de02f405ed88316fcfef996d4862632d3d3b..310325ee1439e16651db8917a013fdc9af542880
@@@ -597,8 -595,7 +597,8 @@@ bool ED_mball_select_pick(bContext *C, 
        unsigned int buffer[MAXPICKBUF];
        rcti rect;
  
-       view3d_set_viewcontext(C, &vc);
 +      CTX_data_eval_ctx(C, &eval_ctx);
+       ED_view3d_viewcontext_init(C, &vc);
  
        BLI_rcti_init_pt_radius(&rect, mval, 12);
  
index b336b560ef276eeecbc152736dfdf12c00f51925,9fea7bf5b8938f5c9a5da363d16b8c40db83c908..033f9d190b7f6b2365db5042d297fb3e2b71f12a
@@@ -1152,389 -1131,3 +1152,389 @@@ void OBJECT_OT_origin_set(wmOperatorTyp
        ot->prop = RNA_def_enum(ot->srna, "type", prop_set_center_types, 0, "Type", "");
        RNA_def_enum(ot->srna, "center", prop_set_bounds_types, V3D_AROUND_CENTER_MEAN, "Center", "");
  }
-       view3d_set_viewcontext(C, &vc);
 +
 +/* -------------------------------------------------------------------- */
 +
 +/** \name Transform Axis Target
 + *
 + * Note this is an experemental operator to point lamps/cameras at objects.
 + * We may re-work how this behaves based on user feedback.
 + * - campbell.
 + * \{ */
 +
 +/* When using multiple objects, apply their relative rotational offset to the active object. */
 +#define USE_RELATIVE_ROTATION
 +
 +struct XFormAxisItem {
 +      Object *ob;
 +      float rot_mat[3][3];
 +      void *obtfm;
 +      float xform_dist;
 +
 +#ifdef USE_RELATIVE_ROTATION
 +      /* use when translating multiple */
 +      float xform_rot_offset[3][3];
 +#endif
 +};
 +
 +struct XFormAxisData {
 +      ViewContext vc;
 +      struct {
 +              float depth;
 +              float normal[3];
 +              bool is_depth_valid;
 +              bool is_normal_valid;
 +      } prev;
 +
 +      struct XFormAxisItem *object_data;
 +      uint object_data_len;
 +      bool is_translate;
 +
 +      int init_event;
 +};
 +
 +static bool object_is_target_compat(const Object *ob)
 +{
 +      if (ob->type == OB_LAMP) {
 +              const Lamp *la = ob->data;
 +              if (ELEM(la->type, LA_SUN, LA_SPOT, LA_HEMI, LA_AREA)) {
 +                      return true;
 +              }
 +      }
 +      /* We might want to enable this later, for now just lamps */
 +#if 0
 +      else if (ob->type == OB_CAMERA) {
 +              return true;
 +      }
 +#endif
 +      return false;
 +}
 +
 +static void object_transform_axis_target_free_data(wmOperator *op)
 +{
 +      struct XFormAxisData *xfd = op->customdata;
 +      struct XFormAxisItem *item = xfd->object_data;
 +      for (int i = 0; i < xfd->object_data_len; i++, item++) {
 +              MEM_freeN(item->obtfm);
 +      }
 +      MEM_freeN(xfd->object_data);
 +      MEM_freeN(xfd);
 +      op->customdata = NULL;
 +}
 +
 +/* We may want to expose as alternative to: BKE_object_apply_rotation */
 +static void object_apply_rotation(Object *ob, const float rmat[3][3])
 +{
 +      float size[3];
 +      float loc[3];
 +      float rmat4[4][4];
 +      copy_m4_m3(rmat4, rmat);
 +
 +      copy_v3_v3(size, ob->size);
 +      copy_v3_v3(loc, ob->loc);
 +      BKE_object_apply_mat4(ob, rmat4, true, true);
 +      copy_v3_v3(ob->size, size);
 +      copy_v3_v3(ob->loc, loc);
 +}
 +/* We may want to extract this to: BKE_object_apply_location */
 +static void object_apply_location(Object *ob, const float loc[3])
 +{
 +      /* quick but weak */
 +      Object ob_prev = *ob;
 +      float mat[4][4];
 +      copy_m4_m4(mat, ob->obmat);
 +      copy_v3_v3(mat[3], loc);
 +      BKE_object_apply_mat4(ob, mat, true, true);
 +      copy_v3_v3(mat[3], ob->loc);
 +      *ob = ob_prev;
 +      copy_v3_v3(ob->loc, mat[3]);
 +}
 +
 +static void object_orient_to_location(
 +        Object *ob, float rot_orig[3][3], const float axis[3], const float location[3])
 +{
 +      float delta[3];
 +      sub_v3_v3v3(delta, ob->obmat[3], location);
 +      if (normalize_v3(delta) != 0.0f) {
 +              if (len_squared_v3v3(delta, axis) > FLT_EPSILON) {
 +                      float delta_rot[3][3];
 +                      float final_rot[3][3];
 +                      rotation_between_vecs_to_mat3(delta_rot, axis, delta);
 +
 +                      mul_m3_m3m3(final_rot, delta_rot, rot_orig);
 +
 +                      object_apply_rotation(ob, final_rot);
 +
 +                      DEG_id_tag_update(&ob->id, OB_RECALC_OB);
 +              }
 +      }
 +}
 +
 +static void object_transform_axis_target_cancel(bContext *C, wmOperator *op)
 +{
 +      struct XFormAxisData *xfd = op->customdata;
 +      struct XFormAxisItem *item = xfd->object_data;
 +      for (int i = 0; i < xfd->object_data_len; i++, item++) {
 +              BKE_object_tfm_restore(item->ob, item->obtfm);
 +              DEG_id_tag_update(&item->ob->id, OB_RECALC_OB);
 +              WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, item->ob);
 +      }
 +
 +      object_transform_axis_target_free_data(op);
 +}
 +
 +static int object_transform_axis_target_invoke(bContext *C, wmOperator *op, const wmEvent *event)
 +{
 +      ViewContext vc;
++      ED_view3d_viewcontext_init(C, &vc);
 +
 +      if (!object_is_target_compat(vc.obact)) {
 +              /* Falls back to texture space transform. */
 +              return OPERATOR_PASS_THROUGH;
 +      }
 +
 +      EvaluationContext eval_ctx;
 +
 +      CTX_data_eval_ctx(C, &eval_ctx);
 +
 +      ED_view3d_autodist_init(&eval_ctx, vc.depsgraph, vc.ar, vc.v3d, 0);
 +
 +      if (vc.rv3d->depths != NULL) {
 +              vc.rv3d->depths->damaged = true;
 +      }
 +      ED_view3d_depth_update(vc.ar);
 +
 +      if (vc.rv3d->depths == NULL) {
 +              BKE_report(op->reports, RPT_WARNING, "Unable to access depth buffer, using view plane");
 +              return OPERATOR_CANCELLED;
 +      }
 +
 +      ED_region_tag_redraw(vc.ar);
 +
 +      struct XFormAxisData *xfd;
 +      xfd = op->customdata = MEM_callocN(sizeof(struct XFormAxisData), __func__);
 +
 +      /* Don't change this at runtime. */
 +      xfd->vc = vc;
 +      xfd->vc.mval[0] = event->mval[0];
 +      xfd->vc.mval[1] = event->mval[1];
 +
 +      xfd->prev.depth = 1.0f;
 +      xfd->prev.is_depth_valid = false;
 +      xfd->prev.is_normal_valid = false;
 +      xfd->is_translate = false;
 +
 +      xfd->init_event = WM_userdef_event_type_from_keymap_type(event->type);
 +
 +      {
 +              struct XFormAxisItem *object_data = NULL;
 +              BLI_array_declare(object_data);
 +
 +              struct XFormAxisItem *item = BLI_array_append_ret(object_data);
 +              item->ob = xfd->vc.obact;
 +
 +              CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects)
 +              {
 +                      if ((ob != xfd->vc.obact) && object_is_target_compat(ob)) {
 +                              item = BLI_array_append_ret(object_data);
 +                              item->ob = ob;
 +                      }
 +              }
 +              CTX_DATA_END;
 +
 +              xfd->object_data = object_data;
 +              xfd->object_data_len = BLI_array_count(object_data);
 +
 +              if (xfd->object_data_len != BLI_array_count(object_data)) {
 +                      xfd->object_data = MEM_reallocN(xfd->object_data, xfd->object_data_len * sizeof(*xfd->object_data));
 +              }
 +      }
 +
 +      {
 +              struct XFormAxisItem *item = xfd->object_data;
 +              for (int i = 0; i < xfd->object_data_len; i++, item++) {
 +                      item->obtfm = BKE_object_tfm_backup(item->ob);
 +                      BKE_object_rot_to_mat3(item->ob, item->rot_mat, true);
 +              }
 +      }
 +
 +      WM_event_add_modal_handler(C, op);
 +
 +      return OPERATOR_RUNNING_MODAL;
 +}
 +
 +static int object_transform_axis_target_modal(bContext *C, wmOperator *op, const wmEvent *event)
 +{
 +      struct XFormAxisData *xfd = op->customdata;
 +      ARegion *ar = xfd->vc.ar;
 +
 +      view3d_operator_needs_opengl(C);
 +
 +      const bool is_translate = (event->ctrl != 0);
 +      const bool is_translate_init = is_translate && (xfd->is_translate != is_translate);
 +
 +      if (event->type == MOUSEMOVE || is_translate_init) {
 +              const ViewDepths *depths = xfd->vc.rv3d->depths;
 +              if (depths &&
 +                  ((unsigned int)event->mval[0] < depths->w) &&
 +                  ((unsigned int)event->mval[1] < depths->h))
 +              {
 +                      double depth = (double)ED_view3d_depth_read_cached(&xfd->vc, event->mval);
 +                      float location_world[3];
 +                      if (depth == 1.0f) {
 +                              if (xfd->prev.is_depth_valid) {
 +                                      depth = (double)xfd->prev.depth;
 +                              }
 +                      }
 +                      if ((depth > depths->depth_range[0]) && (depth < depths->depth_range[1])) {
 +                              xfd->prev.depth = depth;
 +                              xfd->prev.is_depth_valid = true;
 +                              if (ED_view3d_depth_unproject(ar, event->mval, depth, location_world)) {
 +                                      if (is_translate) {
 +
 +                                              float normal[3];
 +                                              bool normal_found = false;
 +                                              if (ED_view3d_depth_read_cached_normal(&xfd->vc, event->mval, normal)) {
 +                                                      normal_found = true;
 +
 +                                                      /* cheap attempt to smooth normals out a bit! */
 +                                                      const uint ofs = 2;
 +                                                      for (uint x = -ofs; x <= ofs; x += ofs / 2) {
 +                                                              for (uint y = -ofs; y <= ofs; y += ofs / 2) {
 +                                                                      if (x != 0 && y != 0) {
 +                                                                              int mval_ofs[2] = {event->mval[0] + x, event->mval[1] + y};
 +                                                                              float n[3];
 +                                                                              if (ED_view3d_depth_read_cached_normal(
 +                                                                                      &xfd->vc, mval_ofs, n))
 +                                                                              {
 +                                                                                      add_v3_v3(normal, n);
 +                                                                              }
 +                                                                      }
 +                                                              }
 +                                                      }
 +                                                      normalize_v3(normal);
 +                                              }
 +                                              else if (xfd->prev.is_normal_valid) {
 +                                                      copy_v3_v3(normal, xfd->prev.normal);
 +                                                      normal_found = true;
 +                                              }
 +
 +                                              if (normal_found) {
 +#ifdef USE_RELATIVE_ROTATION
 +                                                      if (is_translate_init && xfd->object_data_len > 1) {
 +                                                              float xform_rot_offset_inv_first[3][3];
 +                                                              struct XFormAxisItem *item = xfd->object_data;
 +                                                              for (int i = 0; i < xfd->object_data_len; i++, item++) {
 +                                                                      copy_m3_m4(item->xform_rot_offset, item->ob->obmat);
 +                                                                      normalize_m3(item->xform_rot_offset);
 +
 +                                                                      if (i == 0) {
 +                                                                              invert_m3_m3(xform_rot_offset_inv_first, xfd->object_data[0].xform_rot_offset);
 +                                                                      }
 +                                                                      else {
 +                                                                              mul_m3_m3m3(item->xform_rot_offset,
 +                                                                                          item->xform_rot_offset,
 +                                                                                          xform_rot_offset_inv_first);
 +                                                                      }
 +                                                              }
 +                                                      }
 +
 +#endif
 +
 +                                                      struct XFormAxisItem *item = xfd->object_data;
 +                                                      for (int i = 0; i < xfd->object_data_len; i++, item++) {
 +                                                              if (is_translate_init) {
 +                                                                      float ob_axis[3];
 +                                                                      item->xform_dist = len_v3v3(item->ob->obmat[3], location_world);
 +                                                                      normalize_v3_v3(ob_axis, item->ob->obmat[2]);
 +                                                                      /* Scale to avoid adding distance when moving between surfaces. */
 +                                                                      float scale = fabsf(dot_v3v3(ob_axis, normal));
 +                                                                      item->xform_dist *= scale;
 +                                                              }
 +
 +                                                              float target_normal[3];
 +                                                              copy_v3_v3(target_normal, normal);
 +
 +#ifdef USE_RELATIVE_ROTATION
 +                                                              if (i != 0) {
 +                                                                      mul_m3_v3(item->xform_rot_offset, target_normal);
 +                                                              }
 +#endif
 +                                                              {
 +                                                                      float loc[3];
 +
 +                                                                      copy_v3_v3(loc, location_world);
 +                                                                      madd_v3_v3fl(loc, target_normal, item->xform_dist);
 +                                                                      object_apply_location(item->ob, loc);
 +                                                                      copy_v3_v3(item->ob->obmat[3], loc);  /* so orient behaves as expected */
 +                                                              }
 +
 +                                                              object_orient_to_location(item->ob, item->rot_mat, item->rot_mat[2], location_world);
 +                                                              WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, item->ob);
 +                                                      }
 +                                                      copy_v3_v3(xfd->prev.normal, normal);
 +                                                      xfd->prev.is_normal_valid = true;
 +                                              }
 +                                      }
 +                                      else {
 +                                              struct XFormAxisItem *item = xfd->object_data;
 +                                              for (int i = 0; i < xfd->object_data_len; i++, item++) {
 +                                                      object_orient_to_location(item->ob, item->rot_mat, item->rot_mat[2], location_world);
 +                                                      WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, item->ob);
 +                                              }
 +                                              xfd->prev.is_normal_valid = false;
 +                                      }
 +                              }
 +                      }
 +              }
 +              xfd->is_translate = is_translate;
 +
 +              ED_region_tag_redraw(xfd->vc.ar);
 +      }
 +
 +      bool is_finished = false;
 +
 +      if (ISMOUSE(xfd->init_event)) {
 +              if ((event->type == xfd->init_event) && (event->val == KM_RELEASE)) {
 +                      is_finished = true;
 +              }
 +      }
 +      else {
 +              if (ELEM(event->type, LEFTMOUSE, RETKEY, PADENTER)) {
 +                      is_finished = true;
 +              }
 +      }
 +
 +      if (is_finished) {
 +              object_transform_axis_target_free_data(op);
 +              return OPERATOR_FINISHED;
 +      }
 +      else if (ELEM(event->type, ESCKEY, RIGHTMOUSE)) {
 +              object_transform_axis_target_cancel(C, op);
 +              return OPERATOR_CANCELLED;
 +      }
 +
 +
 +      return OPERATOR_RUNNING_MODAL;
 +}
 +
 +void OBJECT_OT_transform_axis_target(wmOperatorType *ot)
 +{
 +      /* identifiers */
 +      ot->name = "Interactive Lamp Track to Cursor";
 +      ot->description = "Interactively point cameras and lamps to a location (Ctrl translates)";
 +      ot->idname = "OBJECT_OT_transform_axis_target";
 +
 +      /* api callbacks */
 +      ot->invoke = object_transform_axis_target_invoke;
 +      ot->cancel = object_transform_axis_target_cancel;
 +      ot->modal = object_transform_axis_target_modal;
 +      ot->poll = ED_operator_region_view3d_active;
 +
 +      /* flags */
 +      ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING;
 +}
 +
 +#undef USE_RELATIVE_ROTATION
 +
 +/** \} */
index 850ef0ad958c857deaacb46caf5d2c7e47530146,3c7cb90eba43ec08c70f0a00c6f36331f3ca4454..597cdf08c76e5693ffaeb8f6fbf99175c414d3e8
@@@ -412,7 -396,9 +412,7 @@@ static void PE_set_view3d_data(bContex
  {
        PE_set_data(C, data);
  
-       view3d_set_viewcontext(C, &data->vc);
+       ED_view3d_viewcontext_init(C, &data->vc);
 -      /* note, the object argument means the modelview matrix does not account for the objects matrix, use viewmat rather than (obmat * viewmat) */
 -      view3d_get_transformation(data->vc.ar, data->vc.rv3d, NULL, &data->mats);
  
        if (V3D_IS_ZBUF(data->vc.v3d)) {
                if (data->vc.v3d->flag & V3D_INVALID_BACKBUF) {
index 3a43c7a6585d06de48442d5ae44e8fc7352126d0,e6219b4fae13b053d68b2e4b1639c3273bf3aa8c..d2063d15ddfce5ef44d1c0e398dfb31cfcc0fc31
@@@ -1032,8 -1011,7 +1032,8 @@@ static void paint_draw_cursor(bContext 
  
        /* can't use stroke vc here because this will be called during
         * mouse over too, not just during a stroke */
-       view3d_set_viewcontext(C, &vc);
 +      ViewContext vc;
+       ED_view3d_viewcontext_init(C, &vc);
  
        if (vc.rv3d && (vc.rv3d->rflag & RV3D_NAVIGATING)) {
                return;
index b175a33934a686caf74875f74d57874a8497ba8f,e2b318710a878d5de2d5f9e32243a60fd94e4584..5d4451dd3d895151e21658f6e386cf6316561f2b
@@@ -323,10 -323,12 +323,10 @@@ static void clip_planes_from_rect(bCont
  {
        ViewContext vc;
        BoundBox bb;
 -      bglMats mats = {{0}};
        
        view3d_operator_needs_opengl(C);
-       view3d_set_viewcontext(C, &vc);
+       ED_view3d_viewcontext_init(C, &vc);
 -      view3d_get_transformation(vc.ar, vc.rv3d, vc.obact, &mats);
 -      ED_view3d_clipping_calc(&bb, clip_planes, &mats, rect);
 +      ED_view3d_clipping_calc(&bb, clip_planes, vc.ar, vc.obact, rect);
        negate_m4(clip_planes);
  }
  
index 64969075d8917de364b71cfaaa22182d24237468,76b629395e254aa6ecfdff181ac2de1e94846c29..162c067166cd03bbc60465ce8bfefcdfce9b42e1
@@@ -449,7 -443,8 +449,7 @@@ static int paint_mask_gesture_lasso_exe
                /* Calculations of individual vertices are done in 2D screen space to diminish the amount of
                 * calculations done. Bounding box PBVH collision is not computed against enclosing rectangle
                 * of lasso */
-               view3d_set_viewcontext(C, &vc);
+               ED_view3d_viewcontext_init(C, &vc);
 -              view3d_get_transformation(vc.ar, vc.rv3d, vc.obact, &mats);
  
                /* lasso data calculations */
                data.vc = &vc;
index 8c3ee6da012bee18deb9b9edd6890532474179b1,1cdbd4da1c4162a3ea27845589144b82432e7155..a90a719b556a53f5f7a94a97f666f0bd75c39477
@@@ -1318,11 -1329,9 +1318,11 @@@ Base *ED_view3d_give_base_under_cursor(
        
        /* setup view context for argument to callbacks */
        view3d_operator_needs_opengl(C);
-       view3d_set_viewcontext(C, &vc);
 +
 +      CTX_data_eval_ctx(C, &eval_ctx);
+       ED_view3d_viewcontext_init(C, &vc);
        
 -      hits = mixed_bones_object_selectbuffer(&vc, buffer, mval, false, false, &do_nearest);
 +      hits = mixed_bones_object_selectbuffer(&eval_ctx, &vc, buffer, mval, false, false, &do_nearest);
        
        if (hits > 0) {
                const bool has_bones = selectbuffer_has_bones(buffer, hits);
@@@ -1370,8 -1378,7 +1370,8 @@@ static bool ed_object_select_pick
  
        
        /* setup view context for argument to callbacks */
-       view3d_set_viewcontext(C, &vc);
 +      CTX_data_eval_ctx(C, &eval_ctx);
+       ED_view3d_viewcontext_init(C, &vc);
  
        is_obedit = (vc.obedit != NULL);
        if (object) {
@@@ -2112,8 -2081,7 +2112,8 @@@ static int view3d_borderselect_exec(bCo
        view3d_operator_needs_opengl(C);
  
        /* setup view context for argument to callbacks */
-       view3d_set_viewcontext(C, &vc);
 +      CTX_data_eval_ctx(C, &eval_ctx);
+       ED_view3d_viewcontext_init(C, &vc);
        
        select = !RNA_boolean_get(op->ptr, "deselect");
        extend = RNA_boolean_get(op->ptr, "extend");
@@@ -2813,11 -2779,9 +2813,11 @@@ static bool object_circle_select(ViewCo
  static int view3d_circle_select_exec(bContext *C, wmOperator *op)
  {
        ViewContext vc;
-       view3d_set_viewcontext(C, &vc);
+       ED_view3d_viewcontext_init(C, &vc);
        Object *obact = vc.obact;
        Object *obedit = vc.obedit;
 +      EvaluationContext eval_ctx;
 +      CTX_data_eval_ctx(C, &eval_ctx);
        const int radius = RNA_int_get(op->ptr, "radius");
        const bool select = !RNA_boolean_get(op->ptr, "deselect");
        const int mval[2] = {RNA_int_get(op->ptr, "x"),