UI: support Copy To Selected for id-properties [GN modifier properties]

Both {key Alt} editing behavior as well as `Copy To Selected` were not
working on geometry nodes modifiers (even if these matched exactly -
having the same nodegroup - on multiple objects)

Reason is that code checks pointer equality on the discovered properties
[geometry nodes modifier properties are stored as ID properties], but
these are not the same across objects (since these are fetched from
NodesModifierSettings - which are different on different objects).

note: if general custom properties are "API defined" on existing classes,
this was working, we are getting the exact property for different IDs in
this case

Now be more permissive with ID properties not defined on classes in
general and dont check pointer equality for them. For ID properties on
specific IDs (not the ones defined on classes) this //might// be undesired
(havent spotted issues though, even if equally named ID properies with
different types existed -- this then simply does nothing).

For geometry nodes modifiers, new code also checks if the nodegroups are
the same [since generic naming "Input_XXX" is shared for all modifiers --
and starting to copy over things to unrelated modifiers is not desired
here].

Fixes T93983.

Maniphest Tasks: T93983

Differential Revision: https://developer.blender.org/D13573
This commit is contained in:
Philipp Oeser 2021-12-16 13:12:36 +01:00
parent 6da23db5e0
commit d6902668e3
Notes: blender-bot 2024-01-31 11:35:08 +01:00
Referenced by issue #93983, Copy To Selected (also ALT-changing with multiple objects selected) does not work with ID properties (this includes Geometry Nodes modifier UIs)
Referenced by issue #54862, Multi-Object Properties Editing
1 changed files with 37 additions and 1 deletions

View File

@ -1023,7 +1023,43 @@ bool UI_context_copy_to_selected_check(PointerRNA *ptr,
return false;
}
if ((lprop != prop)) {
/* Skip non-existing properties on link. This was previously covered with the lprop != prop check
* but we are now more permissive when it comes to ID properties, see below. */
if (lprop == NULL) {
return false;
}
if (RNA_property_type(lprop) != RNA_property_type(prop)) {
return false;
}
/* Check property pointers matching
* For ID properties, these pointers match
* - if the property is API defined on an existing class (and they are equally named)
* - never for ID properties on specific ID (even if they are equally named)
* - never for NodesModifierSettings properties (even if they are equally named)
*
* Be permissive on ID properties in the following cases:
* - NodesModifierSettings properties
* - (special check: only if the nodegroup matches, since the 'Input_n' properties are name
* based and similar on potentionally very different nodegroups)
* - ID properties on specific ID
* - (no special check, copying seems OK [even if type does not match -- does not do anything
* then])
*/
bool ignore_prop_eq = RNA_property_is_idprop(lprop) && RNA_property_is_idprop(prop);
if (RNA_struct_is_a(lptr.type, &RNA_NodesModifier) &&
RNA_struct_is_a(ptr->type, &RNA_NodesModifier)) {
ignore_prop_eq = false;
NodesModifierData *nmd_link = (NodesModifierData *)lptr.data;
NodesModifierData *nmd_src = (NodesModifierData *)ptr->data;
if (nmd_link->node_group == nmd_src->node_group) {
ignore_prop_eq = true;
}
}
if ((lprop != prop) && !ignore_prop_eq) {
return false;
}