diff options
author | Alexander Gavrilov <angavrilov@gmail.com> | 2021-01-13 12:36:02 +0300 |
---|---|---|
committer | Alexander Gavrilov <angavrilov@gmail.com> | 2021-01-13 14:09:31 +0300 |
commit | 8964c02348f61c2ce8046c09478180ddfbd0f8e5 (patch) | |
tree | 9045cf9a32903d4cc2fb13d90fd449f0a99a3f71 /source/blender/makesrna/intern | |
parent | 8185d07ace493a74fb1b99636f4bb80174b81418 (diff) |
RNA: allow editing pointer IDProperty values from the UI.
Currently it is not possible to edit bare IDProperty pointer
values which are not explicitly defined through python via
UI fields. This is likely mostly because, unlike numeric values,
pointers aren't marked PROP_EDITABLE by default. However there
are also some bugs in the RNA code that need fixing.
The Geometry Nodes modifier uses bare properties to store
input settings for the node group it wraps, so supporting
Object and Collection sockets requires editable pointers.
This patch marks bare IDProperties editable, and ensures
that changing ID pointers rebuilds the dependency graph.
A type check is needed because an IDPROPERTY PointerPropertyRNA
can actually wrap a group value rather than an ID pointer.
Making pointers editable is not likely to accidentally
affect UI fields that were not intended to be editable,
because a simple `layout.prop` cannot determine which
datablocks to display in the menu and remains read-only.
The PROP_NEVER_UNLINK flag is also removed: it seems it
was added because the edit field that couldn't produce
a menu to set the pointer used to still display the unlink
button, but that seems not to be the case anymore.
Actual support for Object & Collection inputs in the modifier
is added in D10056, which can be used to test this code.
Differential Revision: https://developer.blender.org/D10098
Diffstat (limited to 'source/blender/makesrna/intern')
-rw-r--r-- | source/blender/makesrna/intern/rna_ID.c | 2 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_access.c | 6 |
2 files changed, 7 insertions, 1 deletions
diff --git a/source/blender/makesrna/intern/rna_ID.c b/source/blender/makesrna/intern/rna_ID.c index 5e3c234708a..fd19352a9a5 100644 --- a/source/blender/makesrna/intern/rna_ID.c +++ b/source/blender/makesrna/intern/rna_ID.c @@ -1113,7 +1113,7 @@ static void rna_def_ID_properties(BlenderRNA *brna) /* IDP_ID */ prop = RNA_def_property(srna, "id", PROP_POINTER, PROP_NONE); - RNA_def_property_flag(prop, PROP_IDPROPERTY | PROP_NEVER_UNLINK); + RNA_def_property_flag(prop, PROP_IDPROPERTY | PROP_EDITABLE); RNA_def_property_struct_type(prop, "ID"); /* ID property groups > level 0, since level 0 group is merged diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c index 70757573051..ae23e0b9109 100644 --- a/source/blender/makesrna/intern/rna_access.c +++ b/source/blender/makesrna/intern/rna_access.c @@ -52,6 +52,7 @@ #include "BKE_report.h" #include "DEG_depsgraph.h" +#include "DEG_depsgraph_build.h" #include "RNA_access.h" #include "RNA_define.h" @@ -2289,6 +2290,11 @@ static void rna_property_update( DEG_id_tag_update(ptr->owner_id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY | ID_RECALC_PARAMETERS); + /* When updating an ID pointer property, tag depsgraph for update. */ + if (prop->type == PROP_POINTER && RNA_struct_is_ID(RNA_property_pointer_type(ptr, prop))) { + DEG_relations_tag_update(bmain); + } + WM_main_add_notifier(NC_WINDOW, NULL); /* Not nice as well, but the only way to make sure material preview * is updated with custom nodes. |