[Bf-blender-cvs] [232049dd940] master: Armature: use BKE_armature_transform when applying transformation

Campbell Barton noreply at git.blender.org
Fri Aug 23 04:04:27 CEST 2019


Commit: 232049dd9408e15d2082181e60ddd775b375ff19
Author: Campbell Barton
Date:   Fri Aug 23 11:53:45 2019 +1000
Branches: master
https://developer.blender.org/rB232049dd9408e15d2082181e60ddd775b375ff19

Armature: use BKE_armature_transform when applying transformation

Keep ED_armature_transform for RNA Armature.transform
since it operates on edit-bones in edit-mode.

Rename ED_armature_transform_bones to ED_armature_edit_transform
since it wasn't obviously an edit-mode function.

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

M	source/blender/editors/armature/armature_edit.c
M	source/blender/editors/include/ED_armature.h
M	source/blender/editors/object/object_transform.c
M	source/blender/makesrna/intern/rna_armature.c

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

diff --git a/source/blender/editors/armature/armature_edit.c b/source/blender/editors/armature/armature_edit.c
index 4e6661b1d15..c4c10549da3 100644
--- a/source/blender/editors/armature/armature_edit.c
+++ b/source/blender/editors/armature/armature_edit.c
@@ -62,22 +62,10 @@
 /* ************************** Object Tools Exports ******************************* */
 /* NOTE: these functions are exported to the Object module to be called from the tools there */
 
-void ED_armature_transform_apply(Main *bmain, Object *ob, float mat[4][4], const bool do_props)
-{
-  bArmature *arm = ob->data;
-
-  /* Put the armature into editmode */
-  ED_armature_to_edit(arm);
-
-  /* Transform the bones */
-  ED_armature_transform_bones(arm, mat, do_props);
-
-  /* Turn the list into an armature */
-  ED_armature_from_edit(bmain, arm);
-  ED_armature_edit_free(arm);
-}
-
-void ED_armature_transform_bones(struct bArmature *arm, float mat[4][4], const bool do_props)
+/**
+ * See #BKE_armature_transform for object-mode transform.
+ */
+void ED_armature_edit_transform(bArmature *arm, const float mat[4][4], const bool do_props)
 {
   EditBone *ebone;
   float scale = mat4_to_scale(mat); /* store the scale of the matrix here to use on envelopes */
@@ -114,21 +102,13 @@ void ED_armature_transform_bones(struct bArmature *arm, float mat[4][4], const b
   }
 }
 
-void ED_armature_transform(Main *bmain, bArmature *arm, float mat[4][4], const bool do_props)
+void ED_armature_transform(bArmature *arm, const float mat[4][4], const bool do_props)
 {
   if (arm->edbo) {
-    ED_armature_transform_bones(arm, mat, do_props);
+    ED_armature_edit_transform(arm, mat, do_props);
   }
   else {
-    /* Put the armature into editmode */
-    ED_armature_to_edit(arm);
-
-    /* Transform the bones */
-    ED_armature_transform_bones(arm, mat, do_props);
-
-    /* Go back to object mode*/
-    ED_armature_from_edit(bmain, arm);
-    ED_armature_edit_free(arm);
+    BKE_armature_transform(arm, mat, do_props);
   }
 }
 
diff --git a/source/blender/editors/include/ED_armature.h b/source/blender/editors/include/ED_armature.h
index 76be0e82aa4..8dbe832d18b 100644
--- a/source/blender/editors/include/ED_armature.h
+++ b/source/blender/editors/include/ED_armature.h
@@ -229,15 +229,9 @@ void ED_armature_edit_transform_mirror_update(struct Object *obedit);
 void ED_armature_origin_set(
     struct Main *bmain, struct Object *ob, const float cursor[3], int centermode, int around);
 
-void ED_armature_transform_bones(struct bArmature *arm, float mat[4][4], const bool do_props);
-void ED_armature_transform_apply(struct Main *bmain,
-                                 struct Object *ob,
-                                 float mat[4][4],
-                                 const bool do_props);
-void ED_armature_transform(struct Main *bmain,
-                           struct bArmature *arm,
-                           float mat[4][4],
-                           const bool do_props);
+void ED_armature_edit_transform(struct bArmature *arm, const float mat[4][4], const bool do_props);
+
+void ED_armature_transform(struct bArmature *arm, const float mat[4][4], const bool do_props);
 
 #define ARM_GROUPS_NAME 1
 #define ARM_GROUPS_ENVELOPE 2
diff --git a/source/blender/editors/object/object_transform.c b/source/blender/editors/object/object_transform.c
index 9b39c5b2a88..76a45f219fe 100644
--- a/source/blender/editors/object/object_transform.c
+++ b/source/blender/editors/object/object_transform.c
@@ -768,7 +768,8 @@ static int apply_objects_internal(bContext *C,
       BKE_mesh_calc_normals(me);
     }
     else if (ob->type == OB_ARMATURE) {
-      ED_armature_transform_apply(bmain, ob, mat, do_props);
+      bArmature *arm = ob->data;
+      BKE_armature_transform(arm, mat, do_props);
     }
     else if (ob->type == OB_LATTICE) {
       Lattice *lt = ob->data;
diff --git a/source/blender/makesrna/intern/rna_armature.c b/source/blender/makesrna/intern/rna_armature.c
index bc6d3b6e743..c0e3404f78c 100644
--- a/source/blender/makesrna/intern/rna_armature.c
+++ b/source/blender/makesrna/intern/rna_armature.c
@@ -604,9 +604,9 @@ static bool rna_Armature_is_editmode_get(PointerRNA *ptr)
   return (arm->edbo != NULL);
 }
 
-static void rna_Armature_transform(struct bArmature *arm, Main *bmain, float *mat)
+static void rna_Armature_transform(bArmature *arm, float *mat)
 {
-  ED_armature_transform(bmain, arm, (float(*)[4])mat, true);
+  ED_armature_transform(arm, (const float(*)[4])mat, true);
 }
 
 #else
@@ -1320,7 +1320,6 @@ static void rna_def_armature(BlenderRNA *brna)
   RNA_def_struct_sdna(srna, "bArmature");
 
   func = RNA_def_function(srna, "transform", "rna_Armature_transform");
-  RNA_def_function_flag(func, FUNC_USE_MAIN);
   RNA_def_function_ui_description(func, "Transform armature bones by a matrix");
   parm = RNA_def_float_matrix(func, "matrix", 4, 4, NULL, 0.0f, 0.0f, "", "Matrix", 0.0f, 0.0f);
   RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);



More information about the Bf-blender-cvs mailing list