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

git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Gavrilov <angavrilov@gmail.com>2022-01-02 19:48:39 +0300
committerAlexander Gavrilov <angavrilov@gmail.com>2022-01-03 23:49:25 +0300
commit2f1c38fd507ecfd9c23cc7205da6b426507fa07f (patch)
treeba497ed0b6bb68ff78eeb5e09a9145d4bd898c29 /rigify/utils/animation.py
parent7f4c2d5e48657af8bf450da7d6a0587065cfa8b4 (diff)
Rigify: support uniform scaling of limbs via the master control.
Existing IK & FK controls only allowed squash and stretch scaling.
Diffstat (limited to 'rigify/utils/animation.py')
-rw-r--r--rigify/utils/animation.py27
1 files changed, 21 insertions, 6 deletions
diff --git a/rigify/utils/animation.py b/rigify/utils/animation.py
index 1355a0b6..8710e74d 100644
--- a/rigify/utils/animation.py
+++ b/rigify/utils/animation.py
@@ -182,18 +182,33 @@ def undo_copy_scale_with_offset(obj, bone, con, old_matrix):
"Undo the effects of Copy Scale with Offset constraint on a bone matrix."
inf = con.influence
- if con.mute or inf == 0 or not con.is_valid or not con.use_offset or con.use_add or con.use_make_uniform:
+ if con.mute or inf == 0 or not con.is_valid or not con.use_offset or con.use_add:
return old_matrix
+ tgt_matrix = get_constraint_target_matrix(con)
+ tgt_scale = tgt_matrix.to_scale()
+ use = [con.use_x, con.use_y, con.use_z]
+
+ if con.use_make_uniform:
+ if con.use_x and con.use_y and con.use_z:
+ total = tgt_matrix.determinant()
+ else:
+ total = 1
+ for i, use in enumerate(use):
+ if use:
+ total *= tgt_scale[i]
+
+ tgt_scale = [abs(total)**(1./3.)]*3
+ else:
+ for i, use in enumerate(use):
+ if not use:
+ tgt_scale[i] = 1
+
scale_delta = [
1 / (1 + (math.pow(x, con.power) - 1) * inf)
- for x in get_constraint_target_matrix(con).to_scale()
+ for x in tgt_scale
]
- for i, use in enumerate([con.use_x, con.use_y, con.use_z]):
- if not use:
- scale_delta[i] = 1
-
return old_matrix @ Matrix.Diagonal([*scale_delta, 1])
def undo_copy_scale_constraints(obj, bone, matrix):