diff options
author | Campbell Barton <ideasman42@gmail.com> | 2020-06-23 11:31:10 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2020-06-23 11:35:06 +0300 |
commit | 309cfbceaa590828b61bfd72f12ef976f9808392 (patch) | |
tree | 96321104d6fe9fc59ee79c8b784344d76cc6eadc /source/blender/editors/object/object_transform.c | |
parent | 3a3708cefb7ae87f53ce45b65754fbb857e945a1 (diff) |
Transform: default to median center instead of bounds
When neither bounds or median is selected, snapping the cursor to
the selection was using bounds which often doesn't give useful results.
Resolves T78135
Diffstat (limited to 'source/blender/editors/object/object_transform.c')
-rw-r--r-- | source/blender/editors/object/object_transform.c | 50 |
1 files changed, 25 insertions, 25 deletions
diff --git a/source/blender/editors/object/object_transform.c b/source/blender/editors/object/object_transform.c index 132b530455e..161611d59c9 100644 --- a/source/blender/editors/object/object_transform.c +++ b/source/blender/editors/object/object_transform.c @@ -1098,15 +1098,7 @@ static int object_origin_set_exec(bContext *C, wmOperator *op) mul_m4_v3(obedit->imat, cent); } else { - if (around == V3D_AROUND_CENTER_MEDIAN) { - if (em->bm->totvert) { - const float total_div = 1.0f / (float)em->bm->totvert; - BM_ITER_MESH (eve, &iter, em->bm, BM_VERTS_OF_MESH) { - madd_v3_v3fl(cent, eve->co, total_div); - } - } - } - else { + if (around == V3D_AROUND_CENTER_BOUNDS) { float min[3], max[3]; INIT_MINMAX(min, max); BM_ITER_MESH (eve, &iter, em->bm, BM_VERTS_OF_MESH) { @@ -1114,6 +1106,14 @@ static int object_origin_set_exec(bContext *C, wmOperator *op) } mid_v3_v3v3(cent, min, max); } + else { /* #V3D_AROUND_CENTER_MEDIAN. */ + if (em->bm->totvert) { + const float total_div = 1.0f / (float)em->bm->totvert; + BM_ITER_MESH (eve, &iter, em->bm, BM_VERTS_OF_MESH) { + madd_v3_v3fl(cent, eve->co, total_div); + } + } + } } BM_ITER_MESH (eve, &iter, em->bm, BM_VERTS_OF_MESH) { @@ -1211,12 +1211,12 @@ static int object_origin_set_exec(bContext *C, wmOperator *op) else if (centermode == ORIGIN_TO_CENTER_OF_MASS_VOLUME) { BKE_mesh_center_of_volume(me, cent); } - else if (around == V3D_AROUND_CENTER_MEDIAN) { - BKE_mesh_center_median(me, cent); - } - else { + else if (around == V3D_AROUND_CENTER_BOUNDS) { BKE_mesh_center_bounds(me, cent); } + else { /* #V3D_AROUND_CENTER_MEDIAN. */ + BKE_mesh_center_median(me, cent); + } negate_v3_v3(cent_neg, cent); BKE_mesh_translate(me, cent_neg, 1); @@ -1231,12 +1231,12 @@ static int object_origin_set_exec(bContext *C, wmOperator *op) if (centermode == ORIGIN_TO_CURSOR) { /* done */ } - else if (around == V3D_AROUND_CENTER_MEDIAN) { - BKE_curve_center_median(cu, cent); - } - else { + else if (around == V3D_AROUND_CENTER_BOUNDS) { BKE_curve_center_bounds(cu, cent); } + else { /* #V3D_AROUND_CENTER_MEDIAN. */ + BKE_curve_center_median(cu, cent); + } /* don't allow Z change if curve is 2D */ if ((ob->type == OB_CURVE) && !(cu->flag & CU_3D)) { @@ -1324,12 +1324,12 @@ static int object_origin_set_exec(bContext *C, wmOperator *op) if (centermode == ORIGIN_TO_CURSOR) { /* done */ } - else if (around == V3D_AROUND_CENTER_MEDIAN) { - BKE_mball_center_median(mb, cent); - } - else { + else if (around == V3D_AROUND_CENTER_BOUNDS) { BKE_mball_center_bounds(mb, cent); } + else { /* #V3D_AROUND_CENTER_MEDIAN. */ + BKE_mball_center_median(mb, cent); + } negate_v3_v3(cent_neg, cent); BKE_mball_translate(mb, cent_neg); @@ -1351,12 +1351,12 @@ static int object_origin_set_exec(bContext *C, wmOperator *op) if (centermode == ORIGIN_TO_CURSOR) { /* done */ } - else if (around == V3D_AROUND_CENTER_MEDIAN) { - BKE_lattice_center_median(lt, cent); - } - else { + else if (around == V3D_AROUND_CENTER_BOUNDS) { BKE_lattice_center_bounds(lt, cent); } + else { /* #V3D_AROUND_CENTER_MEDIAN. */ + BKE_lattice_center_median(lt, cent); + } negate_v3_v3(cent_neg, cent); BKE_lattice_translate(lt, cent_neg, 1); |