Cleanup: function naming for manipulator
Rename 'stats_*' to 'protectflag_to_drawflags_*' (was too vague). Also remove NULL check from gimbal_axis
This commit is contained in:
parent
5e3b6e951b
commit
f74b4a010d
Notes:
blender-bot
2023-02-14 06:54:35 +01:00
Referenced by issue #51705, Filter and Texture Nodes in Compositor crash Blender
|
@ -143,13 +143,13 @@ static void protectflag_to_drawflags(short protectflag, short *drawflags)
|
|||
}
|
||||
|
||||
/* for pose mode */
|
||||
static void stats_pchan(RegionView3D *rv3d, bPoseChannel *pchan)
|
||||
static void protectflag_to_drawflags_pchan(RegionView3D *rv3d, const bPoseChannel *pchan)
|
||||
{
|
||||
protectflag_to_drawflags(pchan->protectflag, &rv3d->twdrawflag);
|
||||
}
|
||||
|
||||
/* for editmode*/
|
||||
static void stats_editbone(RegionView3D *rv3d, EditBone *ebo)
|
||||
static void protectflag_to_drawflags_ebone(RegionView3D *rv3d, const EditBone *ebo)
|
||||
{
|
||||
if (ebo->flag & BONE_EDITMODE_LOCKED) {
|
||||
protectflag_to_drawflags(OB_LOCK_LOC | OB_LOCK_ROT | OB_LOCK_SCALE, &rv3d->twdrawflag);
|
||||
|
@ -188,73 +188,71 @@ static void axis_angle_to_gimbal_axis(float gmat[3][3], const float axis[3], con
|
|||
}
|
||||
|
||||
|
||||
static int test_rotmode_euler(short rotmode)
|
||||
static bool test_rotmode_euler(short rotmode)
|
||||
{
|
||||
return (ELEM(rotmode, ROT_MODE_AXISANGLE, ROT_MODE_QUAT)) ? 0 : 1;
|
||||
}
|
||||
|
||||
bool gimbal_axis(Object *ob, float gmat[3][3])
|
||||
{
|
||||
if (ob) {
|
||||
if (ob->mode & OB_MODE_POSE) {
|
||||
bPoseChannel *pchan = BKE_pose_channel_active(ob);
|
||||
if (ob->mode & OB_MODE_POSE) {
|
||||
bPoseChannel *pchan = BKE_pose_channel_active(ob);
|
||||
|
||||
if (pchan) {
|
||||
float mat[3][3], tmat[3][3], obmat[3][3];
|
||||
if (test_rotmode_euler(pchan->rotmode)) {
|
||||
eulO_to_gimbal_axis(mat, pchan->eul, pchan->rotmode);
|
||||
}
|
||||
else if (pchan->rotmode == ROT_MODE_AXISANGLE) {
|
||||
axis_angle_to_gimbal_axis(mat, pchan->rotAxis, pchan->rotAngle);
|
||||
}
|
||||
else { /* quat */
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* apply bone transformation */
|
||||
mul_m3_m3m3(tmat, pchan->bone->bone_mat, mat);
|
||||
|
||||
if (pchan->parent) {
|
||||
float parent_mat[3][3];
|
||||
|
||||
copy_m3_m4(parent_mat, pchan->parent->pose_mat);
|
||||
mul_m3_m3m3(mat, parent_mat, tmat);
|
||||
|
||||
/* needed if object transformation isn't identity */
|
||||
copy_m3_m4(obmat, ob->obmat);
|
||||
mul_m3_m3m3(gmat, obmat, mat);
|
||||
}
|
||||
else {
|
||||
/* needed if object transformation isn't identity */
|
||||
copy_m3_m4(obmat, ob->obmat);
|
||||
mul_m3_m3m3(gmat, obmat, tmat);
|
||||
}
|
||||
|
||||
normalize_m3(gmat);
|
||||
return 1;
|
||||
if (pchan) {
|
||||
float mat[3][3], tmat[3][3], obmat[3][3];
|
||||
if (test_rotmode_euler(pchan->rotmode)) {
|
||||
eulO_to_gimbal_axis(mat, pchan->eul, pchan->rotmode);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (test_rotmode_euler(ob->rotmode)) {
|
||||
eulO_to_gimbal_axis(gmat, ob->rot, ob->rotmode);
|
||||
}
|
||||
else if (ob->rotmode == ROT_MODE_AXISANGLE) {
|
||||
axis_angle_to_gimbal_axis(gmat, ob->rotAxis, ob->rotAngle);
|
||||
else if (pchan->rotmode == ROT_MODE_AXISANGLE) {
|
||||
axis_angle_to_gimbal_axis(mat, pchan->rotAxis, pchan->rotAngle);
|
||||
}
|
||||
else { /* quat */
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (ob->parent) {
|
||||
|
||||
/* apply bone transformation */
|
||||
mul_m3_m3m3(tmat, pchan->bone->bone_mat, mat);
|
||||
|
||||
if (pchan->parent) {
|
||||
float parent_mat[3][3];
|
||||
copy_m3_m4(parent_mat, ob->parent->obmat);
|
||||
normalize_m3(parent_mat);
|
||||
mul_m3_m3m3(gmat, parent_mat, gmat);
|
||||
|
||||
copy_m3_m4(parent_mat, pchan->parent->pose_mat);
|
||||
mul_m3_m3m3(mat, parent_mat, tmat);
|
||||
|
||||
/* needed if object transformation isn't identity */
|
||||
copy_m3_m4(obmat, ob->obmat);
|
||||
mul_m3_m3m3(gmat, obmat, mat);
|
||||
}
|
||||
else {
|
||||
/* needed if object transformation isn't identity */
|
||||
copy_m3_m4(obmat, ob->obmat);
|
||||
mul_m3_m3m3(gmat, obmat, tmat);
|
||||
}
|
||||
|
||||
normalize_m3(gmat);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (test_rotmode_euler(ob->rotmode)) {
|
||||
eulO_to_gimbal_axis(gmat, ob->rot, ob->rotmode);
|
||||
}
|
||||
else if (ob->rotmode == ROT_MODE_AXISANGLE) {
|
||||
axis_angle_to_gimbal_axis(gmat, ob->rotAxis, ob->rotAngle);
|
||||
}
|
||||
else { /* quat */
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (ob->parent) {
|
||||
float parent_mat[3][3];
|
||||
copy_m3_m4(parent_mat, ob->parent->obmat);
|
||||
normalize_m3(parent_mat);
|
||||
mul_m3_m3m3(gmat, parent_mat, gmat);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -381,7 +379,7 @@ static int calc_manipulator_stats(const bContext *C)
|
|||
calc_tw_center(scene, ebo->head);
|
||||
totsel++;
|
||||
}
|
||||
stats_editbone(rv3d, ebo);
|
||||
protectflag_to_drawflags_ebone(rv3d, ebo);
|
||||
}
|
||||
else {
|
||||
for (ebo = arm->edbo->first; ebo; ebo = ebo->next) {
|
||||
|
@ -401,7 +399,7 @@ static int calc_manipulator_stats(const bContext *C)
|
|||
totsel++;
|
||||
}
|
||||
if (ebo->flag & BONE_SELECTED) {
|
||||
stats_editbone(rv3d, ebo);
|
||||
protectflag_to_drawflags_ebone(rv3d, ebo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -527,7 +525,7 @@ static int calc_manipulator_stats(const bContext *C)
|
|||
Bone *bone = pchan->bone;
|
||||
if (bone) {
|
||||
calc_tw_center(scene, pchan->pose_head);
|
||||
stats_pchan(rv3d, pchan);
|
||||
protectflag_to_drawflags_pchan(rv3d, pchan);
|
||||
totsel = 1;
|
||||
ok = true;
|
||||
}
|
||||
|
@ -541,7 +539,7 @@ static int calc_manipulator_stats(const bContext *C)
|
|||
Bone *bone = pchan->bone;
|
||||
if (bone && (bone->flag & BONE_TRANSFORM)) {
|
||||
calc_tw_center(scene, pchan->pose_head);
|
||||
stats_pchan(rv3d, pchan);
|
||||
protectflag_to_drawflags_pchan(rv3d, pchan);
|
||||
}
|
||||
}
|
||||
ok = true;
|
||||
|
|
|
@ -451,7 +451,7 @@ void initTransformOrientation(bContext *C, TransInfo *t)
|
|||
|
||||
case V3D_MANIP_GIMBAL:
|
||||
unit_m3(t->spacemtx);
|
||||
if (gimbal_axis(ob, t->spacemtx)) {
|
||||
if (ob && gimbal_axis(ob, t->spacemtx)) {
|
||||
BLI_strncpy(t->spacename, IFACE_("gimbal"), sizeof(t->spacename));
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue