From ec0ecf08daace5bd01fd1df205a0266837f758e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Tue, 1 Oct 2024 11:44:31 +0200 Subject: [PATCH] Refactor: Anim, use blender::listbase_to_vector Add a `const` version of `blender::listbase_to_vector`, and use it in `animrig::fcurves_for_action_slot()`. No functional changes. --- source/blender/animrig/intern/action_legacy.cc | 8 +++----- source/blender/blenlib/BLI_listbase_wrapper.hh | 13 +++++++++++++ 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/source/blender/animrig/intern/action_legacy.cc b/source/blender/animrig/intern/action_legacy.cc index cc3cedc2dad..f8cb8a0a845 100644 --- a/source/blender/animrig/intern/action_legacy.cc +++ b/source/blender/animrig/intern/action_legacy.cc @@ -5,6 +5,8 @@ #include "ANIM_action.hh" #include "ANIM_action_legacy.hh" +#include "BLI_listbase_wrapper.hh" + #include "BKE_fcurve.hh" namespace blender::animrig::legacy { @@ -140,11 +142,7 @@ static Vector fcurves_for_action_slot_templated(ActionType &action /* Legacy Action. */ if (action.is_action_legacy()) { #endif /* WITH_ANIM_BAKLAVA */ - Vector legacy_fcurves; - LISTBASE_FOREACH (FCurveType *, fcurve, &action.curves) { - legacy_fcurves.append(fcurve); - } - return legacy_fcurves; + return listbase_to_vector(action.curves); #ifdef WITH_ANIM_BAKLAVA } diff --git a/source/blender/blenlib/BLI_listbase_wrapper.hh b/source/blender/blenlib/BLI_listbase_wrapper.hh index 7bf5f9c73db..d08cea2267f 100644 --- a/source/blender/blenlib/BLI_listbase_wrapper.hh +++ b/source/blender/blenlib/BLI_listbase_wrapper.hh @@ -112,4 +112,17 @@ template Vector listbase_to_vector(ListBase &list) return vector; } +/** + * Convert a ListBase to a Vector. + */ +template Vector listbase_to_vector(const ListBase &list) +{ + Vector vector; + + for (T *item : ConstListBaseWrapper(list)) { + vector.append(item); + } + return vector; +} + } /* namespace blender */