diff options
author | Campbell Barton <ideasman42@gmail.com> | 2021-08-31 09:29:59 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2021-08-31 10:02:47 +0300 |
commit | fa4f9292e16ce6a9253164ea731870c6d0161848 (patch) | |
tree | 988f3d289f45b2f4454a9632f2df563601800417 /source/blender/editors/transform/transform_orientations.c | |
parent | d718d6b4493429a1e688e874fd76963f98e3d034 (diff) |
Transform: avoid passing the context to extended orientation functions
This makes it possible to calculate orientation from functions
that don't have the context.
Diffstat (limited to 'source/blender/editors/transform/transform_orientations.c')
-rw-r--r-- | source/blender/editors/transform/transform_orientations.c | 50 |
1 files changed, 24 insertions, 26 deletions
diff --git a/source/blender/editors/transform/transform_orientations.c b/source/blender/editors/transform/transform_orientations.c index 33f4b06eb0e..1e3acdf1071 100644 --- a/source/blender/editors/transform/transform_orientations.c +++ b/source/blender/editors/transform/transform_orientations.c @@ -490,13 +490,14 @@ void ED_transform_calc_orientation_from_type(const bContext *C, float r_mat[3][3 Scene *scene = CTX_data_scene(C); ViewLayer *view_layer = CTX_data_view_layer(C); Object *obedit = CTX_data_edit_object(C); + View3D *v3d = CTX_wm_view3d(C); RegionView3D *rv3d = region->regiondata; Object *ob = OBACT(view_layer); const short orient_index = BKE_scene_orientation_get_index(scene, SCE_ORIENT_DEFAULT); const int pivot_point = scene->toolsettings->transform_pivot_point; ED_transform_calc_orientation_from_type_ex( - C, r_mat, scene, rv3d, ob, obedit, orient_index, pivot_point); + scene, view_layer, v3d, rv3d, ob, obedit, orient_index, pivot_point, r_mat); } /** @@ -508,15 +509,15 @@ void ED_transform_calc_orientation_from_type(const bContext *C, float r_mat[3][3 * - #V3D_ORIENT_LOCAL may contain shear from non-uniform scale in parent/child relationships. * - #V3D_ORIENT_CUSTOM may have been created from #V3D_ORIENT_LOCAL. */ -short ED_transform_calc_orientation_from_type_ex(const bContext *C, - float r_mat[3][3], - /* extra args (can be accessed from context) */ - Scene *scene, - RegionView3D *rv3d, +short ED_transform_calc_orientation_from_type_ex(const Scene *scene, + ViewLayer *view_layer, + const View3D *v3d, + const RegionView3D *rv3d, Object *ob, Object *obedit, const short orientation_index, - const int pivot_point) + const int pivot_point, + float r_mat[3][3]) { switch (orientation_index) { case V3D_ORIENT_GIMBAL: { @@ -528,7 +529,7 @@ short ED_transform_calc_orientation_from_type_ex(const bContext *C, } case V3D_ORIENT_NORMAL: { if (obedit || (ob && ob->mode & OB_MODE_POSE)) { - ED_getTransformOrientationMatrix(C, ob, obedit, pivot_point, r_mat); + ED_getTransformOrientationMatrix(view_layer, v3d, ob, obedit, pivot_point, r_mat); break; } /* No break we define 'normal' as 'local' in Object mode. */ @@ -541,7 +542,7 @@ short ED_transform_calc_orientation_from_type_ex(const bContext *C, * use the active pones axis for display T33575, this works as expected on a single * bone and users who select many bones will understand what's going on and what local * means when they start transforming. */ - ED_getTransformOrientationMatrix(C, ob, obedit, pivot_point, r_mat); + ED_getTransformOrientationMatrix(view_layer, v3d, ob, obedit, pivot_point, r_mat); } else { transform_orientations_create_from_axis(r_mat, UNPACK3(ob->obmat)); @@ -604,9 +605,11 @@ short transform_orientation_matrix_get(bContext *C, Object *ob = CTX_data_active_object(C); Object *obedit = CTX_data_edit_object(C); Scene *scene = t->scene; + View3D *v3d = NULL; RegionView3D *rv3d = NULL; if ((t->spacetype == SPACE_VIEW3D) && t->region && (t->region->regiontype == RGN_TYPE_WINDOW)) { + v3d = t->view; rv3d = t->region->regiondata; if (ob && (ob->mode & OB_MODE_ALL_WEIGHT_PAINT) && !(t->options & CTX_PAINT_CURVE)) { @@ -619,15 +622,7 @@ short transform_orientation_matrix_get(bContext *C, } short r_orient_index = ED_transform_calc_orientation_from_type_ex( - C, - r_spacemtx, - /* extra args (can be accessed from context) */ - scene, - rv3d, - ob, - obedit, - orient_index, - t->around); + scene, t->view_layer, v3d, rv3d, ob, obedit, orient_index, t->around, r_spacemtx); if (rv3d && (t->options & CTX_PAINT_CURVE)) { /* Screen space in the 3d region. */ @@ -757,15 +752,14 @@ static uint bm_mesh_faces_select_get_n(BMesh *bm, BMVert **elems, const uint n) } #endif -int getTransformOrientation_ex(const bContext *C, +int getTransformOrientation_ex(ViewLayer *view_layer, + const View3D *v3d, struct Object *ob, struct Object *obedit, float normal[3], float plane[3], const short around) { - ViewLayer *view_layer = CTX_data_view_layer(C); - View3D *v3d = CTX_wm_view3d(C); int result = ORIENTATION_NONE; const bool activeOnly = (around == V3D_AROUND_ACTIVE); @@ -1296,12 +1290,16 @@ int getTransformOrientation(const bContext *C, float normal[3], float plane[3]) /* dummy value, not V3D_AROUND_ACTIVE and not V3D_AROUND_LOCAL_ORIGINS */ short around = V3D_AROUND_CENTER_BOUNDS; - return getTransformOrientation_ex(C, obact, obedit, normal, plane, around); + ViewLayer *view_layer = CTX_data_view_layer(C); + View3D *v3d = CTX_wm_view3d(C); + + return getTransformOrientation_ex(view_layer, v3d, obact, obedit, normal, plane, around); } -void ED_getTransformOrientationMatrix(const bContext *C, - struct Object *ob, - struct Object *obedit, +void ED_getTransformOrientationMatrix(ViewLayer *view_layer, + const View3D *v3d, + Object *ob, + Object *obedit, const short around, float r_orientation_mat[3][3]) { @@ -1310,7 +1308,7 @@ void ED_getTransformOrientationMatrix(const bContext *C, int type; - type = getTransformOrientation_ex(C, ob, obedit, normal, plane, around); + type = getTransformOrientation_ex(view_layer, v3d, ob, obedit, normal, plane, around); /* Fallback, when the plane can't be calculated. */ if (ORIENTATION_USE_PLANE(type) && is_zero_v3(plane)) { |