From 4f9eabcf12c63557e3fe82acf1e99186a3abbf5a Mon Sep 17 00:00:00 2001 From: Christoph Lendenfeld Date: Tue, 26 Mar 2024 12:08:31 +0100 Subject: [PATCH 1/8] the fix --- source/blender/editors/animation/keyframing.cc | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/source/blender/editors/animation/keyframing.cc b/source/blender/editors/animation/keyframing.cc index 75f8004781b..f572b3e3e86 100644 --- a/source/blender/editors/animation/keyframing.cc +++ b/source/blender/editors/animation/keyframing.cc @@ -298,6 +298,14 @@ static blender::Vector construct_rna_paths(PointerRNA *ptr) if (insert_channel_flags & USER_ANIM_KEY_CHANNEL_CUSTOM_PROPERTIES) { if (properties) { LISTBASE_FOREACH (IDProperty *, prop, &properties->data.group) { + if (!ELEM(prop->type, + eIDPropertyType::IDP_BOOLEAN, + eIDPropertyType::IDP_INT, + eIDPropertyType::IDP_FLOAT)) + { + /* Ignore unkeyable properties. */ + continue; + } std::string name = prop->name; std::string rna_path = "[\"" + name + "\"]"; paths.append(rna_path); -- 2.30.2 From 2da2e7a250bb4f7a8cccb1897708984e1a882b73 Mon Sep 17 00:00:00 2001 From: Christoph Lendenfeld Date: Tue, 26 Mar 2024 12:44:06 +0100 Subject: [PATCH 2/8] also include double and array --- source/blender/editors/animation/keyframing.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/source/blender/editors/animation/keyframing.cc b/source/blender/editors/animation/keyframing.cc index f572b3e3e86..377ff0214f9 100644 --- a/source/blender/editors/animation/keyframing.cc +++ b/source/blender/editors/animation/keyframing.cc @@ -301,7 +301,9 @@ static blender::Vector construct_rna_paths(PointerRNA *ptr) if (!ELEM(prop->type, eIDPropertyType::IDP_BOOLEAN, eIDPropertyType::IDP_INT, - eIDPropertyType::IDP_FLOAT)) + eIDPropertyType::IDP_FLOAT, + eIDPropertyType::IDP_DOUBLE, + eIDPropertyType::IDP_ARRAY)) { /* Ignore unkeyable properties. */ continue; -- 2.30.2 From fdbf16fb5465d317220912302c68e5cc08628379 Mon Sep 17 00:00:00 2001 From: Christoph Lendenfeld Date: Tue, 26 Mar 2024 15:45:57 +0100 Subject: [PATCH 3/8] extract function --- .../blender/editors/animation/keyframing.cc | 34 ++++++++++++++----- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/source/blender/editors/animation/keyframing.cc b/source/blender/editors/animation/keyframing.cc index 377ff0214f9..89fee14449e 100644 --- a/source/blender/editors/animation/keyframing.cc +++ b/source/blender/editors/animation/keyframing.cc @@ -245,6 +245,31 @@ static int insert_key_with_keyingset(bContext *C, wmOperator *op, KeyingSet *ks) return OPERATOR_FINISHED; } +static bool is_keyable_type(IDProperty *prop) +{ + if (ELEM(prop->type, + eIDPropertyType::IDP_BOOLEAN, + eIDPropertyType::IDP_INT, + eIDPropertyType::IDP_FLOAT, + eIDPropertyType::IDP_DOUBLE)) + { + return true; + } + + if (prop->type == eIDPropertyType::IDP_ARRAY) { + if (ELEM(prop->subtype, + eIDPropertyType::IDP_BOOLEAN, + eIDPropertyType::IDP_INT, + eIDPropertyType::IDP_FLOAT, + eIDPropertyType::IDP_DOUBLE)) + { + return true; + } + } + + return false; +} + static blender::Vector construct_rna_paths(PointerRNA *ptr) { eRotationModes rotation_mode; @@ -298,14 +323,7 @@ static blender::Vector construct_rna_paths(PointerRNA *ptr) if (insert_channel_flags & USER_ANIM_KEY_CHANNEL_CUSTOM_PROPERTIES) { if (properties) { LISTBASE_FOREACH (IDProperty *, prop, &properties->data.group) { - if (!ELEM(prop->type, - eIDPropertyType::IDP_BOOLEAN, - eIDPropertyType::IDP_INT, - eIDPropertyType::IDP_FLOAT, - eIDPropertyType::IDP_DOUBLE, - eIDPropertyType::IDP_ARRAY)) - { - /* Ignore unkeyable properties. */ + if (!is_keyable_type(prop)) { continue; } std::string name = prop->name; -- 2.30.2 From e62142e9f330f481ee18f4e61a6759877b898368 Mon Sep 17 00:00:00 2001 From: Christoph Lendenfeld Date: Tue, 2 Apr 2024 16:47:39 +0200 Subject: [PATCH 4/8] create RNA function --- .../blender/editors/animation/keyframing.cc | 21 ++++++++++++++----- source/blender/makesrna/RNA_access.hh | 5 +++++ source/blender/makesrna/intern/rna_access.cc | 5 +++++ 3 files changed, 26 insertions(+), 5 deletions(-) diff --git a/source/blender/editors/animation/keyframing.cc b/source/blender/editors/animation/keyframing.cc index dec77c545c8..76c7144c6d7 100644 --- a/source/blender/editors/animation/keyframing.cc +++ b/source/blender/editors/animation/keyframing.cc @@ -247,8 +247,12 @@ static int insert_key_with_keyingset(bContext *C, wmOperator *op, KeyingSet *ks) return OPERATOR_FINISHED; } -static bool is_keyable_type(IDProperty *prop) +static bool is_keyable_type(IDProperty *prop, const PropertyRNA *property_rna) { + if (RNA_property_is_runtime(property_rna)) { + return false; + } + if (ELEM(prop->type, eIDPropertyType::IDP_BOOLEAN, eIDPropertyType::IDP_INT, @@ -325,12 +329,19 @@ static blender::Vector construct_rna_paths(PointerRNA *ptr) if (insert_channel_flags & USER_ANIM_KEY_CHANNEL_CUSTOM_PROPERTIES) { if (properties) { LISTBASE_FOREACH (IDProperty *, prop, &properties->data.group) { - if (!is_keyable_type(prop)) { - continue; - } char name_escaped[MAX_IDPROP_NAME * 2]; BLI_str_escape(name_escaped, prop->name, sizeof(name_escaped)); - paths.append(fmt::format("[\"{}\"]", name_escaped)); + std::string path = fmt::format("[\"{}\"]", name_escaped); + PointerRNA resolved_ptr; + PropertyRNA *resolved_prop; + const bool resolved_path = RNA_path_resolve_property( + ptr, path.c_str(), &resolved_ptr, &resolved_prop); + if (!resolved_path) { + continue; + } + if (is_keyable_type(prop, resolved_prop)) { + paths.append(path); + } } } } diff --git a/source/blender/makesrna/RNA_access.hh b/source/blender/makesrna/RNA_access.hh index f84999841b5..ef66c6d4de1 100644 --- a/source/blender/makesrna/RNA_access.hh +++ b/source/blender/makesrna/RNA_access.hh @@ -288,6 +288,11 @@ int RNA_property_enum_bitflag_identifiers( StructRNA *RNA_property_pointer_type(PointerRNA *ptr, PropertyRNA *prop); bool RNA_property_pointer_poll(PointerRNA *ptr, PropertyRNA *prop, PointerRNA *value); +/** + * A property is a runtime property if the PROP_INTERN_RUNTIME flag is set on it. + * */ +bool RNA_property_is_runtime(const PropertyRNA *prop); + bool RNA_property_editable(const PointerRNA *ptr, PropertyRNA *prop); /** * Version of #RNA_property_editable that tries to return additional info in \a r_info diff --git a/source/blender/makesrna/intern/rna_access.cc b/source/blender/makesrna/intern/rna_access.cc index d59d9303003..e2ec63b9306 100644 --- a/source/blender/makesrna/intern/rna_access.cc +++ b/source/blender/makesrna/intern/rna_access.cc @@ -2162,6 +2162,11 @@ static bool rna_property_editable_do(const PointerRNA *ptr, return true; } +bool RNA_property_is_runtime(const PropertyRNA *prop) +{ + return prop->flag_internal & PROP_INTERN_RUNTIME; +} + bool RNA_property_editable(const PointerRNA *ptr, PropertyRNA *prop) { return rna_property_editable_do(ptr, prop, -1, nullptr); -- 2.30.2 From 7dc2f7fedf6e7c2ec90dc5b9428d7708b1a0802c Mon Sep 17 00:00:00 2001 From: Christoph Lendenfeld Date: Fri, 5 Apr 2024 09:18:35 +0200 Subject: [PATCH 5/8] cleanup comment --- source/blender/makesrna/RNA_access.hh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/makesrna/RNA_access.hh b/source/blender/makesrna/RNA_access.hh index ef66c6d4de1..affdf43b3b0 100644 --- a/source/blender/makesrna/RNA_access.hh +++ b/source/blender/makesrna/RNA_access.hh @@ -290,7 +290,7 @@ bool RNA_property_pointer_poll(PointerRNA *ptr, PropertyRNA *prop, PointerRNA *v /** * A property is a runtime property if the PROP_INTERN_RUNTIME flag is set on it. - * */ + */ bool RNA_property_is_runtime(const PropertyRNA *prop); bool RNA_property_editable(const PointerRNA *ptr, PropertyRNA *prop); -- 2.30.2 From 46bf595d28f26c749a045f4d98b178cf1824b488 Mon Sep 17 00:00:00 2001 From: Christoph Lendenfeld Date: Fri, 12 Apr 2024 11:56:04 +0200 Subject: [PATCH 6/8] use RNA_property_is_runtime in rna_Property_is_runtime_get --- source/blender/makesrna/intern/rna_rna.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/makesrna/intern/rna_rna.cc b/source/blender/makesrna/intern/rna_rna.cc index 83057af3897..a5cb6f5405c 100644 --- a/source/blender/makesrna/intern/rna_rna.cc +++ b/source/blender/makesrna/intern/rna_rna.cc @@ -843,7 +843,7 @@ static bool rna_Property_is_registered_optional_get(PointerRNA *ptr) static bool rna_Property_is_runtime_get(PointerRNA *ptr) { PropertyRNA *prop = (PropertyRNA *)ptr->data; - return (prop->flag_internal & PROP_INTERN_RUNTIME) != 0; + return RNA_property_is_runtime(prop); } static bool rna_BoolProperty_default_get(PointerRNA *ptr) -- 2.30.2 From 8097f36fa487dd9c3b5450dc2b1e7aed60c941a5 Mon Sep 17 00:00:00 2001 From: Christoph Lendenfeld Date: Fri, 12 Apr 2024 12:02:12 +0200 Subject: [PATCH 7/8] rename function --- source/blender/editors/animation/keyframing.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/blender/editors/animation/keyframing.cc b/source/blender/editors/animation/keyframing.cc index 395ff2dd6d3..dc65a322915 100644 --- a/source/blender/editors/animation/keyframing.cc +++ b/source/blender/editors/animation/keyframing.cc @@ -247,7 +247,7 @@ static int insert_key_with_keyingset(bContext *C, wmOperator *op, KeyingSet *ks) return OPERATOR_FINISHED; } -static bool is_keyable_type(IDProperty *prop, const PropertyRNA *property_rna) +static bool is_idproperty_keyable(IDProperty *prop, const PropertyRNA *property_rna) { if (RNA_property_is_runtime(property_rna)) { return false; @@ -339,7 +339,7 @@ static blender::Vector construct_rna_paths(PointerRNA *ptr) if (!resolved_path) { continue; } - if (is_keyable_type(prop, resolved_prop)) { + if (is_idproperty_keyable(prop, resolved_prop)) { paths.append(path); } } -- 2.30.2 From 73d2fc08d949552cea7d1e56a1bc2fec3f46cc11 Mon Sep 17 00:00:00 2001 From: Christoph Lendenfeld Date: Fri, 12 Apr 2024 12:21:00 +0200 Subject: [PATCH 8/8] change var name --- source/blender/editors/animation/keyframing.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/blender/editors/animation/keyframing.cc b/source/blender/editors/animation/keyframing.cc index dc65a322915..5745d0bbd46 100644 --- a/source/blender/editors/animation/keyframing.cc +++ b/source/blender/editors/animation/keyframing.cc @@ -334,9 +334,9 @@ static blender::Vector construct_rna_paths(PointerRNA *ptr) std::string path = fmt::format("[\"{}\"]", name_escaped); PointerRNA resolved_ptr; PropertyRNA *resolved_prop; - const bool resolved_path = RNA_path_resolve_property( + const bool is_resolved = RNA_path_resolve_property( ptr, path.c_str(), &resolved_ptr, &resolved_prop); - if (!resolved_path) { + if (!is_resolved) { continue; } if (is_idproperty_keyable(prop, resolved_prop)) { -- 2.30.2