Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/transform/transform_gizmo_3d.c
| Show First 20 Lines • Show All 875 Lines • ▼ Show 20 Lines | else if (obedit->type == OB_ARMATURE) { | ||||
| ((ebo->flag & BONE_TIPSEL) == false)) /* ensure we get at least one point */ | ((ebo->flag & BONE_TIPSEL) == false)) /* ensure we get at least one point */ | ||||
| { | { | ||||
| calc_tw_center(tbounds, ebo->head); | calc_tw_center(tbounds, ebo->head); | ||||
| totsel++; | totsel++; | ||||
| } | } | ||||
| protectflag_to_drawflags_ebone(rv3d, ebo); | protectflag_to_drawflags_ebone(rv3d, ebo); | ||||
| } | } | ||||
| else { | else { | ||||
| /* TODO: multi-object support. */ | uint objects_len = 0; | ||||
| Object **objects = BKE_view_layer_array_from_objects_in_edit_mode(view_layer, &objects_len); | |||||
| float mat_local[4][4]; | |||||
| invert_m4_m4(obedit->imat, obedit->obmat); | |||||
| for (uint ob_index = 0; ob_index < objects_len; ob_index++) { | |||||
| Object *ob_iter = objects[ob_index]; | |||||
| arm = ob_iter->data; | |||||
| for (ebo = arm->edbo->first; ebo; ebo = ebo->next) { | for (ebo = arm->edbo->first; ebo; ebo = ebo->next) { | ||||
| if (EBONE_VISIBLE(arm, ebo)) { | if (EBONE_VISIBLE(arm, ebo)) { | ||||
| const bool use_mat_local = (ob_iter != obedit); | |||||
| if (use_mat_local) { | |||||
| mul_m4_m4m4(mat_local, obedit->imat, ob_iter->obmat); | |||||
| } | |||||
| if (ebo->flag & BONE_TIPSEL) { | if (ebo->flag & BONE_TIPSEL) { | ||||
| calc_tw_center(tbounds, ebo->tail); | float co[3]; | ||||
| if (use_mat_local) { | |||||
| mul_v3_m4v3(co, mat_local, ebo->tail); | |||||
| } | |||||
| else { | |||||
| copy_v3_v3(co, ebo->tail); | |||||
| } | |||||
| calc_tw_center(tbounds, co); | |||||
| totsel++; | totsel++; | ||||
| } | } | ||||
| if ((ebo->flag & BONE_ROOTSEL) && | if ((ebo->flag & BONE_ROOTSEL) && | ||||
| /* don't include same point multiple times */ | /* don't include same point multiple times */ | ||||
| ((ebo->flag & BONE_CONNECTED) && | ((ebo->flag & BONE_CONNECTED) && | ||||
| (ebo->parent != NULL) && | (ebo->parent != NULL) && | ||||
| (ebo->parent->flag & BONE_TIPSEL) && | (ebo->parent->flag & BONE_TIPSEL) && | ||||
| EBONE_VISIBLE(arm, ebo->parent)) == 0) | EBONE_VISIBLE(arm, ebo->parent)) == 0) | ||||
| { | { | ||||
| calc_tw_center(tbounds, ebo->head); | float co[3]; | ||||
| if (use_mat_local) { | |||||
| mul_v3_m4v3(co, mat_local, ebo->head); | |||||
| } | |||||
| else { | |||||
| copy_v3_v3(co, ebo->head); | |||||
| } | |||||
| calc_tw_center(tbounds, co); | |||||
| totsel++; | totsel++; | ||||
| } | } | ||||
| if (ebo->flag & BONE_SELECTED) { | if (ebo->flag & BONE_SELECTED) { | ||||
| protectflag_to_drawflags_ebone(rv3d, ebo); | protectflag_to_drawflags_ebone(rv3d, ebo); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| MEM_freeN(objects); | |||||
| } | |||||
| } | } | ||||
| else if (ELEM(obedit->type, OB_CURVE, OB_SURF)) { | else if (ELEM(obedit->type, OB_CURVE, OB_SURF)) { | ||||
| Curve *cu = obedit->data; | Curve *cu = obedit->data; | ||||
| float center[3]; | float center[3]; | ||||
| if ((pivot_point == V3D_AROUND_ACTIVE) && ED_curve_active_center(cu, center)) { | if ((pivot_point == V3D_AROUND_ACTIVE) && ED_curve_active_center(cu, center)) { | ||||
| calc_tw_center(tbounds, center); | calc_tw_center(tbounds, center); | ||||
| totsel++; | totsel++; | ||||
| } | } | ||||
| else { | else { | ||||
| /* TODO: multi-object support. */ | uint objects_len = 0; | ||||
| Object **objects = BKE_view_layer_array_from_objects_in_edit_mode(view_layer, &objects_len); | |||||
| float mat_local[4][4]; | |||||
| invert_m4_m4(obedit->imat, obedit->obmat); | |||||
| for (uint ob_index = 0; ob_index < objects_len; ob_index++) { | |||||
| Object *ob_iter = objects[ob_index]; | |||||
| cu = ob_iter->data; | |||||
| Nurb *nu; | Nurb *nu; | ||||
| BezTriple *bezt; | BezTriple *bezt; | ||||
| BPoint *bp; | BPoint *bp; | ||||
| ListBase *nurbs = BKE_curve_editNurbs_get(cu); | ListBase *nurbs = BKE_curve_editNurbs_get(cu); | ||||
| const bool use_mat_local = (ob_iter != obedit); | |||||
| if (use_mat_local) { | |||||
| mul_m4_m4m4(mat_local, obedit->imat, ob_iter->obmat); | |||||
| } | |||||
| nu = nurbs->first; | nu = nurbs->first; | ||||
| while (nu) { | while (nu) { | ||||
| if (nu->type == CU_BEZIER) { | if (nu->type == CU_BEZIER) { | ||||
| bezt = nu->bezt; | bezt = nu->bezt; | ||||
| a = nu->pntsu; | a = nu->pntsu; | ||||
| while (a--) { | while (a--) { | ||||
| /* exceptions | /* exceptions | ||||
| * if handles are hidden then only check the center points. | * if handles are hidden then only check the center points. | ||||
| * If the center knot is selected then only use this as the center point. | * If the center knot is selected then only use this as the center point. | ||||
| */ | */ | ||||
| if ((v3d->overlay.edit_flag & V3D_OVERLAY_EDIT_CU_HANDLES) == 0) { | if ((v3d->overlay.edit_flag & V3D_OVERLAY_EDIT_CU_HANDLES) == 0) { | ||||
| if (bezt->f2 & SELECT) { | if (bezt->f2 & SELECT) { | ||||
| calc_tw_center(tbounds, bezt->vec[1]); | float co[3]; | ||||
| if (use_mat_local) { | |||||
| mul_v3_m4v3(co, mat_local, bezt->vec[1]); | |||||
| } | |||||
| else { | |||||
| copy_v3_v3(co, bezt->vec[1]); | |||||
| } | |||||
| calc_tw_center(tbounds, co); | |||||
| totsel++; | totsel++; | ||||
| } | } | ||||
| } | } | ||||
| else if (bezt->f2 & SELECT) { | else if (bezt->f2 & SELECT) { | ||||
| calc_tw_center(tbounds, bezt->vec[1]); | float co[3]; | ||||
| if (use_mat_local) { | |||||
| mul_v3_m4v3(co, mat_local, bezt->vec[1]); | |||||
| } | |||||
| else { | |||||
| copy_v3_v3(co, bezt->vec[1]); | |||||
| } | |||||
| calc_tw_center(tbounds, co); | |||||
| totsel++; | totsel++; | ||||
| } | } | ||||
| else { | else { | ||||
| if (bezt->f1 & SELECT) { | if (bezt->f1 & SELECT) { | ||||
| calc_tw_center( | float co[3]; | ||||
| tbounds, bezt->vec[(pivot_point == V3D_AROUND_LOCAL_ORIGINS) ? 1 : 0]); | if (use_mat_local) { | ||||
| mul_v3_m4v3(co, mat_local, | |||||
| bezt->vec[(pivot_point == V3D_AROUND_LOCAL_ORIGINS) ? 1 : 0]); | |||||
| } | |||||
| else { | |||||
| copy_v3_v3(co, | |||||
| bezt->vec[(pivot_point == V3D_AROUND_LOCAL_ORIGINS) ? 1 : 0]); | |||||
| } | |||||
| calc_tw_center(tbounds, co); | |||||
| totsel++; | totsel++; | ||||
| } | } | ||||
| if (bezt->f3 & SELECT) { | if (bezt->f3 & SELECT) { | ||||
| calc_tw_center( | float co[3]; | ||||
| tbounds, bezt->vec[(pivot_point == V3D_AROUND_LOCAL_ORIGINS) ? 1 : 2]); | if (use_mat_local) { | ||||
| mul_v3_m4v3(co, mat_local, | |||||
| bezt->vec[(pivot_point == V3D_AROUND_LOCAL_ORIGINS) ? 1 : 2]); | |||||
| } | |||||
| else { | |||||
| copy_v3_v3(co, | |||||
| bezt->vec[(pivot_point == V3D_AROUND_LOCAL_ORIGINS) ? 1 : 2]); | |||||
| } | |||||
| calc_tw_center(tbounds, co); | |||||
| totsel++; | totsel++; | ||||
| } | } | ||||
| } | } | ||||
| bezt++; | bezt++; | ||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| bp = nu->bp; | bp = nu->bp; | ||||
| a = nu->pntsu * nu->pntsv; | a = nu->pntsu * nu->pntsv; | ||||
| while (a--) { | while (a--) { | ||||
| if (bp->f1 & SELECT) { | if (bp->f1 & SELECT) { | ||||
| calc_tw_center(tbounds, bp->vec); | float co[3]; | ||||
| if (use_mat_local) { | |||||
| mul_v3_m4v3(co, mat_local, bp->vec); | |||||
| } | |||||
| else { | |||||
| copy_v3_v3(co, bp->vec); | |||||
| } | |||||
| calc_tw_center(tbounds, co); | |||||
| totsel++; | totsel++; | ||||
| } | } | ||||
| bp++; | bp++; | ||||
| } | } | ||||
| } | } | ||||
| nu = nu->next; | nu = nu->next; | ||||
| } | } | ||||
| MEM_freeN(objects); | |||||
| } | |||||
| } | } | ||||
| } | } | ||||
| else if (obedit->type == OB_MBALL) { | else if (obedit->type == OB_MBALL) { | ||||
| MetaBall *mb = (MetaBall *)obedit->data; | MetaBall *mb = (MetaBall *)obedit->data; | ||||
| MetaElem *ml; | MetaElem *ml; | ||||
| if ((pivot_point == V3D_AROUND_ACTIVE) && (ml = mb->lastelem)) { | if ((pivot_point == V3D_AROUND_ACTIVE) && (ml = mb->lastelem)) { | ||||
| calc_tw_center(tbounds, &ml->x); | calc_tw_center(tbounds, &ml->x); | ||||
| ▲ Show 20 Lines • Show All 1,201 Lines • Show Last 20 Lines | |||||