Merge branch 'master' into blender2.8
This commit is contained in:
@@ -155,6 +155,10 @@ typedef struct ManipulatorGroup {
|
||||
struct wmManipulator *manipulators[MAN_AXIS_LAST];
|
||||
} ManipulatorGroup;
|
||||
|
||||
struct TransformBounds {
|
||||
float center[3]; /* Center for transform widget. */
|
||||
float min[3], max[3]; /* Boundbox of selection for transform widget. */
|
||||
};
|
||||
|
||||
/* **************** Utilities **************** */
|
||||
|
||||
@@ -414,14 +418,10 @@ static void manipulator_get_axis_constraint(const int axis_idx, int r_axis[3])
|
||||
/* **************** Preparation Stuff **************** */
|
||||
|
||||
/* transform widget center calc helper for below */
|
||||
static void calc_tw_center(Scene *scene, const float co[3])
|
||||
static void calc_tw_center(struct TransformBounds *tbounds, const float co[3])
|
||||
{
|
||||
float *twcent = scene->twcent;
|
||||
float *min = scene->twmin;
|
||||
float *max = scene->twmax;
|
||||
|
||||
minmax_v3v3_v3(min, max, co);
|
||||
add_v3_v3(twcent, co);
|
||||
minmax_v3v3_v3(tbounds->min, tbounds->max, co);
|
||||
add_v3_v3(tbounds->center, co);
|
||||
}
|
||||
|
||||
static void protectflag_to_drawflags(short protectflag, short *drawflags)
|
||||
@@ -566,7 +566,7 @@ 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)
|
||||
static int calc_manipulator_stats(const bContext *C, struct TransformBounds *tbounds)
|
||||
{
|
||||
ScrArea *sa = CTX_wm_area(C);
|
||||
ARegion *ar = CTX_wm_region(C);
|
||||
@@ -587,8 +587,8 @@ static int calc_manipulator_stats(const bContext *C)
|
||||
rv3d->twdrawflag = 0xFFFF;
|
||||
|
||||
/* transform widget centroid/center */
|
||||
INIT_MINMAX(scene->twmin, scene->twmax);
|
||||
zero_v3(scene->twcent);
|
||||
INIT_MINMAX(tbounds->min, tbounds->max);
|
||||
zero_v3(tbounds->center);
|
||||
|
||||
if (is_gp_edit) {
|
||||
float diff_mat[4][4];
|
||||
@@ -618,12 +618,12 @@ static int calc_manipulator_stats(const bContext *C)
|
||||
for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) {
|
||||
if (pt->flag & GP_SPOINT_SELECT) {
|
||||
if (gpl->parent == NULL) {
|
||||
calc_tw_center(scene, &pt->x);
|
||||
calc_tw_center(tbounds, &pt->x);
|
||||
totsel++;
|
||||
}
|
||||
else {
|
||||
mul_v3_m4v3(fpt, diff_mat, &pt->x);
|
||||
calc_tw_center(scene, fpt);
|
||||
calc_tw_center(tbounds, fpt);
|
||||
totsel++;
|
||||
}
|
||||
}
|
||||
@@ -636,7 +636,7 @@ static int calc_manipulator_stats(const bContext *C)
|
||||
|
||||
/* selection center */
|
||||
if (totsel) {
|
||||
mul_v3_fl(scene->twcent, 1.0f / (float)totsel); /* centroid! */
|
||||
mul_v3_fl(tbounds->center, 1.0f / (float)totsel); /* centroid! */
|
||||
}
|
||||
}
|
||||
else if (obedit) {
|
||||
@@ -649,7 +649,7 @@ static int calc_manipulator_stats(const bContext *C)
|
||||
/* USE LAST SELECTE WITH ACTIVE */
|
||||
if ((v3d->around == V3D_AROUND_ACTIVE) && BM_select_history_active_get(em->bm, &ese)) {
|
||||
BM_editselection_center(&ese, vec);
|
||||
calc_tw_center(scene, vec);
|
||||
calc_tw_center(tbounds, vec);
|
||||
totsel = 1;
|
||||
}
|
||||
else {
|
||||
@@ -662,7 +662,7 @@ static int calc_manipulator_stats(const bContext *C)
|
||||
if (!BM_elem_flag_test(eve, BM_ELEM_HIDDEN)) {
|
||||
if (BM_elem_flag_test(eve, BM_ELEM_SELECT)) {
|
||||
totsel++;
|
||||
calc_tw_center(scene, eve->co);
|
||||
calc_tw_center(tbounds, eve->co);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -675,13 +675,13 @@ static int calc_manipulator_stats(const bContext *C)
|
||||
if ((v3d->around == V3D_AROUND_ACTIVE) && (ebo = arm->act_edbone)) {
|
||||
/* doesn't check selection or visibility intentionally */
|
||||
if (ebo->flag & BONE_TIPSEL) {
|
||||
calc_tw_center(scene, ebo->tail);
|
||||
calc_tw_center(tbounds, ebo->tail);
|
||||
totsel++;
|
||||
}
|
||||
if ((ebo->flag & BONE_ROOTSEL) ||
|
||||
((ebo->flag & BONE_TIPSEL) == false)) /* ensure we get at least one point */
|
||||
{
|
||||
calc_tw_center(scene, ebo->head);
|
||||
calc_tw_center(tbounds, ebo->head);
|
||||
totsel++;
|
||||
}
|
||||
protectflag_to_drawflags_ebone(rv3d, ebo);
|
||||
@@ -690,7 +690,7 @@ static int calc_manipulator_stats(const bContext *C)
|
||||
for (ebo = arm->edbo->first; ebo; ebo = ebo->next) {
|
||||
if (EBONE_VISIBLE(arm, ebo)) {
|
||||
if (ebo->flag & BONE_TIPSEL) {
|
||||
calc_tw_center(scene, ebo->tail);
|
||||
calc_tw_center(tbounds, ebo->tail);
|
||||
totsel++;
|
||||
}
|
||||
if ((ebo->flag & BONE_ROOTSEL) &&
|
||||
@@ -700,7 +700,7 @@ static int calc_manipulator_stats(const bContext *C)
|
||||
(ebo->parent->flag & BONE_TIPSEL) &&
|
||||
EBONE_VISIBLE(arm, ebo->parent)) == 0)
|
||||
{
|
||||
calc_tw_center(scene, ebo->head);
|
||||
calc_tw_center(tbounds, ebo->head);
|
||||
totsel++;
|
||||
}
|
||||
if (ebo->flag & BONE_SELECTED) {
|
||||
@@ -715,7 +715,7 @@ static int calc_manipulator_stats(const bContext *C)
|
||||
float center[3];
|
||||
|
||||
if (v3d->around == V3D_AROUND_ACTIVE && ED_curve_active_center(cu, center)) {
|
||||
calc_tw_center(scene, center);
|
||||
calc_tw_center(tbounds, center);
|
||||
totsel++;
|
||||
}
|
||||
else {
|
||||
@@ -736,21 +736,21 @@ static int calc_manipulator_stats(const bContext *C)
|
||||
*/
|
||||
if (cu->drawflag & CU_HIDE_HANDLES) {
|
||||
if (bezt->f2 & SELECT) {
|
||||
calc_tw_center(scene, bezt->vec[1]);
|
||||
calc_tw_center(tbounds, bezt->vec[1]);
|
||||
totsel++;
|
||||
}
|
||||
}
|
||||
else if (bezt->f2 & SELECT) {
|
||||
calc_tw_center(scene, bezt->vec[1]);
|
||||
calc_tw_center(tbounds, bezt->vec[1]);
|
||||
totsel++;
|
||||
}
|
||||
else {
|
||||
if (bezt->f1 & SELECT) {
|
||||
calc_tw_center(scene, bezt->vec[(v3d->around == V3D_AROUND_LOCAL_ORIGINS) ? 1 : 0]);
|
||||
calc_tw_center(tbounds, bezt->vec[(v3d->around == V3D_AROUND_LOCAL_ORIGINS) ? 1 : 0]);
|
||||
totsel++;
|
||||
}
|
||||
if (bezt->f3 & SELECT) {
|
||||
calc_tw_center(scene, bezt->vec[(v3d->around == V3D_AROUND_LOCAL_ORIGINS) ? 1 : 2]);
|
||||
calc_tw_center(tbounds, bezt->vec[(v3d->around == V3D_AROUND_LOCAL_ORIGINS) ? 1 : 2]);
|
||||
totsel++;
|
||||
}
|
||||
}
|
||||
@@ -762,7 +762,7 @@ static int calc_manipulator_stats(const bContext *C)
|
||||
a = nu->pntsu * nu->pntsv;
|
||||
while (a--) {
|
||||
if (bp->f1 & SELECT) {
|
||||
calc_tw_center(scene, bp->vec);
|
||||
calc_tw_center(tbounds, bp->vec);
|
||||
totsel++;
|
||||
}
|
||||
bp++;
|
||||
@@ -777,13 +777,13 @@ static int calc_manipulator_stats(const bContext *C)
|
||||
MetaElem *ml;
|
||||
|
||||
if ((v3d->around == V3D_AROUND_ACTIVE) && (ml = mb->lastelem)) {
|
||||
calc_tw_center(scene, &ml->x);
|
||||
calc_tw_center(tbounds, &ml->x);
|
||||
totsel++;
|
||||
}
|
||||
else {
|
||||
for (ml = mb->editelems->first; ml; ml = ml->next) {
|
||||
if (ml->flag & SELECT) {
|
||||
calc_tw_center(scene, &ml->x);
|
||||
calc_tw_center(tbounds, &ml->x);
|
||||
totsel++;
|
||||
}
|
||||
}
|
||||
@@ -794,7 +794,7 @@ static int calc_manipulator_stats(const bContext *C)
|
||||
BPoint *bp;
|
||||
|
||||
if ((v3d->around == V3D_AROUND_ACTIVE) && (bp = BKE_lattice_active_point_get(lt))) {
|
||||
calc_tw_center(scene, bp->vec);
|
||||
calc_tw_center(tbounds, bp->vec);
|
||||
totsel++;
|
||||
}
|
||||
else {
|
||||
@@ -802,7 +802,7 @@ static int calc_manipulator_stats(const bContext *C)
|
||||
a = lt->pntsu * lt->pntsv * lt->pntsw;
|
||||
while (a--) {
|
||||
if (bp->f1 & SELECT) {
|
||||
calc_tw_center(scene, bp->vec);
|
||||
calc_tw_center(tbounds, bp->vec);
|
||||
totsel++;
|
||||
}
|
||||
bp++;
|
||||
@@ -812,10 +812,10 @@ static int calc_manipulator_stats(const bContext *C)
|
||||
|
||||
/* selection center */
|
||||
if (totsel) {
|
||||
mul_v3_fl(scene->twcent, 1.0f / (float)totsel); // centroid!
|
||||
mul_m4_v3(obedit->obmat, scene->twcent);
|
||||
mul_m4_v3(obedit->obmat, scene->twmin);
|
||||
mul_m4_v3(obedit->obmat, scene->twmax);
|
||||
mul_v3_fl(tbounds->center, 1.0f / (float)totsel); // centroid!
|
||||
mul_m4_v3(obedit->obmat, tbounds->center);
|
||||
mul_m4_v3(obedit->obmat, tbounds->min);
|
||||
mul_m4_v3(obedit->obmat, tbounds->max);
|
||||
}
|
||||
}
|
||||
else if (ob && (ob->mode & OB_MODE_POSE)) {
|
||||
@@ -827,7 +827,7 @@ static int calc_manipulator_stats(const bContext *C)
|
||||
/* doesn't check selection or visibility intentionally */
|
||||
Bone *bone = pchan->bone;
|
||||
if (bone) {
|
||||
calc_tw_center(scene, pchan->pose_head);
|
||||
calc_tw_center(tbounds, pchan->pose_head);
|
||||
protectflag_to_drawflags_pchan(rv3d, pchan);
|
||||
totsel = 1;
|
||||
ok = true;
|
||||
@@ -841,7 +841,7 @@ static int calc_manipulator_stats(const bContext *C)
|
||||
for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
|
||||
Bone *bone = pchan->bone;
|
||||
if (bone && (bone->flag & BONE_TRANSFORM)) {
|
||||
calc_tw_center(scene, pchan->pose_head);
|
||||
calc_tw_center(tbounds, pchan->pose_head);
|
||||
protectflag_to_drawflags_pchan(rv3d, pchan);
|
||||
}
|
||||
}
|
||||
@@ -850,10 +850,10 @@ static int calc_manipulator_stats(const bContext *C)
|
||||
}
|
||||
|
||||
if (ok) {
|
||||
mul_v3_fl(scene->twcent, 1.0f / (float)totsel); // centroid!
|
||||
mul_m4_v3(ob->obmat, scene->twcent);
|
||||
mul_m4_v3(ob->obmat, scene->twmin);
|
||||
mul_m4_v3(ob->obmat, scene->twmax);
|
||||
mul_v3_fl(tbounds->center, 1.0f / (float)totsel); // centroid!
|
||||
mul_m4_v3(ob->obmat, tbounds->center);
|
||||
mul_m4_v3(ob->obmat, tbounds->min);
|
||||
mul_m4_v3(ob->obmat, tbounds->max);
|
||||
}
|
||||
}
|
||||
else if (ob && (ob->mode & OB_MODE_ALL_PAINT)) {
|
||||
@@ -872,7 +872,7 @@ static int calc_manipulator_stats(const bContext *C)
|
||||
|
||||
for (k = 0, ek = point->keys; k < point->totkey; k++, ek++) {
|
||||
if (ek->flag & PEK_SELECT) {
|
||||
calc_tw_center(scene, (ek->flag & PEK_USE_WCO) ? ek->world_co : ek->co);
|
||||
calc_tw_center(tbounds, (ek->flag & PEK_USE_WCO) ? ek->world_co : ek->co);
|
||||
totsel++;
|
||||
}
|
||||
}
|
||||
@@ -880,7 +880,7 @@ static int calc_manipulator_stats(const bContext *C)
|
||||
|
||||
/* selection center */
|
||||
if (totsel)
|
||||
mul_v3_fl(scene->twcent, 1.0f / (float)totsel); // centroid!
|
||||
mul_v3_fl(tbounds->center, 1.0f / (float)totsel); // centroid!
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -894,7 +894,7 @@ static int calc_manipulator_stats(const bContext *C)
|
||||
if (TESTBASELIB_NEW(base)) {
|
||||
if (ob == NULL)
|
||||
ob = base->object;
|
||||
calc_tw_center(scene, base->object->obmat[3]);
|
||||
calc_tw_center(tbounds, base->object->obmat[3]);
|
||||
protectflag_to_drawflags(base->object->protectflag, &rv3d->twdrawflag);
|
||||
totsel++;
|
||||
}
|
||||
@@ -902,7 +902,7 @@ static int calc_manipulator_stats(const bContext *C)
|
||||
|
||||
/* selection center */
|
||||
if (totsel) {
|
||||
mul_v3_fl(scene->twcent, 1.0f / (float)totsel); // centroid!
|
||||
mul_v3_fl(tbounds->center, 1.0f / (float)totsel); // centroid!
|
||||
}
|
||||
}
|
||||
|
||||
@@ -988,7 +988,8 @@ static void manipulator_get_idot(RegionView3D *rv3d, float r_idot[3])
|
||||
}
|
||||
}
|
||||
|
||||
static void manipulator_prepare_mat(const bContext *C, View3D *v3d, RegionView3D *rv3d)
|
||||
static void manipulator_prepare_mat(
|
||||
const bContext *C, View3D *v3d, RegionView3D *rv3d, const struct TransformBounds *tbounds)
|
||||
{
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
SceneLayer *sl = CTX_data_scene_layer(C);
|
||||
@@ -1007,13 +1008,13 @@ static void manipulator_prepare_mat(const bContext *C, View3D *v3d, RegionView3D
|
||||
copy_v3_v3(rv3d->twmat[3], ob->obmat[3]);
|
||||
}
|
||||
else {
|
||||
mid_v3_v3v3(rv3d->twmat[3], scene->twmin, scene->twmax);
|
||||
mid_v3_v3v3(rv3d->twmat[3], tbounds->min, tbounds->max);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case V3D_AROUND_LOCAL_ORIGINS:
|
||||
case V3D_AROUND_CENTER_MEAN:
|
||||
copy_v3_v3(rv3d->twmat[3], scene->twcent);
|
||||
copy_v3_v3(rv3d->twmat[3], tbounds->center);
|
||||
break;
|
||||
case V3D_AROUND_CURSOR:
|
||||
copy_v3_v3(rv3d->twmat[3], ED_view3d_cursor3d_get(scene, v3d));
|
||||
@@ -1120,9 +1121,11 @@ static int manipulator_modal(
|
||||
ARegion *ar = CTX_wm_region(C);
|
||||
View3D *v3d = sa->spacedata.first;
|
||||
RegionView3D *rv3d = ar->regiondata;
|
||||
struct TransformBounds tbounds;
|
||||
|
||||
if (calc_manipulator_stats(C)) {
|
||||
manipulator_prepare_mat(C, v3d, rv3d);
|
||||
|
||||
if (calc_manipulator_stats(C, &tbounds)) {
|
||||
manipulator_prepare_mat(C, v3d, rv3d, &tbounds);
|
||||
WM_manipulator_set_matrix_location(widget, rv3d->twmat[3]);
|
||||
}
|
||||
|
||||
@@ -1254,12 +1257,13 @@ static void WIDGETGROUP_manipulator_refresh(const bContext *C, wmManipulatorGrou
|
||||
ARegion *ar = CTX_wm_region(C);
|
||||
View3D *v3d = sa->spacedata.first;
|
||||
RegionView3D *rv3d = ar->regiondata;
|
||||
struct TransformBounds tbounds;
|
||||
|
||||
/* skip, we don't draw anything anyway */
|
||||
if ((man->all_hidden = (calc_manipulator_stats(C) == 0)))
|
||||
if ((man->all_hidden = (calc_manipulator_stats(C, &tbounds) == 0)))
|
||||
return;
|
||||
|
||||
manipulator_prepare_mat(C, v3d, rv3d);
|
||||
manipulator_prepare_mat(C, v3d, rv3d, &tbounds);
|
||||
|
||||
/* *** set properties for axes *** */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user