Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source/blender/blenkernel/BKE_armature.h1
-rw-r--r--source/blender/blenkernel/intern/armature.c16
-rw-r--r--source/blender/makesdna/DNA_armature_types.h2
-rw-r--r--source/blender/makesrna/intern/rna_armature.c6
4 files changed, 25 insertions, 0 deletions
diff --git a/source/blender/blenkernel/BKE_armature.h b/source/blender/blenkernel/BKE_armature.h
index b255500272a..4012ff60b98 100644
--- a/source/blender/blenkernel/BKE_armature.h
+++ b/source/blender/blenkernel/BKE_armature.h
@@ -165,6 +165,7 @@ void BKE_bone_offset_matrix_get(const struct Bone *bone, float offs_bone[4][4]);
typedef struct BoneParentTransform {
float rotscale_mat[4][4]; /* parent effect on rotation & scale pose channels */
float loc_mat[4][4]; /* parent effect on location pose channel */
+ float post_scale[3]; /* additional scale to apply with post-multiply */
} BoneParentTransform;
/* Matrix-like algebra operations on the transform */
diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c
index 3215b3d7b40..4d9a92d3ead 100644
--- a/source/blender/blenkernel/intern/armature.c
+++ b/source/blender/blenkernel/intern/armature.c
@@ -1893,6 +1893,8 @@ void BKE_bone_parent_transform_calc_from_matrices(int bone_flag,
const float parent_pose_mat[4][4],
BoneParentTransform *r_bpt)
{
+ copy_v3_fl(r_bpt->post_scale, 1.0f);
+
if (parent_pose_mat) {
const bool use_rotation = (bone_flag & BONE_HINGE) == 0;
const bool full_transform = use_rotation && inherit_scale_mode == BONE_INHERIT_SCALE_FULL;
@@ -1922,6 +1924,12 @@ void BKE_bone_parent_transform_calc_from_matrices(int bone_flag,
orthogonalize_m4_stable(tmat, 1, true);
break;
+ case BONE_INHERIT_SCALE_ALIGNED:
+ /* Remove shear and extract scale. */
+ orthogonalize_m4_stable(tmat, 1, false);
+ normalize_m4_ex(tmat, r_bpt->post_scale);
+ break;
+
case BONE_INHERIT_SCALE_NONE_LEGACY:
/* Remove only scale - bad legacy way. */
normalize_m4(tmat);
@@ -1949,6 +1957,10 @@ void BKE_bone_parent_transform_calc_from_matrices(int bone_flag,
rescale_m4(tmat, tscale);
break;
+ case BONE_INHERIT_SCALE_ALIGNED:
+ mat4_to_size_fix_shear(r_bpt->post_scale, parent_pose_mat);
+ break;
+
case BONE_INHERIT_SCALE_NONE:
case BONE_INHERIT_SCALE_AVERAGE:
case BONE_INHERIT_SCALE_NONE_LEGACY:
@@ -2023,12 +2035,14 @@ void BKE_bone_parent_transform_clear(struct BoneParentTransform *bpt)
{
unit_m4(bpt->rotscale_mat);
unit_m4(bpt->loc_mat);
+ copy_v3_fl(bpt->post_scale, 1.0f);
}
void BKE_bone_parent_transform_invert(struct BoneParentTransform *bpt)
{
invert_m4(bpt->rotscale_mat);
invert_m4(bpt->loc_mat);
+ invert_v3(bpt->post_scale);
}
void BKE_bone_parent_transform_combine(const struct BoneParentTransform *in1,
@@ -2037,6 +2051,7 @@ void BKE_bone_parent_transform_combine(const struct BoneParentTransform *in1,
{
mul_m4_m4m4(result->rotscale_mat, in1->rotscale_mat, in2->rotscale_mat);
mul_m4_m4m4(result->loc_mat, in1->loc_mat, in2->loc_mat);
+ mul_v3_v3v3(result->post_scale, in1->post_scale, in2->post_scale);
}
void BKE_bone_parent_transform_apply(const struct BoneParentTransform *bpt,
@@ -2049,6 +2064,7 @@ void BKE_bone_parent_transform_apply(const struct BoneParentTransform *bpt,
mul_m4_m4m4(outmat, bpt->rotscale_mat, inmat);
mul_v3_m4v3(outmat[3], bpt->loc_mat, tmploc);
+ rescale_m4(outmat, bpt->post_scale);
}
/* Convert Pose-Space Matrix to Bone-Space Matrix.
diff --git a/source/blender/makesdna/DNA_armature_types.h b/source/blender/makesdna/DNA_armature_types.h
index 3bad2a04a65..4ead3165715 100644
--- a/source/blender/makesdna/DNA_armature_types.h
+++ b/source/blender/makesdna/DNA_armature_types.h
@@ -267,6 +267,8 @@ typedef enum eBone_InheritScaleMode {
BONE_INHERIT_SCALE_NONE,
/* Inherit effects of shear on parent (same as old disabled Inherit Scale). */
BONE_INHERIT_SCALE_NONE_LEGACY,
+ /* Inherit parent X scale as child X scale etc. */
+ BONE_INHERIT_SCALE_ALIGNED,
} eBone_InheritScaleMode;
/* bone->bbone_prev_type, bbone_next_type */
diff --git a/source/blender/makesrna/intern/rna_armature.c b/source/blender/makesrna/intern/rna_armature.c
index 4dc383a2460..b09a19bb39f 100644
--- a/source/blender/makesrna/intern/rna_armature.c
+++ b/source/blender/makesrna/intern/rna_armature.c
@@ -832,6 +832,12 @@ static void rna_def_bone_common(StructRNA *srna, int editbone)
0,
"Fix Shear",
"Inherit scaling, but remove shearing of the child in the rest orientation"},
+ {BONE_INHERIT_SCALE_ALIGNED,
+ "ALIGNED",
+ 0,
+ "Aligned",
+ "Rotate non-uniform parent scaling to align with the child, applying parent X "
+ "scale to child X axis, and so forth"},
{BONE_INHERIT_SCALE_AVERAGE,
"AVERAGE",
0,