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
This commit is contained in:
parent
8185d07ace
commit
8964c02348
|
@ -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
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Reference in New Issue