Replace Bone Layers+Groups with Bone Collections #109976
|
@ -267,29 +267,29 @@ void BKE_pose_channel_session_uuid_generate(struct bPoseChannel *pchan);
|
|||
*/
|
||||
struct bPoseChannel *BKE_pose_channel_find_name(const struct bPose *pose, const char *name);
|
||||
/**
|
||||
* Checks if the bone is on a visible armature layer
|
||||
* Checks if the bone is on a visible bone collection
|
||||
*
|
||||
* \return true if on a visible layer, false otherwise.
|
||||
*/
|
||||
bool BKE_pose_is_layer_visible(const struct bArmature *arm,
|
||||
const struct bPoseChannel *pchan) ATTR_WARN_UNUSED_RESULT;
|
||||
bool BKE_pose_is_bonecoll_visible(const struct bArmature *arm,
|
||||
const struct bPoseChannel *pchan) ATTR_WARN_UNUSED_RESULT;
|
||||
/**
|
||||
* Find the active pose-channel for an object
|
||||
*
|
||||
* \param check_arm_layer: checks if the bone is on a visible armature layer (this might be skipped
|
||||
* \param check_bonecoll: checks if the bone is on a visible bone collection (this might be skipped
|
||||
* (e.g. for "Show Active" from the Outliner).
|
||||
* \return #bPoseChannel if found or NULL.
|
||||
* \note #Object, not #bPose is used here, as we need info (layer/active bone) from Armature.
|
||||
* \note #Object, not #bPose is used here, as we need info (collection/active bone) from Armature.
|
||||
*/
|
||||
struct bPoseChannel *BKE_pose_channel_active(struct Object *ob, bool check_arm_layer);
|
||||
struct bPoseChannel *BKE_pose_channel_active(struct Object *ob, bool check_bonecoll);
|
||||
/**
|
||||
* Find the active pose-channel for an object if it is on a visible armature layer
|
||||
* (calls #BKE_pose_channel_active with check_arm_layer set to true)
|
||||
* Find the active pose-channel for an object if it is on a visible bone collection
|
||||
* (calls #BKE_pose_channel_active with check_bonecoll set to true)
|
||||
*
|
||||
* \return #bPoseChannel if found or NULL.
|
||||
* \note #Object, not #bPose is used here, as we need info (layer/active bone) from Armature.
|
||||
* \note #Object, not #bPose is used here, as we need info (collection/active bone) from Armature.
|
||||
*/
|
||||
struct bPoseChannel *BKE_pose_channel_active_if_layer_visible(struct Object *ob)
|
||||
struct bPoseChannel *BKE_pose_channel_active_if_bonecoll_visible(struct Object *ob)
|
||||
ATTR_WARN_UNUSED_RESULT;
|
||||
/**
|
||||
* Use this when detecting the "other selected bone",
|
||||
|
|
|
@ -680,12 +680,12 @@ bool BKE_pose_channels_is_valid(const bPose *pose)
|
|||
|
||||
#endif
|
||||
|
||||
bool BKE_pose_is_layer_visible(const bArmature *arm, const bPoseChannel *pchan)
|
||||
bool BKE_pose_is_bonecoll_visible(const bArmature *arm, const bPoseChannel *pchan)
|
||||
{
|
||||
return (pchan->bone->layer & arm->layer);
|
||||
return pchan->bone && ANIM_bonecoll_is_visible(arm, pchan->bone);
|
||||
}
|
||||
|
||||
bPoseChannel *BKE_pose_channel_active(Object *ob, const bool check_arm_layer)
|
||||
bPoseChannel *BKE_pose_channel_active(Object *ob, const bool check_bonecoll)
|
||||
{
|
||||
bArmature *arm = static_cast<bArmature *>((ob) ? ob->data : nullptr);
|
||||
if (ELEM(nullptr, ob, ob->pose, arm)) {
|
||||
|
@ -695,7 +695,7 @@ bPoseChannel *BKE_pose_channel_active(Object *ob, const bool check_arm_layer)
|
|||
/* find active */
|
||||
LISTBASE_FOREACH (bPoseChannel *, pchan, &ob->pose->chanbase) {
|
||||
if ((pchan->bone) && (pchan->bone == arm->act_bone)) {
|
||||
if (!check_arm_layer || BKE_pose_is_layer_visible(arm, pchan)) {
|
||||
if (!check_bonecoll || ANIM_bonecoll_is_visible(arm, pchan->bone)) {
|
||||
return pchan;
|
||||
}
|
||||
}
|
||||
|
@ -704,7 +704,7 @@ bPoseChannel *BKE_pose_channel_active(Object *ob, const bool check_arm_layer)
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
bPoseChannel *BKE_pose_channel_active_if_layer_visible(Object *ob)
|
||||
bPoseChannel *BKE_pose_channel_active_if_bonecoll_visible(Object *ob)
|
||||
{
|
||||
return BKE_pose_channel_active(ob, true);
|
||||
}
|
||||
|
@ -717,7 +717,7 @@ bPoseChannel *BKE_pose_channel_active_or_first_selected(Object *ob)
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
bPoseChannel *pchan = BKE_pose_channel_active_if_layer_visible(ob);
|
||||
bPoseChannel *pchan = BKE_pose_channel_active_if_bonecoll_visible(ob);
|
||||
if (pchan && (pchan->bone->flag & BONE_SELECTED) && PBONE_VISIBLE(arm, pchan->bone)) {
|
||||
return pchan;
|
||||
}
|
||||
|
|
|
@ -753,7 +753,7 @@ static int pose_select_hierarchy_exec(bContext *C, wmOperator *op)
|
|||
const bool add_to_sel = RNA_boolean_get(op->ptr, "extend");
|
||||
bool changed = false;
|
||||
|
||||
pchan_act = BKE_pose_channel_active_if_layer_visible(ob);
|
||||
pchan_act = BKE_pose_channel_active_if_bonecoll_visible(ob);
|
||||
if (pchan_act == nullptr) {
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
|
|
@ -78,7 +78,7 @@ ListBase *ED_object_constraint_active_list(Object *ob)
|
|||
if (ob->mode & OB_MODE_POSE) {
|
||||
bPoseChannel *pchan;
|
||||
|
||||
pchan = BKE_pose_channel_active_if_layer_visible(ob);
|
||||
pchan = BKE_pose_channel_active_if_bonecoll_visible(ob);
|
||||
if (pchan) {
|
||||
return &pchan->constraints;
|
||||
}
|
||||
|
@ -2204,7 +2204,7 @@ static bool get_new_constraint_target(
|
|||
bContext *C, int con_type, Object **tar_ob, bPoseChannel **tar_pchan, bool add)
|
||||
{
|
||||
Object *obact = ED_object_active_context(C);
|
||||
bPoseChannel *pchanact = BKE_pose_channel_active_if_layer_visible(obact);
|
||||
bPoseChannel *pchanact = BKE_pose_channel_active_if_bonecoll_visible(obact);
|
||||
bool only_curve = false, only_mesh = false, only_ob = false;
|
||||
bool found = false;
|
||||
|
||||
|
@ -2362,7 +2362,7 @@ static int constraint_add_exec(
|
|||
pchan = nullptr;
|
||||
}
|
||||
else {
|
||||
pchan = BKE_pose_channel_active_if_layer_visible(ob);
|
||||
pchan = BKE_pose_channel_active_if_bonecoll_visible(ob);
|
||||
|
||||
/* ensure not to confuse object/pose adding */
|
||||
if (pchan == nullptr) {
|
||||
|
@ -2636,7 +2636,7 @@ void POSE_OT_constraint_add_with_targets(wmOperatorType *ot)
|
|||
static int pose_ik_add_invoke(bContext *C, wmOperator *op, const wmEvent * /*event*/)
|
||||
{
|
||||
Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C));
|
||||
bPoseChannel *pchan = BKE_pose_channel_active_if_layer_visible(ob);
|
||||
bPoseChannel *pchan = BKE_pose_channel_active_if_bonecoll_visible(ob);
|
||||
bConstraint *con = nullptr;
|
||||
|
||||
uiPopupMenu *pup;
|
||||
|
|
|
@ -577,7 +577,7 @@ static int add_hook_object(const bContext *C,
|
|||
|
||||
STRNCPY(hmd->subtarget, arm->act_bone->name);
|
||||
|
||||
pchan_act = BKE_pose_channel_active_if_layer_visible(ob);
|
||||
pchan_act = BKE_pose_channel_active_if_bonecoll_visible(ob);
|
||||
if (LIKELY(pchan_act)) {
|
||||
invert_m4_m4(pose_mat, pchan_act->pose_mat);
|
||||
mul_v3_m4v3(cent, ob->object_to_world, pchan_act->pose_mat[3]);
|
||||
|
|
|
@ -571,8 +571,8 @@ bool ED_object_parent_set(ReportList *reports,
|
|||
}
|
||||
case PAR_BONE:
|
||||
case PAR_BONE_RELATIVE:
|
||||
pchan = BKE_pose_channel_active_if_layer_visible(par);
|
||||
pchan_eval = BKE_pose_channel_active_if_layer_visible(parent_eval);
|
||||
pchan = BKE_pose_channel_active_if_bonecoll_visible(par);
|
||||
pchan_eval = BKE_pose_channel_active_if_bonecoll_visible(parent_eval);
|
||||
|
||||
if (pchan == nullptr || pchan_eval == nullptr) {
|
||||
/* If pchan_eval is nullptr, pchan should also be nullptr. */
|
||||
|
|
|
@ -105,7 +105,7 @@ bool ED_object_calc_active_center_for_posemode(Object *ob,
|
|||
const bool select_only,
|
||||
float r_center[3])
|
||||
{
|
||||
bPoseChannel *pchan = BKE_pose_channel_active_if_layer_visible(ob);
|
||||
bPoseChannel *pchan = BKE_pose_channel_active_if_bonecoll_visible(ob);
|
||||
if (pchan && (!select_only || (pchan->bone->flag & BONE_SELECTED))) {
|
||||
copy_v3_v3(r_center, pchan->pose_head);
|
||||
return true;
|
||||
|
|
|
@ -522,7 +522,7 @@ static eContextResult screen_ctx_active_pose_bone(const bContext *C, bContextDat
|
|||
Object *obact = BKE_view_layer_active_object_get(view_layer);
|
||||
Object *obpose = BKE_object_pose_armature_get(obact);
|
||||
|
||||
bPoseChannel *pchan = BKE_pose_channel_active_if_layer_visible(obpose);
|
||||
bPoseChannel *pchan = BKE_pose_channel_active_if_bonecoll_visible(obpose);
|
||||
if (pchan) {
|
||||
CTX_data_pointer_set(result, &obpose->id, &RNA_PoseBone, pchan);
|
||||
return CTX_RESULT_OK;
|
||||
|
|
|
@ -325,7 +325,7 @@ static void stats_object_pose(const Object *ob, SceneStats *stats)
|
|||
LISTBASE_FOREACH (bPoseChannel *, pchan, &ob->pose->chanbase) {
|
||||
stats->totbone++;
|
||||
if (pchan->bone && (pchan->bone->flag & BONE_SELECTED)) {
|
||||
if (BKE_pose_is_layer_visible(arm, pchan)) {
|
||||
if (BKE_pose_is_bonecoll_visible(arm, pchan)) {
|
||||
stats->totbonesel++;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1625,7 +1625,7 @@ static void v3d_posearmature_buts(uiLayout *layout, Object *ob)
|
|||
PointerRNA pchanptr;
|
||||
uiLayout *col;
|
||||
|
||||
pchan = BKE_pose_channel_active_if_layer_visible(ob);
|
||||
pchan = BKE_pose_channel_active_if_bonecoll_visible(ob);
|
||||
|
||||
if (!pchan) {
|
||||
uiItemL(layout, IFACE_("No Bone Active"), ICON_NONE);
|
||||
|
|
|
@ -127,7 +127,7 @@ static int view_lock_to_active_exec(bContext *C, wmOperator * /*op*/)
|
|||
if (obact->mode & OB_MODE_POSE) {
|
||||
Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
|
||||
Object *obact_eval = DEG_get_evaluated_object(depsgraph, obact);
|
||||
bPoseChannel *pcham_act = BKE_pose_channel_active_if_layer_visible(obact_eval);
|
||||
bPoseChannel *pcham_act = BKE_pose_channel_active_if_bonecoll_visible(obact_eval);
|
||||
if (pcham_act) {
|
||||
STRNCPY(v3d->ob_center_bone, pcham_act->name);
|
||||
}
|
||||
|
|
|
@ -123,7 +123,7 @@ static bool WIDGETGROUP_armature_spline_poll(const bContext *C, wmGizmoGroupType
|
|||
if (ob) {
|
||||
const bArmature *arm = static_cast<const bArmature *>(ob->data);
|
||||
if (arm->drawtype == ARM_B_BONE) {
|
||||
bPoseChannel *pchan = BKE_pose_channel_active_if_layer_visible(ob);
|
||||
bPoseChannel *pchan = BKE_pose_channel_active_if_bonecoll_visible(ob);
|
||||
if (pchan && pchan->bone->segments > 1) {
|
||||
return true;
|
||||
}
|
||||
|
@ -139,7 +139,7 @@ static void WIDGETGROUP_armature_spline_setup(const bContext *C, wmGizmoGroup *g
|
|||
ViewLayer *view_layer = CTX_data_view_layer(C);
|
||||
BKE_view_layer_synced_ensure(scene, view_layer);
|
||||
Object *ob = BKE_object_pose_armature_get(BKE_view_layer_active_object_get(view_layer));
|
||||
bPoseChannel *pchan = BKE_pose_channel_active_if_layer_visible(ob);
|
||||
bPoseChannel *pchan = BKE_pose_channel_active_if_bonecoll_visible(ob);
|
||||
|
||||
const wmGizmoType *gzt_move = WM_gizmotype_find("GIZMO_GT_move_3d", true);
|
||||
|
||||
|
@ -180,7 +180,7 @@ static void WIDGETGROUP_armature_spline_refresh(const bContext *C, wmGizmoGroup
|
|||
}
|
||||
|
||||
BoneSplineWidgetGroup *bspline_group = static_cast<BoneSplineWidgetGroup *>(gzgroup->customdata);
|
||||
bPoseChannel *pchan = BKE_pose_channel_active_if_layer_visible(ob);
|
||||
bPoseChannel *pchan = BKE_pose_channel_active_if_bonecoll_visible(ob);
|
||||
|
||||
/* Handles */
|
||||
for (int i = 0; i < ARRAY_SIZE(bspline_group->handles); i++) {
|
||||
|
|
|
@ -414,7 +414,7 @@ static short pose_grab_with_ik(Main *bmain, Object *ob)
|
|||
/* Rule: allow multiple Bones
|
||||
* (but they must be selected, and only one ik-solver per chain should get added) */
|
||||
LISTBASE_FOREACH (bPoseChannel *, pchan, &ob->pose->chanbase) {
|
||||
if (BKE_pose_is_layer_visible(arm, pchan)) {
|
||||
if (BKE_pose_is_bonecoll_visible(arm, pchan)) {
|
||||
if (pchan->bone->flag & (BONE_SELECTED | BONE_TRANSFORM_MIRROR)) {
|
||||
/* Rule: no IK for solitary (unconnected) bones. */
|
||||
for (bonec = static_cast<Bone *>(pchan->bone->childbase.first); bonec; bonec = bonec->next)
|
||||
|
|
|
@ -633,7 +633,7 @@ short ED_transform_calc_orientation_from_type_ex(const Scene *scene,
|
|||
|
||||
if (ob) {
|
||||
if (ob->mode & OB_MODE_POSE) {
|
||||
const bPoseChannel *pchan = BKE_pose_channel_active_if_layer_visible(ob);
|
||||
const bPoseChannel *pchan = BKE_pose_channel_active_if_bonecoll_visible(ob);
|
||||
if (pchan && gimbal_axis_pose(ob, pchan, r_mat)) {
|
||||
break;
|
||||
}
|
||||
|
@ -1361,7 +1361,7 @@ int getTransformOrientation_ex(const Scene *scene,
|
|||
float imat[3][3], mat[3][3];
|
||||
bool ok = false;
|
||||
|
||||
if (activeOnly && (pchan = BKE_pose_channel_active_if_layer_visible(ob))) {
|
||||
if (activeOnly && (pchan = BKE_pose_channel_active_if_bonecoll_visible(ob))) {
|
||||
add_v3_v3(normal, pchan->pose_mat[2]);
|
||||
add_v3_v3(plane, pchan->pose_mat[1]);
|
||||
ok = true;
|
||||
|
|
Loading…
Reference in New Issue