diff options
author | Bastien Montagne <bastien@blender.org> | 2022-06-10 16:53:46 +0300 |
---|---|---|
committer | Bastien Montagne <bastien@blender.org> | 2022-06-10 16:56:55 +0300 |
commit | 4d0f7c3dcde22224b17e5c481fea11f99fe5b160 (patch) | |
tree | 84e949e88ec951d695ef12bd699d04905ed7caba /source/blender/blenkernel/intern | |
parent | f5d0a40122ab73e0a7c6dca93d94724e3c10600f (diff) |
LibOverride: Add util to check if a given Override Property is animated.
Searches in available animdata for fcuve(s) with matching RNA path.
Diffstat (limited to 'source/blender/blenkernel/intern')
-rw-r--r-- | source/blender/blenkernel/intern/lib_override.cc | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/source/blender/blenkernel/intern/lib_override.cc b/source/blender/blenkernel/intern/lib_override.cc index 56d0308a033..22012662180 100644 --- a/source/blender/blenkernel/intern/lib_override.cc +++ b/source/blender/blenkernel/intern/lib_override.cc @@ -21,8 +21,10 @@ #include "DEG_depsgraph.h" #include "DEG_depsgraph_build.h" +#include "BKE_anim_data.h" #include "BKE_armature.h" #include "BKE_collection.h" +#include "BKE_fcurve.h" #include "BKE_global.h" #include "BKE_idtype.h" #include "BKE_key.h" @@ -321,6 +323,34 @@ bool BKE_lib_override_library_is_system_defined(const Main *bmain, const ID *id) return false; } +bool BKE_lib_override_library_property_is_animated(const ID *id, + const IDOverrideLibraryProperty *override_prop, + const PropertyRNA *override_rna_prop, + const int rnaprop_index) +{ + AnimData *anim_data = BKE_animdata_from_id(id); + if (anim_data != nullptr) { + struct FCurve *fcurve; + char *index_token_start = const_cast<char *>( + RNA_path_array_index_token_find(override_prop->rna_path, override_rna_prop)); + if (index_token_start != nullptr) { + const char index_token_start_backup = *index_token_start; + *index_token_start = '\0'; + fcurve = BKE_animadata_fcurve_find_by_rna_path( + anim_data, override_prop->rna_path, rnaprop_index, nullptr, nullptr); + *index_token_start = index_token_start_backup; + } + else { + fcurve = BKE_animadata_fcurve_find_by_rna_path( + anim_data, override_prop->rna_path, 0, nullptr, nullptr); + } + if (fcurve != nullptr) { + return true; + } + } + return false; +} + static int foreachid_is_hierarchy_leaf_fn(LibraryIDLinkCallbackData *cb_data) { ID *id_owner = cb_data->id_owner; |