#107126: Make FCurve.update() also deduplicate keys

The RNA function `FCurve.update()` now also deduplicates keys. This is done
in a way that is independent of key selection; simply the last key in the
list of keyframes 'wins' and overwrites earlier ones. It is exactly the
same as `FCurve.keyframe_points.deduplicate()`.
This commit is contained in:
Sybren A. Stüvel 2023-06-09 11:29:06 +02:00
parent f5dd7d5e6c
commit 6452eccc80
2 changed files with 4 additions and 6 deletions

View File

@ -571,8 +571,6 @@ class KeyframesCo:
keyframe_points.foreach_set("co", co_buffer)
keyframe_points.foreach_set("interpolation", ipo_buffer)
# TODO: in Blender 4.0 the next lines can be replaced with one call to `fcurve.update()`.
# See https://projects.blender.org/blender/blender/issues/107126 for more info.
keyframe_points.sort()
keyframe_points.deduplicate()
keyframe_points.handles_recalc()
# This also deduplicates keys where baked keys were inserted on the
# same frame as existing ones.
fcurve.update()

View File

@ -694,7 +694,7 @@ static void rna_tag_animation_update(Main *bmain, ID *id)
static void rna_FCurve_update_data_ex(ID *id, FCurve *fcu, Main *bmain)
{
sort_time_fcurve(fcu);
/* TODO: Blender 4.0 should call BKE_fcurve_deduplicate_keys(fcu) here. */
BKE_fcurve_deduplicate_keys(fcu);
BKE_fcurve_handles_recalc(fcu);
rna_tag_animation_update(bmain, id);