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.
This commit is contained in:
Campbell Barton 2019-08-23 11:53:45 +10:00
parent 30582c59cc
commit 232049dd94
Notes: blender-bot 2023-02-14 05:36:11 +01:00
Referenced by issue #71990, When applying Transforms to Armatures, Bone Orientations are affected differently to previous versions.
Referenced by issue #69089, glTF addon: libextern_draco.so is missing
4 changed files with 14 additions and 40 deletions

View File

@ -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);
}
}

View File

@ -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

View File

@ -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;

View File

@ -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);