Gizmo: use general active center calculation
There are some minor differences in center calculation but I don't think they're important, if so we can update the code. - Edit-bone uses head (instead of the middle when both are selected). - Edit-bone flag for restricting components uses the selection instead of the active bone.
This commit is contained in:
parent
0835c224ba
commit
81ea815dcb
Notes:
blender-bot
2023-02-14 06:54:28 +01:00
Referenced by issue #59489, GLIBC on CentOS 7.5 Referenced by issue #59391, 2.80 Crash on selecting an entire collection and snappping cursor to active. Referenced by issue #59303, crash when clicking "change shortcut" on the contextual menu Referenced by issue #59287, Using the Bevel Modifier crashes Blender
|
@ -862,21 +862,6 @@ int ED_transform_calc_gizmo_stats(
|
|||
}
|
||||
}
|
||||
} FOREACH_EDIT_OBJECT_END();
|
||||
|
||||
/* Around active, only if there is a selection. The active
|
||||
* element itself does not have to be selected. */
|
||||
if ((pivot_point == V3D_AROUND_ACTIVE) && totsel) {
|
||||
BMEditMesh *em = BKE_editmesh_from_object(obedit);
|
||||
BMEditSelection ese;
|
||||
|
||||
if (BM_select_history_active_get(em->bm, &ese)) {
|
||||
float vec[3] = {0, 0, 0};
|
||||
BM_editselection_center(&ese, vec);
|
||||
reset_tw_center(tbounds);
|
||||
calc_tw_center(tbounds, vec);
|
||||
totsel = 1;
|
||||
}
|
||||
}
|
||||
} /* end editmesh */
|
||||
else if (obedit->type == OB_ARMATURE) {
|
||||
FOREACH_EDIT_OBJECT_BEGIN(ob_iter, use_mat_local) {
|
||||
|
@ -908,31 +893,6 @@ int ED_transform_calc_gizmo_stats(
|
|||
}
|
||||
}
|
||||
} FOREACH_EDIT_OBJECT_END();
|
||||
|
||||
/* Around active, only if there is a selection. The active
|
||||
* element itself does not have to be selected. */
|
||||
if ((pivot_point == V3D_AROUND_ACTIVE) && totsel) {
|
||||
bArmature *arm = obedit->data;
|
||||
EditBone *ebo = arm->act_edbone;
|
||||
|
||||
if (ebo) {
|
||||
reset_tw_center(tbounds);
|
||||
rv3d->twdrawflag = 0xFFFF;
|
||||
totsel = 0;
|
||||
|
||||
if (ebo->flag & BONE_TIPSEL) {
|
||||
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(tbounds, ebo->head);
|
||||
totsel++;
|
||||
}
|
||||
protectflag_to_drawflags_ebone(rv3d, ebo);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (ELEM(obedit->type, OB_CURVE, OB_SURF)) {
|
||||
FOREACH_EDIT_OBJECT_BEGIN(ob_iter, use_mat_local) {
|
||||
|
@ -996,19 +956,6 @@ int ED_transform_calc_gizmo_stats(
|
|||
nu = nu->next;
|
||||
}
|
||||
} FOREACH_EDIT_OBJECT_END();
|
||||
|
||||
/* Around active, only if there is a selection. The active
|
||||
* element itself does not have to be selected. */
|
||||
if ((pivot_point == V3D_AROUND_ACTIVE) && totsel) {
|
||||
Curve *cu = obedit->data;
|
||||
float center[3];
|
||||
|
||||
if (ED_curve_active_center(cu, center)) {
|
||||
reset_tw_center(tbounds);
|
||||
calc_tw_center(tbounds, center);
|
||||
totsel = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (obedit->type == OB_MBALL) {
|
||||
FOREACH_EDIT_OBJECT_BEGIN(ob_iter, use_mat_local) {
|
||||
|
@ -1026,19 +973,6 @@ int ED_transform_calc_gizmo_stats(
|
|||
}
|
||||
}
|
||||
} FOREACH_EDIT_OBJECT_END();
|
||||
|
||||
/* Around active, only if there is a selection. The active
|
||||
* element itself does not have to be selected. */
|
||||
if ((pivot_point == V3D_AROUND_ACTIVE) && totsel) {
|
||||
MetaBall *mb = (MetaBall *)obedit->data;
|
||||
MetaElem *ml = mb->lastelem;
|
||||
|
||||
if (ml) {
|
||||
reset_tw_center(tbounds);
|
||||
calc_tw_center(tbounds, &ml->x);
|
||||
totsel = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (obedit->type == OB_LATTICE) {
|
||||
FOREACH_EDIT_OBJECT_BEGIN(ob_iter, use_mat_local) {
|
||||
|
@ -1059,19 +993,6 @@ int ED_transform_calc_gizmo_stats(
|
|||
bp++;
|
||||
}
|
||||
} FOREACH_EDIT_OBJECT_END();
|
||||
|
||||
/* Around active, only if there is a selection. The active
|
||||
* element itself does not have to be selected. */
|
||||
if ((pivot_point == V3D_AROUND_ACTIVE) && totsel) {
|
||||
Lattice *lt = ((Lattice *)obedit->data)->editlatt->latt;
|
||||
BPoint *bp = BKE_lattice_active_point_get(lt);
|
||||
|
||||
if (bp) {
|
||||
reset_tw_center(tbounds);
|
||||
calc_tw_center(tbounds, bp->vec);
|
||||
totsel = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#undef FOREACH_EDIT_OBJECT_BEGIN
|
||||
|
@ -1092,22 +1013,12 @@ int ED_transform_calc_gizmo_stats(
|
|||
totsel = count_set_pose_transflags(ob, mode, V3D_AROUND_CENTER_BOUNDS, NULL);
|
||||
|
||||
if (totsel) {
|
||||
if ((pivot_point == V3D_AROUND_ACTIVE) &&
|
||||
(pchan = BKE_pose_channel_active(ob)))
|
||||
{
|
||||
/* Doesn't check selection or visibility of the active bone intentionally. */
|
||||
calc_tw_center(tbounds, pchan->pose_head);
|
||||
protectflag_to_drawflags_pchan(rv3d, pchan);
|
||||
totsel = 1;
|
||||
}
|
||||
else {
|
||||
/* use channels to get stats */
|
||||
for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
|
||||
Bone *bone = pchan->bone;
|
||||
if (bone && (bone->flag & BONE_TRANSFORM)) {
|
||||
calc_tw_center(tbounds, pchan->pose_head);
|
||||
protectflag_to_drawflags_pchan(rv3d, pchan);
|
||||
}
|
||||
/* use channels to get stats */
|
||||
for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
|
||||
Bone *bone = pchan->bone;
|
||||
if (bone && (bone->flag & BONE_TRANSFORM)) {
|
||||
calc_tw_center(tbounds, pchan->pose_head);
|
||||
protectflag_to_drawflags_pchan(rv3d, pchan);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1217,18 +1128,17 @@ static void gizmo_prepare_mat(
|
|||
case V3D_AROUND_CENTER_BOUNDS:
|
||||
case V3D_AROUND_ACTIVE:
|
||||
{
|
||||
bGPdata *gpd = CTX_data_gpencil_data(C);
|
||||
Object *ob = OBACT(view_layer);
|
||||
mid_v3_v3v3(rv3d->twmat[3], tbounds->min, tbounds->max);
|
||||
|
||||
if (((scene->toolsettings->transform_pivot_point == V3D_AROUND_ACTIVE) &&
|
||||
(OBEDIT_FROM_OBACT(ob) == NULL)) &&
|
||||
((gpd == NULL) || !(gpd->flag & GP_DATA_STROKE_EDITMODE)) &&
|
||||
(!(ob->mode & OB_MODE_POSE)))
|
||||
{
|
||||
copy_v3_v3(rv3d->twmat[3], ob->obmat[3]);
|
||||
}
|
||||
else {
|
||||
mid_v3_v3v3(rv3d->twmat[3], tbounds->min, tbounds->max);
|
||||
if (scene->toolsettings->transform_pivot_point == V3D_AROUND_ACTIVE) {
|
||||
bGPdata *gpd = CTX_data_gpencil_data(C);
|
||||
Object *ob = OBACT(view_layer);
|
||||
if (gpd && (gpd->flag & GP_DATA_STROKE_EDITMODE)) {
|
||||
/* pass */
|
||||
}
|
||||
else if (ob != NULL) {
|
||||
ED_object_calc_active_center(ob, false, rv3d->twmat[3]);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue