Commit: d173a52f56be3dd0f1dea6a9628bad52d2fcd0f7 Author: Campbell Barton Date: Thu Dec 15 09:26:40 2022 +1100 Branches: master https://developer.blender.org/rBd173a52f56be3dd0f1dea6a9628bad52d2fcd0f7
Cleanup: doc-strings and minor changes to anim_utils.py - Follow sphinx conventions for doc-strings. - Use __slots__ for KeyframesCo as dynamically assigning new members isn't needed. - Import from bpy.types instead of assigning. - Split typing imports across multiple lines as they tend to become quite large. =================================================================== M release/scripts/modules/bpy_extras/anim_utils.py =================================================================== diff --git a/release/scripts/modules/bpy_extras/anim_utils.py b/release/scripts/modules/bpy_extras/anim_utils.py index 43973307ce6..3586401dd7a 100644 --- a/release/scripts/modules/bpy_extras/anim_utils.py +++ b/release/scripts/modules/bpy_extras/anim_utils.py @@ -9,13 +9,24 @@ __all__ = ( ) import bpy -from typing import Mapping, List, Tuple, Sequence +from bpy.types import Action -# (fcurve.data_path, fcurve.array_index) -FCurveKey = Tuple[str, int] -# [frame0, value0, frame1, value1, ...] +from typing import ( + List, + Mapping, + Sequence, + Tuple, +) + +FCurveKey = Tuple[ + # `fcurve.data_path`. + str, + # `fcurve.array_index`. + int, +] + +# List of `[frame0, value0, frame1, value1, ...]` pairs. ListKeyframes = List[float] -Action = bpy.types.Action def bake_action( @@ -144,11 +155,11 @@ def bake_action_iter( # Note: BBONE_PROPS is a list so we can preserve the ordering BBONE_PROPS = [ - 'bbone_curveinx', 'bbone_curveoutx', - 'bbone_curveinz', 'bbone_curveoutz', - 'bbone_rollin', 'bbone_rollout', - 'bbone_scalein', 'bbone_scaleout', - 'bbone_easein', 'bbone_easeout' + "bbone_curveinx", "bbone_curveoutx", + "bbone_curveinz", "bbone_curveoutz", + "bbone_rollin", "bbone_rollout", + "bbone_scalein", "bbone_scaleout", + "bbone_easein", "bbone_easeout" ] BBONE_PROPS_LENGTHS = { "bbone_curveinx": 1, @@ -433,14 +444,18 @@ def bake_action_iter( class KeyframesCo: - """A buffer for keyframe Co unpacked values per FCurveKey. FCurveKeys are added using - add_paths(), Co values stored using extend_co_values(), then finally use - insert_keyframes_into_*_action() for efficiently inserting keys into the fcurves. + """ + A buffer for keyframe Co unpacked values per ``FCurveKey``. ``FCurveKeys`` are added using + ``add_paths()``, Co values stored using extend_co_values(), then finally use + ``insert_keyframes_into_*_action()`` for efficiently inserting keys into the F-curves. Users are limited to one Action Group per instance. """ + __slots__ = ( + "keyframes_from_fcurve", + ) - # keyframes[(rna_path, array_index)] = list(time0,value0, time1,value1,...) + # `keyframes[(rna_path, array_index)] = list(time0,value0, time1,value1,...)`. keyframes_from_fcurve: Mapping[FCurveKey, ListKeyframes] def __init__(self): @@ -480,11 +495,12 @@ class KeyframesCo: action: Action, action_group_name: str, ) -> None: - """Assumes the action is new, that it has no fcurves. Otherwise, the only difference between versions is + """ + Assumes the action is new, that it has no F-curves. Otherwise, the only difference between versions is performance and implementation simplicity. - Args: - action_group_name (str): Name of Action Group that fcurves are added to. + :arg action_group_name: Name of Action Group that F-curves are added to. + :type action_group_name: str """ linear_enum_values = [ bpy.types.Keyframe.bl_rna.properties["interpolation"].enum_items["LINEAR"].value @@ -513,14 +529,15 @@ class KeyframesCo: action: Action, action_group_name: str, ) -> None: - """Assumes the action already exists, that it might already have fcurves. Otherwise, the + """ + Assumes the action already exists, that it might already have F-curves. Otherwise, the only difference between versions is performance and implementation simplicity. - Args: - lookup_fcurves (Mapping[FCurveKey, bpy.types.FCurve]): This is only used for efficiency. - It's a substitute for action.fcurves.find() which is a potentially expensive linear - search. - action_group_name (str): Name of Action Group that fcurves are added to. + :arg lookup_fcurves: : This is only used for efficiency. + It's a substitute for ``action.fcurves.find()`` which is a potentially expensive linear search. + :type lookup_fcurves: ``Mapping[FCurveKey, bpy.types.FCurve]`` + :arg action_group_name: Name of Action Group that F-curves are added to. + :type action_group_name: str """ linear_enum_values = [ bpy.types.Keyframe.bl_rna.properties["interpolation"].enum_items["LINEAR"].value _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs