bdk-blender/scripts/modules/bpy_extras
Sybren A. Stüvel 85ed2e8c36 Animation: add function for deduplicating FCurve keys
Introduce `BKE_fcurve_deduplicate_keys()` to merge keys that are on the
same time, or within the time comparison threshold (1/100th of a frame).

When merging two consecutive keys, the last one 'wins' and determines
the final key *value*. The first key's *time* is retained, to ensure the
reference point for the next comparisons is stable. The only exception
here is when there is a key exactly on an integer frame number, in which
case that one is preferred.

The function is exposed in RNA as `fcurve.keyframe_points.deduplicate()`

This commit also introduces a new function `BKE_fcurve_bezt_shrink(fcu,
new_totvert);` that can reallocate the `bezt` array to ensure removed
keys no longer take up memory.

The RNA function `fcurve.update()` currently performs two steps, which
are now exposed to RNA as well, as `keyframe_points.sort()` and
`keyframe_points.handles_recalc()`. This is so that Python code can
sort, deduplicate, and then recalculate the handles only once (calling
`update` + `deduplicate` would do the latter twice).

In Blender 4.0 the deduplication will also be part of `fcurve.update()`,
see #107126.

Reviewed on blender/blender#107089
2023-04-24 12:07:28 +02:00
..
wm_utils Cleanup: double quotes for non-enum strings 2023-04-18 10:51:32 +10:00
__init__.py
anim_utils.py Animation: add function for deduplicating FCurve keys 2023-04-24 12:07:28 +02:00
asset_utils.py
bmesh_utils.py
id_map_utils.py
image_utils.py
io_utils.py Cleanup: double quotes for non-enum strings 2023-04-18 10:51:32 +10:00
keyconfig_utils.py Cleanup: quiet various pylint warnings 2023-04-13 13:14:05 +10:00
mesh_utils.py Cleanup: quiet various pylint warnings 2023-04-13 13:14:05 +10:00
node_shader_utils.py Cleanup: double quotes for non-enum strings 2023-04-18 10:51:32 +10:00
node_utils.py Cleanup: quiet various pylint warnings 2023-04-13 13:14:05 +10:00
object_utils.py
view3d_utils.py