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:
authorSybren A. Stüvel <sybren@blender.org>2021-04-20 16:52:40 +0300
committerSybren A. Stüvel <sybren@blender.org>2021-04-20 16:52:43 +0300
commiteca5cf146058a098625e289f0d49118755e10939 (patch)
treee21524a7a9615a70784055ea602a8a84c8ba53c9 /release/scripts/startup/keyingsets_builtins.py
parent26d778cd8ac2075a357d9cb7df9f9f161e7550a2 (diff)
Cleanup: keying sets, move common code to mix-in class
Move code common to the Whole Character keying sets ("Whole Character" and "Whole Character (Selected Bones Only)" into a mix-in class. This avoids the need to use direct assignments like `poll = BUILTIN_KSI_WholeCharacter.poll`. No functional changes.
Diffstat (limited to 'release/scripts/startup/keyingsets_builtins.py')
-rw-r--r--release/scripts/startup/keyingsets_builtins.py31
1 files changed, 9 insertions, 22 deletions
diff --git a/release/scripts/startup/keyingsets_builtins.py b/release/scripts/startup/keyingsets_builtins.py
index b656a88e87e..9343c75cd4b 100644
--- a/release/scripts/startup/keyingsets_builtins.py
+++ b/release/scripts/startup/keyingsets_builtins.py
@@ -366,14 +366,7 @@ class BUILTIN_KSI_Available(KeyingSetInfo):
###############################
-
-# All properties that are likely to get animated in a character rig
-class BUILTIN_KSI_WholeCharacter(KeyingSetInfo):
- """Insert a keyframe for all properties that are likely to get animated in a character rig """ \
- """(useful when blocking out a shot)"""
- bl_idname = ANIM_KS_WHOLE_CHARACTER_ID
- bl_label = "Whole Character"
-
+class WholeCharacterMixin:
# these prefixes should be avoided, as they are not really bones
# that animators should be touching (or need to touch)
badBonePrefixes = (
@@ -394,7 +387,7 @@ class BUILTIN_KSI_WholeCharacter(KeyingSetInfo):
# iterator - all bones regardless of selection
def iterator(self, context, ks):
for bone in context.active_object.pose.bones:
- if not bone.name.startswith(BUILTIN_KSI_WholeCharacter.badBonePrefixes):
+ if not bone.name.startswith(self.badBonePrefixes):
self.generate(context, ks, bone)
# generator - all unlocked bone transforms + custom properties
@@ -532,10 +525,14 @@ class BUILTIN_KSI_WholeCharacter(KeyingSetInfo):
self.addProp(ks, bone, prop)
-# All properties that are likely to get animated in a character rig, only selected bones.
+class BUILTIN_KSI_WholeCharacter(WholeCharacterMixin, KeyingSetInfo):
+ """Insert a keyframe for all properties that are likely to get animated in a character rig """ \
+ """(useful when blocking out a shot)"""
+ bl_idname = ANIM_KS_WHOLE_CHARACTER_ID
+ bl_label = "Whole Character"
-class BUILTIN_KSI_WholeCharacterSelected(KeyingSetInfo):
+class BUILTIN_KSI_WholeCharacterSelected(WholeCharacterMixin, KeyingSetInfo):
"""Insert a keyframe for all properties that are likely to get animated in a character rig """ \
"""(only selected bones)"""
bl_idname = ANIM_KS_WHOLE_CHARACTER_SELECTED_ID
@@ -547,20 +544,10 @@ class BUILTIN_KSI_WholeCharacterSelected(KeyingSetInfo):
bones = context.selected_pose_bones_from_active_object or context.active_object.pose.bones
for bone in bones:
- if bone.name.startswith(BUILTIN_KSI_WholeCharacter.badBonePrefixes):
+ if bone.name.startswith(self.badBonePrefixes):
continue
self.generate(context, ks, bone)
- # Poor man's subclassing. Blender breaks when we actually subclass BUILTIN_KSI_WholeCharacter.
- poll = BUILTIN_KSI_WholeCharacter.poll
- generate = BUILTIN_KSI_WholeCharacter.generate
- addProp = BUILTIN_KSI_WholeCharacter.addProp
- doLoc = BUILTIN_KSI_WholeCharacter.doLoc
- doRot4d = BUILTIN_KSI_WholeCharacter.doRot4d
- doRot3d = BUILTIN_KSI_WholeCharacter.doRot3d
- doScale = BUILTIN_KSI_WholeCharacter.doScale
- doBBone = BUILTIN_KSI_WholeCharacter.doBBone
- doCustomProps = BUILTIN_KSI_WholeCharacter.doCustomProps
###############################