Fix #119909: Unkeyable custom properties receive keyframes #119914

Merged
Christoph Lendenfeld merged 13 commits from ChrisLend/blender:fix_more_selective_when_keying_custom_props into main 2024-04-12 14:48:20 +02:00
3 changed files with 26 additions and 5 deletions
Showing only changes of commit e62142e9f3 - Show all commits

View File

@ -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)
mont29 marked this conversation as resolved Outdated

This name is not specific enough. Should be something like is_idproperty_keyable or so (the _type part can be removed I think, since it's not only checking the IDP type anymore).

This name is not specific enough. Should be something like `is_idproperty_keyable` or so (the `_type` part can be removed I think, since it's not only checking the IDP type anymore).
{
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<std::string> 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(
mont29 marked this conversation as resolved Outdated

I think is_resolved (or simply ok) could be a better name than resolved_path, as this variable does not contain "the resolved path".

I think `is_resolved` (or simply `ok`) could be a better name than `resolved_path`, as this variable does not contain "the resolved path".
ptr, path.c_str(), &resolved_ptr, &resolved_prop);
if (!resolved_path) {
continue;
}
if (is_keyable_type(prop, resolved_prop)) {
paths.append(path);
}
}
}
}

View File

@ -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.
* */
mont29 marked this conversation as resolved Outdated

* */ -> */

`* */` -> `*/`
bool RNA_property_is_runtime(const PropertyRNA *prop);
mont29 marked this conversation as resolved
Review

This should also be called by rna_Property_is_runtime_get then, to avoid code duplication.

This should also be called by `rna_Property_is_runtime_get` then, to avoid code duplication.
bool RNA_property_editable(const PointerRNA *ptr, PropertyRNA *prop);
/**
* Version of #RNA_property_editable that tries to return additional info in \a r_info

View File

@ -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);