[Bf-blender-cvs] [d66aa525283] master: Cleanup: Use more descriptive names for functions

Germano Cavalcante noreply at git.blender.org
Tue Apr 28 22:32:41 CEST 2020


Commit: d66aa525283551727f4701fc1080c670e7f05d13
Author: Germano Cavalcante
Date:   Tue Apr 28 17:31:55 2020 -0300
Branches: master
https://developer.blender.org/rBd66aa525283551727f4701fc1080c670e7f05d13

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).

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

M	source/blender/editors/transform/transform_convert.c
M	source/blender/editors/transform/transform_convert.h
M	source/blender/editors/transform/transform_convert_armature.c
M	source/blender/editors/transform/transform_gizmo_3d.c
M	source/blender/editors/transform/transform_orientations.c

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

diff --git a/source/blender/editors/transform/transform_convert.c b/source/blender/editors/transform/transform_convert.c
index eeae4f83470..62fdaa4908e 100644
--- a/source/blender/editors/transform/transform_convert.c
+++ b/source/blender/editors/transform/transform_convert.c
@@ -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 */
diff --git a/source/blender/editors/transform/transform_convert.h b/source/blender/editors/transform/transform_convert.h
index f975d320e62..fccaeb994e9 100644
--- a/source/blender/editors/transform/transform_convert.h
+++ b/source/blender/editors/transform/transform_convert.h
@@ -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,
diff --git a/source/blender/editors/transform/transform_convert_armature.c b/source/blender/editors/transform/transform_convert_armature.c
index 17d210f57b9..107148532b3 100644
--- a/source/blender/editors/transform/transform_convert_armature.c
+++ b/source/blender/editors/transform/transform_convert_armature.c
@@ -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;
     }
diff --git a/source/blender/editors/transform/transform_gizmo_3d.c b/source/blender/editors/transform/transform_gizmo_3d.c
index aa298b04d1a..c93495460ad 100644
--- a/source/blender/editors/transform/transform_gizmo_3d.c
+++ b/source/blender/editors/transform/transform_gizmo_3d.c
@@ -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) {
diff --git a/source/blender/editors/transform/transform_orientations.c b/source/blender/editors/transform/transform_orientations.c
index 76823adfd20..82b3393fc1f 100644
--- a/source/blender/editors/transform/transform_orientations.c
+++ b/source/blender/editors/transform/transform_orientations.c
@@ -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) {



More information about the Bf-blender-cvs mailing list