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
1 changed files with 8 additions and 0 deletions
Showing only changes of commit 4f9eabcf12 - Show all commits

View File

@ -298,6 +298,14 @@ 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 (!ELEM(prop->type,
eIDPropertyType::IDP_BOOLEAN,
eIDPropertyType::IDP_INT,
eIDPropertyType::IDP_FLOAT))
{
/* Ignore unkeyable properties. */

The IDP_ARRAY check is likely not sufficient. It might be an array of unkeyable types, and thus shouldn't be keyed.
I think it's better to keep the array check separate, as that would need to check the type of the array elements as well.

Probably best to move the ELEM(prop->type, eIDPropertyType::IDP_BOOLEAN, eIDPropertyType::IDP_INT, eIDPropertyType::IDP_FLOAT, eIDPropertyType::IDP_DOUBLE into a is_keyable_type() like function, and call that on the array elements as well.

The `IDP_ARRAY` check is likely not sufficient. It might be an array of unkeyable types, and thus shouldn't be keyed. I think it's better to keep the array check separate, as that would need to check the type of the array elements as well. Probably best to move the `ELEM(prop->type, eIDPropertyType::IDP_BOOLEAN, eIDPropertyType::IDP_INT, eIDPropertyType::IDP_FLOAT, eIDPropertyType::IDP_DOUBLE` into a `is_keyable_type()` like function, and call that on the array elements as well.

thanks for spotting that, I've made the changes, but I am not sure how I would create an Array with subtype Group.
I assume that can only be done using python?

thanks for spotting that, I've made the changes, but I am not sure how I would create an Array with subtype Group. I assume that can only be done using python?

I've done some more digging, and the code as it is seems to be safe. In source/blender/blenkernel/intern/idprop_create.cc there are three functions to create IDP_ARRAY properties, for int, float, and double, and so these are indeed always safe to key. Creating a custom property like object["name"] = ["a", "b", "c"] will create a property of a type that's shown as "Python" in the UI, not as "Array". If someone finds a way to create an array of groups, we'll get a bug report and handle it then, when we have a concrete counter-example.

I've done some more digging, and the code as it is seems to be safe. In `source/blender/blenkernel/intern/idprop_create.cc` there are three functions to create `IDP_ARRAY` properties, for `int`, `float`, and `double`, and so these are indeed always safe to key. Creating a custom property like `object["name"] = ["a", "b", "c"]` will create a property of a type that's shown as "Python" in the UI, not as "Array". If someone finds a way to create an array of groups, we'll get a bug report and handle it then, when we have a concrete counter-example.
continue;
}
std::string name = prop->name;
std::string rna_path = "[\"" + name + "\"]";
paths.append(rna_path);