From de31cecfafc9b08b79ea1f9aed894754b6938840 Mon Sep 17 00:00:00 2001 From: Christoph Lendenfeld Date: Fri, 31 Jan 2025 16:38:30 +0100 Subject: [PATCH] Fix #133731: Performance issue with many stashed actions When duplicating an action, it is stashed in the NLA on a muted track. Over time this can slow down blender, because certain code will look at every FCurve in every action in the NLA. To fix the performance issue, we can take advantage of the fact that stashed actions are put onto a muted NLA track. With this patch any strip on a muted NLA track is ignored in the Depsgraph evaluation. Measurements of `DEG_graph_relations_update` | - | Before | After | | - | - | - | | 50 actions | ~140 ms | ~10.0 ms | | 100 actions | ~250 ms | ~10.7 ms | Pull Request: https://projects.blender.org/blender/blender/pulls/133864 --- source/blender/blenkernel/intern/anim_data.cc | 6 +++++- .../blender/depsgraph/intern/builder/deg_builder_nodes.cc | 3 +++ .../depsgraph/intern/builder/deg_builder_relations.cc | 3 +++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/source/blender/blenkernel/intern/anim_data.cc b/source/blender/blenkernel/intern/anim_data.cc index 501d0695289..0b62f028ed3 100644 --- a/source/blender/blenkernel/intern/anim_data.cc +++ b/source/blender/blenkernel/intern/anim_data.cc @@ -1254,7 +1254,8 @@ static void nlastrips_apply_all_curves_cb(ID *id, } } -/* Helper for BKE_fcurves_main_cb() - Dispatch wrapped operator to all F-Curves */ +/* Helper for BKE_fcurves_main_cb() - Dispatch wrapped operator to all F-Curves. Muted NLA Tracks + * are ignored. */ static void adt_apply_all_fcurves_cb(ID *id, AnimData *adt, const FunctionRef func) @@ -1272,6 +1273,9 @@ static void adt_apply_all_fcurves_cb(ID *id, /* NLA Data - Animation Data for Strips */ LISTBASE_FOREACH (NlaTrack *, nlt, &adt->nla_tracks) { + if (nlt->flag & NLATRACK_MUTED) { + continue; + } nlastrips_apply_all_curves_cb(id, &nlt->strips, func); } } diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc index d58cbc2f980..3a32303570c 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc @@ -1257,6 +1257,9 @@ void DepsgraphNodeBuilder::build_animdata(ID *id) } /* NLA strips contain actions. */ LISTBASE_FOREACH (NlaTrack *, nlt, &adt->nla_tracks) { + if (nlt->flag & NLATRACK_MUTED) { + continue; + } build_animdata_nlastrip_targets(&nlt->strips); } /* Drivers. */ diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc index b9884fb6fad..e0cb7125d3c 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc @@ -1617,6 +1617,9 @@ void DepsgraphRelationBuilder::build_animdata_curves(ID *id) build_animdata_action_targets(id, adt->slot_handle, adt_key, operation_from, adt->action); } LISTBASE_FOREACH (NlaTrack *, nlt, &adt->nla_tracks) { + if (nlt->flag & NLATRACK_MUTED) { + continue; + } build_animdata_nlastrip_targets(id, adt_key, operation_from, &nlt->strips); } }