diff options
author | Campbell Barton <ideasman42@gmail.com> | 2017-10-24 04:40:52 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2017-10-26 08:15:54 +0300 |
commit | 3d904d7650c0a74e494f3ea94b0df3e10292812a (patch) | |
tree | 806a6ab38c0d811bc4e27245b35dde799c171e17 /source/blender | |
parent | f074a6dd2ea0eebaa62eef2ee40073599b999207 (diff) |
Manipulator: Use object bound-box for scale cage
Without this, scaling single objects wasn't working usefully.
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/editors/transform/transform_manipulator.c | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/source/blender/editors/transform/transform_manipulator.c b/source/blender/editors/transform/transform_manipulator.c index a540fe58877..1fa62556bd5 100644 --- a/source/blender/editors/transform/transform_manipulator.c +++ b/source/blender/editors/transform/transform_manipulator.c @@ -584,7 +584,9 @@ bool gimbal_axis(Object *ob, float gmat[3][3]) /* centroid, boundbox, of selection */ /* returns total items selected */ -static int calc_manipulator_stats(const bContext *C, struct TransformBounds *tbounds) +static int calc_manipulator_stats( + const bContext *C, bool use_only_center, + struct TransformBounds *tbounds) { ScrArea *sa = CTX_wm_area(C); ARegion *ar = CTX_wm_region(C); @@ -1004,7 +1006,16 @@ static int calc_manipulator_stats(const bContext *C, struct TransformBounds *tbo if (TESTBASELIB_NEW(base)) { if (ob == NULL) ob = base->object; - calc_tw_center(tbounds, base->object->obmat[3]); + if (use_only_center || base->object->bb == NULL) { + calc_tw_center(tbounds, base->object->obmat[3]); + } + else { + for (uint j = 0; j < 8; j++) { + float co[3]; + mul_v3_m4v3(co, base->object->obmat, base->object->bb->vec[j]); + calc_tw_center(tbounds, co); + } + } protectflag_to_drawflags(base->object->protectflag, &rv3d->twdrawflag); totsel++; } @@ -1181,7 +1192,7 @@ static int manipulator_modal( struct TransformBounds tbounds; - if (calc_manipulator_stats(C, &tbounds)) { + if (calc_manipulator_stats(C, true, &tbounds)) { manipulator_prepare_mat(C, v3d, rv3d, &tbounds); WM_manipulator_set_matrix_location(widget, rv3d->twmat[3]); } @@ -1317,7 +1328,7 @@ static void WIDGETGROUP_manipulator_refresh(const bContext *C, wmManipulatorGrou struct TransformBounds tbounds; /* skip, we don't draw anything anyway */ - if ((man->all_hidden = (calc_manipulator_stats(C, &tbounds) == 0))) + if ((man->all_hidden = (calc_manipulator_stats(C, true, &tbounds) == 0))) return; manipulator_prepare_mat(C, v3d, rv3d, &tbounds); @@ -1524,7 +1535,7 @@ static void WIDGETGROUP_xform_cage_refresh(const bContext *C, wmManipulatorGroup struct TransformBounds tbounds; - if ((calc_manipulator_stats(C, &tbounds) == 0) || + if ((calc_manipulator_stats(C, false, &tbounds) == 0) || equals_v3v3(rv3d->tw_axis_min, rv3d->tw_axis_max)) { WM_manipulator_set_flag(mpr, WM_MANIPULATOR_HIDDEN, true); |