diff options
author | Sybren A. Stüvel <sybren@blender.org> | 2021-04-20 18:12:12 +0300 |
---|---|---|
committer | Sybren A. Stüvel <sybren@blender.org> | 2021-04-22 11:33:07 +0300 |
commit | 7192ab614b49258cdbd70a9f020f3566a4e0c0a6 (patch) | |
tree | 5bd95726b6d256476aec1afd2c7a5d7c97af026b /release/scripts/modules | |
parent | 91c652e39aa2bdd0136e209bc1c5b4272db3838e (diff) |
Animation: add "LocRotScaleCProp" keying set
Add a keying set that includes location, rotation, scale, and custom
properties.
The keying set is intentionally not based on the "Whole Character"
keying set. Instead, it is generic enough to be used in both object and
pose animation, making it possible to quickly switch between animating
characters and props without switching keying sets.
This is, according to @rikkert, what the Blender Studio animators need
99.9% of the time.
Diffstat (limited to 'release/scripts/modules')
-rw-r--r-- | release/scripts/modules/keyingsets_utils.py | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/release/scripts/modules/keyingsets_utils.py b/release/scripts/modules/keyingsets_utils.py index 190f0282339..b7a15bbbc19 100644 --- a/release/scripts/modules/keyingsets_utils.py +++ b/release/scripts/modules/keyingsets_utils.py @@ -219,6 +219,40 @@ def RKS_GEN_scaling(_ksi, _context, ks, data): else: ks.paths.add(id_block, path) + +# Custom Properties +def RKS_GEN_custom_props(_ksi, _context, ks, data): + # get id-block and path info + id_block, base_path, grouping = get_transform_generators_base_info(data) + + # Only some RNA types can be animated. + prop_type_compat = {bpy.types.BoolProperty, + bpy.types.IntProperty, + bpy.types.FloatProperty} + + # When working with a pose, 'id_block' is the armature object (which should + # get the animation data), whereas 'data' is the bone being keyed. + for cprop_name in data.keys(): + # ignore special "_RNA_UI" used for UI editing + if cprop_name == "_RNA_UI": + continue + + prop_path = '["%s"]' % bpy.utils.escape_identifier(cprop_name) + try: + rna_property = data.path_resolve(prop_path, False) + except ValueError as ex: + # This happens when a custom property is set to None. In that case it cannot + # be converted to an FCurve-compatible value, so we can't keyframe it anyway. + continue + if rna_property.rna_type not in prop_type_compat: + continue + + path = "%s%s" % (base_path, prop_path) + if grouping: + ks.paths.add(id_block, path, group_method='NAMED', group_name=grouping) + else: + ks.paths.add(id_block, path) + # ------ |