diff --git a/source/blender/makesrna/intern/rna_action.cc b/source/blender/makesrna/intern/rna_action.cc index 762ea0afc51..95275ce49a3 100644 --- a/source/blender/makesrna/intern/rna_action.cc +++ b/source/blender/makesrna/intern/rna_action.cc @@ -585,7 +585,7 @@ static bool rna_ActionStrip_key_insert(ID *dna_action_id, return ok; } -static std::optional rna_Channelbag_path(const PointerRNA *ptr) +std::optional rna_Channelbag_path(const PointerRNA *ptr) { animrig::Action &action = rna_action(ptr); animrig::Channelbag &cbag_to_find = rna_data_channelbag(ptr); diff --git a/source/blender/makesrna/intern/rna_fcurve.cc b/source/blender/makesrna/intern/rna_fcurve.cc index 411df12e617..c6e4ef7051d 100644 --- a/source/blender/makesrna/intern/rna_fcurve.cc +++ b/source/blender/makesrna/intern/rna_fcurve.cc @@ -24,6 +24,8 @@ #include "ED_keyframing.hh" +#include + const EnumPropertyItem rna_enum_fmodifier_type_items[] = { {FMODIFIER_TYPE_NULL, "NULL", 0, "Invalid", ""}, {FMODIFIER_TYPE_GENERATOR, @@ -550,6 +552,34 @@ static void rna_FKeyframe_ctrlpoint_ui_set(PointerRNA *ptr, const float *values) /* ****************************** */ +static std::optional rna_FCurve_path(const PointerRNA *ptr) +{ + using namespace blender; + FCurve *fcurve = reinterpret_cast(ptr->data); + animrig::Action &action = reinterpret_cast(ptr->owner_id)->wrap(); + + for (animrig::Layer *layer : action.layers()) { + for (animrig::Strip *strip : layer->strips()) { + if (strip->type() != animrig::Strip::Type::Keyframe) { + continue; + } + + animrig::StripKeyframeData &strip_data = strip->data(action); + for (animrig::Channelbag *channelbag : strip_data.channelbags()) { + const int fcurve_index = channelbag->fcurves().first_index_try(fcurve); + if (fcurve_index != -1) { + PointerRNA channelbag_ptr = RNA_pointer_create_discrete( + &action.id, &RNA_ActionChannelbag, channelbag); + const std::optional channelbag_path = rna_Channelbag_path(&channelbag_ptr); + return fmt::format("{}.fcurves[{}]", *channelbag_path, fcurve_index); + } + } + } + } + + return std::nullopt; +} + static void rna_FCurve_RnaPath_get(PointerRNA *ptr, char *value) { FCurve *fcu = (FCurve *)ptr->data; @@ -2538,6 +2568,7 @@ static void rna_def_fcurve(BlenderRNA *brna) srna = RNA_def_struct(brna, "FCurve", nullptr); RNA_def_struct_ui_text(srna, "F-Curve", "F-Curve defining values of a period of time"); RNA_def_struct_ui_icon(srna, ICON_ANIM_DATA); + RNA_def_struct_path_func(srna, "rna_FCurve_path"); /* Enums */ prop = RNA_def_property(srna, "extrapolation", PROP_ENUM, PROP_NONE); diff --git a/source/blender/makesrna/intern/rna_internal.hh b/source/blender/makesrna/intern/rna_internal.hh index 5792edcdebe..ef030216696 100644 --- a/source/blender/makesrna/intern/rna_internal.hh +++ b/source/blender/makesrna/intern/rna_internal.hh @@ -395,6 +395,8 @@ std::optional rna_ColorManagedDisplaySettings_path(const PointerRNA std::optional rna_ColorManagedViewSettings_path(const PointerRNA *ptr); std::optional rna_ColorManagedInputColorspaceSettings_path(const PointerRNA *ptr); +std::optional rna_Channelbag_path(const PointerRNA *ptr); + /* Node socket subtypes for group interface. */ void rna_def_node_socket_interface_subtypes(BlenderRNA *brna);