Cleanup: Use more descriptive names for functions
count_set_pose_transflags --> transform_convert_pose_transflags_update count_bone_select --> armature_bone_transflags_update_recursive Also don't mix `BONE_TRANSFORM_MIRROR` with `BONE_TRANSFORM` in transflag. (This was a mess introduced in rBde530a95dc7b).
This commit is contained in:
parent
b443e1b7d4
commit
d66aa52528
|
@ -447,12 +447,12 @@ static void bone_children_clear_transflag(int mode, short around, ListBase *lb)
|
|||
}
|
||||
}
|
||||
|
||||
/* sets transform flags in the bones
|
||||
* returns total number of bones with BONE_TRANSFORM */
|
||||
int count_set_pose_transflags(Object *ob,
|
||||
const int mode,
|
||||
const short around,
|
||||
bool has_translate_rotate[2])
|
||||
/* Sets transform flags in the bones.
|
||||
* Returns total number of bones with `BONE_TRANSFORM`. */
|
||||
int transform_convert_pose_transflags_update(Object *ob,
|
||||
const int mode,
|
||||
const short around,
|
||||
bool has_translate_rotate[2])
|
||||
{
|
||||
bArmature *arm = ob->data;
|
||||
bPoseChannel *pchan;
|
||||
|
@ -2286,7 +2286,7 @@ void special_aftertrans_update(bContext *C, TransInfo *t)
|
|||
|
||||
/* set BONE_TRANSFORM flags for autokey, gizmo draw might have changed them */
|
||||
if (!canceled && (t->mode != TFM_DUMMY)) {
|
||||
count_set_pose_transflags(ob, t->mode, t->around, NULL);
|
||||
transform_convert_pose_transflags_update(ob, t->mode, t->around, NULL);
|
||||
}
|
||||
|
||||
/* if target-less IK grabbing, we calculate the pchan transforms and clear flag */
|
||||
|
|
|
@ -37,10 +37,10 @@ struct bKinematicConstraint;
|
|||
struct bPoseChannel;
|
||||
|
||||
/* transform_convert.c */
|
||||
int count_set_pose_transflags(Object *ob,
|
||||
const int mode,
|
||||
const short around,
|
||||
bool has_translate_rotate[2]);
|
||||
int transform_convert_pose_transflags_update(Object *ob,
|
||||
const int mode,
|
||||
const short around,
|
||||
bool has_translate_rotate[2]);
|
||||
void transform_autoik_update(TransInfo *t, short mode);
|
||||
void autokeyframe_object(struct bContext *C,
|
||||
struct Scene *scene,
|
||||
|
|
|
@ -669,7 +669,9 @@ void createTransPose(TransInfo *t)
|
|||
const bool mirror = ((pose->flag & POSE_MIRROR_EDIT) != 0);
|
||||
|
||||
/* set flags and count total */
|
||||
tc->data_len = count_set_pose_transflags(ob, t->mode, t->around, has_translate_rotate);
|
||||
tc->data_len = transform_convert_pose_transflags_update(
|
||||
ob, t->mode, t->around, has_translate_rotate);
|
||||
|
||||
if (tc->data_len == 0) {
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -1033,7 +1033,7 @@ int ED_transform_calc_gizmo_stats(const bContext *C,
|
|||
/* mislead counting bones... bah. We don't know the gizmo mode, could be mixed */
|
||||
const int mode = TFM_ROTATION;
|
||||
|
||||
const int totsel_iter = count_set_pose_transflags(
|
||||
const int totsel_iter = transform_convert_pose_transflags_update(
|
||||
ob_iter, mode, V3D_AROUND_CENTER_BOUNDS, NULL);
|
||||
|
||||
if (totsel_iter) {
|
||||
|
|
|
@ -407,14 +407,19 @@ bool applyTransformOrientation(const TransformOrientation *ts, float r_mat[3][3]
|
|||
return true;
|
||||
}
|
||||
|
||||
static int count_bone_select(bArmature *arm, ListBase *lb, const bool do_it)
|
||||
/* Updates all `BONE_TRANSFORM` flags.
|
||||
* Returns total number of bones with `BONE_TRANSFORM`.
|
||||
* Note: `transform_convert_pose_transflags_update` has a similar logic. */
|
||||
static int armature_bone_transflags_update_recursive(bArmature *arm,
|
||||
ListBase *lb,
|
||||
const bool do_it)
|
||||
{
|
||||
Bone *bone;
|
||||
bool do_next;
|
||||
int total = 0;
|
||||
|
||||
for (bone = lb->first; bone; bone = bone->next) {
|
||||
bone->flag &= ~(BONE_TRANSFORM | BONE_TRANSFORM_MIRROR);
|
||||
bone->flag &= ~BONE_TRANSFORM;
|
||||
do_next = do_it;
|
||||
if (do_it) {
|
||||
if (bone->layer & arm->layer) {
|
||||
|
@ -427,7 +432,7 @@ static int count_bone_select(bArmature *arm, ListBase *lb, const bool do_it)
|
|||
}
|
||||
}
|
||||
}
|
||||
total += count_bone_select(arm, &bone->childbase, do_next);
|
||||
total += armature_bone_transflags_update_recursive(arm, &bone->childbase, do_next);
|
||||
}
|
||||
|
||||
return total;
|
||||
|
@ -1072,10 +1077,9 @@ int getTransformOrientation_ex(const bContext *C,
|
|||
ok = true;
|
||||
}
|
||||
else {
|
||||
int totsel;
|
||||
|
||||
totsel = count_bone_select(arm, &arm->bonebase, true);
|
||||
if (totsel) {
|
||||
int transformed_len;
|
||||
transformed_len = armature_bone_transflags_update_recursive(arm, &arm->bonebase, true);
|
||||
if (transformed_len) {
|
||||
/* use channels to get stats */
|
||||
for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
|
||||
if (pchan->bone && pchan->bone->flag & BONE_TRANSFORM) {
|
||||
|
|
Loading…
Reference in New Issue