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:
@@ -124,10 +124,8 @@ void special_aftertrans_update__actedit(bContext *C, TransInfo *t);
|
|||||||
* Sets transform flags in the bones.
|
* Sets transform flags in the bones.
|
||||||
* Returns total number of bones with #BONE_TRANSFORM.
|
* Returns total number of bones with #BONE_TRANSFORM.
|
||||||
*/
|
*/
|
||||||
int transform_convert_pose_transflags_update(Object *ob,
|
void transform_convert_pose_transflags_update(Object *ob, int mode, short around);
|
||||||
int mode,
|
|
||||||
short around,
|
|
||||||
bool has_translate_rotate[2]);
|
|
||||||
/**
|
/**
|
||||||
* When objects array is NULL, use 't->data_container' as is.
|
* 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);
|
const bool mirror = ((pose->flag & POSE_MIRROR_EDIT) != 0);
|
||||||
|
|
||||||
/* set flags and count total */
|
/* Set flags. */
|
||||||
tc->data_len = transform_convert_pose_transflags_update(
|
transform_convert_pose_transflags_update(ob, t->mode, t->around);
|
||||||
ob, t->mode, t->around, has_translate_rotate);
|
|
||||||
|
/* 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) {
|
if (tc->data_len == 0) {
|
||||||
continue;
|
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,
|
void transform_convert_pose_transflags_update(Object *ob, const int mode, const short around)
|
||||||
const int mode,
|
|
||||||
const short around,
|
|
||||||
bool has_translate_rotate[2])
|
|
||||||
{
|
{
|
||||||
bArmature *arm = ob->data;
|
bArmature *arm = ob->data;
|
||||||
bPoseChannel *pchan;
|
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;
|
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. */
|
/* Set BONE_TRANSFORM flags for auto-key, gizmo draw might have changed them. */
|
||||||
if (!canceled && (t->mode != TFM_DUMMY)) {
|
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 */
|
/* 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++) {
|
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
|
||||||
Object *ob_iter = objects[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;
|
bPoseChannel *pchan;
|
||||||
|
|
||||||
/* mislead counting bones... bah. We don't know the gizmo mode, could be mixed */
|
/* mislead counting bones... bah. We don't know the gizmo mode, could be mixed */
|
||||||
const int mode = TFM_ROTATION;
|
const int mode = TFM_ROTATION;
|
||||||
|
|
||||||
const int totsel_iter = transform_convert_pose_transflags_update(
|
transform_convert_pose_transflags_update(ob_iter, mode, V3D_AROUND_CENTER_BOUNDS);
|
||||||
ob_iter, mode, V3D_AROUND_CENTER_BOUNDS, NULL);
|
|
||||||
|
|
||||||
if (totsel_iter) {
|
|
||||||
float mat_local[4][4];
|
float mat_local[4][4];
|
||||||
if (params->use_local_axis) {
|
|
||||||
if (use_mat_local) {
|
if (use_mat_local) {
|
||||||
mul_m4_m4m4(mat_local, ob->imat, ob_iter->obmat);
|
mul_m4_m4m4(mat_local, ob->imat, ob_iter->obmat);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/* use channels to get stats */
|
/* Use channels to get stats. */
|
||||||
for (pchan = ob_iter->pose->chanbase.first; pchan; pchan = pchan->next) {
|
LISTBASE_FOREACH (bPoseChannel *, pchan, &ob->pose->chanbase) {
|
||||||
Bone *bone = pchan->bone;
|
if (!(pchan->bone->flag & BONE_TRANSFORM)) {
|
||||||
if (bone && (bone->flag & BONE_TRANSFORM)) {
|
continue;
|
||||||
|
}
|
||||||
calc_tw_center_with_matrix(tbounds, pchan->pose_head, use_mat_local, mat_local);
|
calc_tw_center_with_matrix(tbounds, pchan->pose_head, use_mat_local, mat_local);
|
||||||
protectflag_to_drawflags_pchan(rv3d, pchan, orient_index);
|
protectflag_to_drawflags_pchan(rv3d, pchan, orient_index);
|
||||||
}
|
totsel++;
|
||||||
}
|
|
||||||
totsel += totsel_iter;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
MEM_freeN(objects);
|
MEM_freeN(objects);
|
||||||
|
|||||||
Reference in New Issue
Block a user