Commit: f74b4a010d4b0cc51eb9ecddeab0f7d91b31ec94
Author: Campbell Barton
Date:   Thu Apr 6 12:23:39 2017 +1000
Branches: master
https://developer.blender.org/rBf74b4a010d4b0cc51eb9ecddeab0f7d91b31ec94

Cleanup: function naming for manipulator

Rename 'stats_*' to 'protectflag_to_drawflags_*' (was too vague).
Also remove NULL check from gimbal_axis

===================================================================

M       source/blender/editors/transform/transform_manipulator.c
M       source/blender/editors/transform/transform_orientations.c

===================================================================

diff --git a/source/blender/editors/transform/transform_manipulator.c 
b/source/blender/editors/transform/transform_manipulator.c
index b41b247683f..f23c913da1e 100644
--- a/source/blender/editors/transform/transform_manipulator.c
+++ b/source/blender/editors/transform/transform_manipulator.c
@@ -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 (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;
-                               }
-
+       if (ob->mode & OB_MODE_POSE) {
+               bPoseChannel *pchan = BKE_pose_channel_active(ob);
 
-                               /* 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;
diff --git a/source/blender/editors/transform/transform_orientations.c 
b/source/blender/editors/transform/transform_orientations.c
index 058af768885..674d2c376bb 100644
--- a/source/blender/editors/transform/transform_orientations.c
+++ b/source/blender/editors/transform/transform_orientations.c
@@ -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;
                        }

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to