From 5a79c8f31d8a73258c8353dcbfbf00dccd5f32d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Tue, 24 Sep 2024 14:50:08 +0200 Subject: [PATCH] Refactor: modern API for getting FCurves in Legacy Grease Pencil anim code No functional changes. Ref: #123424 Pull Request: https://projects.blender.org/blender/blender/pulls/128069 --- .../editors/gpencil_legacy/gpencil_bake_animation.cc | 8 +++----- source/blender/editors/gpencil_legacy/gpencil_mesh.cc | 8 +++----- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/source/blender/editors/gpencil_legacy/gpencil_bake_animation.cc b/source/blender/editors/gpencil_legacy/gpencil_bake_animation.cc index 525cf876b94..08bc8f2a266 100644 --- a/source/blender/editors/gpencil_legacy/gpencil_bake_animation.cc +++ b/source/blender/editors/gpencil_legacy/gpencil_bake_animation.cc @@ -25,6 +25,8 @@ #include "BKE_material.h" #include "BKE_scene.hh" +#include "ANIM_action_legacy.hh" + #include "BLT_translation.hh" #include "DEG_depsgraph.hh" @@ -103,11 +105,7 @@ static void animdata_keyframe_list_get(ListBase *ob_list, /* Loop all objects to get the list of keyframes used. */ LISTBASE_FOREACH (GpBakeOb *, elem, ob_list) { Object *ob = elem->ob; - AnimData *adt = BKE_animdata_from_id(&ob->id); - if ((adt == nullptr) || (adt->action == nullptr)) { - continue; - } - LISTBASE_FOREACH (FCurve *, fcurve, &adt->action->curves) { + for (FCurve *fcurve : blender::animrig::legacy::fcurves_for_assigned_action(ob->adt)) { int i; BezTriple *bezt; for (i = 0, bezt = fcurve->bezt; i < fcurve->totvert; i++, bezt++) { diff --git a/source/blender/editors/gpencil_legacy/gpencil_mesh.cc b/source/blender/editors/gpencil_legacy/gpencil_mesh.cc index 1315da56774..1de1a5b8c5b 100644 --- a/source/blender/editors/gpencil_legacy/gpencil_mesh.cc +++ b/source/blender/editors/gpencil_legacy/gpencil_mesh.cc @@ -29,6 +29,8 @@ #include "BKE_report.hh" #include "BKE_scene.hh" +#include "ANIM_action_legacy.hh" + #include "DEG_depsgraph.hh" #include "DEG_depsgraph_query.hh" @@ -79,11 +81,7 @@ static void animdata_keyframe_list_get(ListBase *ob_list, /* Loop all objects to get the list of keyframes used. */ LISTBASE_FOREACH (GpBakeOb *, elem, ob_list) { Object *ob = elem->ob; - AnimData *adt = BKE_animdata_from_id(&ob->id); - if ((adt == nullptr) || (adt->action == nullptr)) { - continue; - } - LISTBASE_FOREACH (FCurve *, fcurve, &adt->action->curves) { + for (FCurve *fcurve : blender::animrig::legacy::fcurves_for_assigned_action(ob->adt)) { int i; BezTriple *bezt; for (i = 0, bezt = fcurve->bezt; i < fcurve->totvert; i++, bezt++) {