Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilipp Oeser <info@graphics-engineer.com>2021-12-16 15:12:36 +0300
committerPhilipp Oeser <info@graphics-engineer.com>2021-12-16 15:18:19 +0300
commitd6902668e366aa349053f7ed3428a05b5955f9a3 (patch)
tree1da367663de8f39923dd1628983207797645d034
parent6da23db5e0def6909797374a0689afa2b3f8d96f (diff)
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
-rw-r--r--source/blender/editors/interface/interface_ops.c38
1 files changed, 37 insertions, 1 deletions
diff --git a/source/blender/editors/interface/interface_ops.c b/source/blender/editors/interface/interface_ops.c
index b1a34a09eec..61869f3da41 100644
--- a/source/blender/editors/interface/interface_ops.c
+++ b/source/blender/editors/interface/interface_ops.c
@@ -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;
}