Cleanup: restructure 'transform_convert_pose_transflags_update'
Move the bones count and `has_translate_rotate` parameter out of the function as they are not required in some places.
This commit is contained in:
parent
7aec5b0622
commit
ff5e8e6d53
Notes:
blender-bot
2023-02-14 06:55:40 +01:00
Referenced by commitcabc9506f9
, Fix crash in recent pose-bone transform cleanup Referenced by commit6b914a43ad
, Fix error inff5e8e6d53
Referenced by commitb127654816
, Fix build error
|
@ -124,10 +124,8 @@ void special_aftertrans_update__actedit(bContext *C, TransInfo *t);
|
|||
* Sets transform flags in the bones.
|
||||
* Returns total number of bones with #BONE_TRANSFORM.
|
||||
*/
|
||||
int transform_convert_pose_transflags_update(Object *ob,
|
||||
int mode,
|
||||
short around,
|
||||
bool has_translate_rotate[2]);
|
||||
void transform_convert_pose_transflags_update(Object *ob, int mode, short around);
|
||||
|
||||
/**
|
||||
* When objects array is NULL, use 't->data_container' as is.
|
||||
*/
|
||||
|
|
|
@ -739,9 +739,41 @@ void createTransPose(TransInfo *t)
|
|||
|
||||
const bool mirror = ((pose->flag & POSE_MIRROR_EDIT) != 0);
|
||||
|
||||
/* set flags and count total */
|
||||
tc->data_len = transform_convert_pose_transflags_update(
|
||||
ob, t->mode, t->around, has_translate_rotate);
|
||||
/* Set flags. */
|
||||
transform_convert_pose_transflags_update(ob, t->mode, t->around);
|
||||
|
||||
/* Now count, and check if we have autoIK or have to switch from translate to rotate. */
|
||||
LISTBASE_FOREACH (bPoseChannel *, pchan, &ob->pose->chanbase) {
|
||||
Bone *bone = pchan->bone;
|
||||
if (!(bone->flag & BONE_TRANSFORM)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
tc->data_len++;
|
||||
|
||||
if (has_translate_rotate[0] && has_translate_rotate[1]) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!has_targetless_ik(pchan) == NULL) {
|
||||
if (pchan->parent && (bone->flag & BONE_CONNECTED)) {
|
||||
if (bone->flag & BONE_HINGE_CHILD_TRANSFORM) {
|
||||
has_translate_rotate[0] = true;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if ((pchan->protectflag & OB_LOCK_LOC) != OB_LOCK_LOC) {
|
||||
has_translate_rotate[0] = true;
|
||||
}
|
||||
}
|
||||
if ((pchan->protectflag & OB_LOCK_ROT) != OB_LOCK_ROT) {
|
||||
has_translate_rotate[1] = true;
|
||||
}
|
||||
}
|
||||
else {
|
||||
has_translate_rotate[0] = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (tc->data_len == 0) {
|
||||
continue;
|
||||
|
@ -1499,10 +1531,7 @@ static void bone_children_clear_transflag(int mode, short around, ListBase *lb)
|
|||
}
|
||||
}
|
||||
|
||||
int transform_convert_pose_transflags_update(Object *ob,
|
||||
const int mode,
|
||||
const short around,
|
||||
bool has_translate_rotate[2])
|
||||
void transform_convert_pose_transflags_update(Object *ob, const int mode, const short around)
|
||||
{
|
||||
bArmature *arm = ob->data;
|
||||
bPoseChannel *pchan;
|
||||
|
@ -1537,34 +1566,6 @@ int transform_convert_pose_transflags_update(Object *ob,
|
|||
}
|
||||
}
|
||||
}
|
||||
/* now count, and check if we have autoIK or have to switch from translate to rotate */
|
||||
for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
|
||||
bone = pchan->bone;
|
||||
if (bone->flag & BONE_TRANSFORM) {
|
||||
total++;
|
||||
|
||||
if (has_translate_rotate != NULL) {
|
||||
if (has_targetless_ik(pchan) == NULL) {
|
||||
if (pchan->parent && (pchan->bone->flag & BONE_CONNECTED)) {
|
||||
if (pchan->bone->flag & BONE_HINGE_CHILD_TRANSFORM) {
|
||||
has_translate_rotate[0] = true;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if ((pchan->protectflag & OB_LOCK_LOC) != OB_LOCK_LOC) {
|
||||
has_translate_rotate[0] = true;
|
||||
}
|
||||
}
|
||||
if ((pchan->protectflag & OB_LOCK_ROT) != OB_LOCK_ROT) {
|
||||
has_translate_rotate[1] = true;
|
||||
}
|
||||
}
|
||||
else {
|
||||
has_translate_rotate[0] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return total;
|
||||
}
|
||||
|
@ -1733,7 +1734,7 @@ void special_aftertrans_update__pose(bContext *C, TransInfo *t)
|
|||
|
||||
/* Set BONE_TRANSFORM flags for auto-key, gizmo draw might have changed them. */
|
||||
if (!canceled && (t->mode != TFM_DUMMY)) {
|
||||
transform_convert_pose_transflags_update(ob, t->mode, t->around, NULL);
|
||||
transform_convert_pose_transflags_update(ob, t->mode, t->around);
|
||||
}
|
||||
|
||||
/* if target-less IK grabbing, we calculate the pchan transforms and clear flag */
|
||||
|
|
|
@ -953,32 +953,27 @@ int ED_transform_calc_gizmo_stats(const bContext *C,
|
|||
|
||||
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
|
||||
Object *ob_iter = objects[ob_index];
|
||||
const bool use_mat_local = (ob_iter != ob);
|
||||
const bool use_mat_local = params->use_local_axis && (ob_iter != ob);
|
||||
bPoseChannel *pchan;
|
||||
|
||||
/* mislead counting bones... bah. We don't know the gizmo mode, could be mixed */
|
||||
const int mode = TFM_ROTATION;
|
||||
|
||||
const int totsel_iter = transform_convert_pose_transflags_update(
|
||||
ob_iter, mode, V3D_AROUND_CENTER_BOUNDS, NULL);
|
||||
transform_convert_pose_transflags_update(ob_iter, mode, V3D_AROUND_CENTER_BOUNDS);
|
||||
|
||||
if (totsel_iter) {
|
||||
float mat_local[4][4];
|
||||
if (params->use_local_axis) {
|
||||
if (use_mat_local) {
|
||||
mul_m4_m4m4(mat_local, ob->imat, ob_iter->obmat);
|
||||
}
|
||||
}
|
||||
float mat_local[4][4];
|
||||
if (use_mat_local) {
|
||||
mul_m4_m4m4(mat_local, ob->imat, ob_iter->obmat);
|
||||
}
|
||||
|
||||
/* use channels to get stats */
|
||||
for (pchan = ob_iter->pose->chanbase.first; pchan; pchan = pchan->next) {
|
||||
Bone *bone = pchan->bone;
|
||||
if (bone && (bone->flag & BONE_TRANSFORM)) {
|
||||
calc_tw_center_with_matrix(tbounds, pchan->pose_head, use_mat_local, mat_local);
|
||||
protectflag_to_drawflags_pchan(rv3d, pchan, orient_index);
|
||||
}
|
||||
/* Use channels to get stats. */
|
||||
LISTBASE_FOREACH (bPoseChannel *, pchan, &ob->pose->chanbase) {
|
||||
if (!(pchan->bone->flag & BONE_TRANSFORM)) {
|
||||
continue;
|
||||
}
|
||||
totsel += totsel_iter;
|
||||
calc_tw_center_with_matrix(tbounds, pchan->pose_head, use_mat_local, mat_local);
|
||||
protectflag_to_drawflags_pchan(rv3d, pchan, orient_index);
|
||||
totsel++;
|
||||
}
|
||||
}
|
||||
MEM_freeN(objects);
|
||||
|
|
Loading…
Reference in New Issue