2023-05-31 16:19:06 +02:00
|
|
|
/* SPDX-FileCopyrightText: 2001-2002 NaN Holding BV. All rights reserved.
|
|
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
2021-07-20 16:13:14 +02:00
|
|
|
|
|
|
|
|
/** \file
|
|
|
|
|
* \ingroup bke
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "BKE_action.hh"
|
|
|
|
|
|
|
|
|
|
#include "BLI_listbase.h"
|
|
|
|
|
#include "BLI_string.h"
|
|
|
|
|
|
|
|
|
|
#include "DNA_action_types.h"
|
|
|
|
|
#include "DNA_anim_types.h"
|
2021-09-04 14:22:44 +10:00
|
|
|
#include "DNA_armature_types.h"
|
2021-07-20 16:13:14 +02:00
|
|
|
|
2024-10-07 16:13:56 +02:00
|
|
|
#include "ANIM_action_legacy.hh"
|
|
|
|
|
|
2021-07-20 16:13:14 +02:00
|
|
|
#include "MEM_guardedalloc.h"
|
|
|
|
|
|
|
|
|
|
namespace blender::bke {
|
|
|
|
|
|
2024-10-07 16:13:56 +02:00
|
|
|
void BKE_action_find_fcurves_with_bones(bAction *action, FoundFCurveCallback callback)
|
2021-07-20 16:13:14 +02:00
|
|
|
{
|
2024-10-07 16:13:56 +02:00
|
|
|
auto const_callback = [&](const FCurve *fcurve, const char *bone_name) {
|
|
|
|
|
callback(const_cast<FCurve *>(fcurve), bone_name);
|
|
|
|
|
};
|
|
|
|
|
BKE_action_find_fcurves_with_bones(const_cast<const bAction *>(action), const_callback);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BKE_action_find_fcurves_with_bones(const bAction *action, FoundFCurveCallbackConst callback)
|
|
|
|
|
{
|
|
|
|
|
/* As of writing this comment, this is only ever used in the pose library
|
|
|
|
|
* code, where actions are only supposed to have one slot. If either it
|
|
|
|
|
* starts getting used elsewhere or the pose library starts using multiple
|
|
|
|
|
* slots, this will need to be updated. */
|
|
|
|
|
const animrig::slot_handle_t slot_handle = animrig::first_slot_handle(*action);
|
|
|
|
|
|
|
|
|
|
for (const FCurve *fcu : animrig::legacy::fcurves_for_action_slot(action, slot_handle)) {
|
2021-09-04 14:22:44 +10:00
|
|
|
char bone_name[MAXBONENAME];
|
|
|
|
|
if (!BLI_str_quoted_substr(fcu->rna_path, "pose.bones[", bone_name, sizeof(bone_name))) {
|
2021-07-20 16:13:14 +02:00
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
callback(fcu, bone_name);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace blender::bke
|