Geometry Nodes: Hide node group selector for asset modifiers
When adding modifiers from assets in the new modifier menu, switching the node group the modifier uses afterwards will not be common. The goal is to replace the builtin modifier directly. In that case it's easier to just add a new modifier. The "Empty Modifier" item makes it easy to choose an arbitrary node group anyway. Combined with hiding the two sub-panels when they are unnecessary, many node-modifiers will look just as clean as their builtin counterparts. The option to show the data-block selector is added to the menu in the node header so it's still accessible though. Pull Request: https://projects.blender.org/blender/blender/pulls/111995
This commit is contained in:
@@ -219,6 +219,9 @@ static int modifier_add_asset_exec(bContext *C, wmOperator *op)
|
||||
id_us_plus(&node_group->id);
|
||||
MOD_nodes_update_interface(object, nmd);
|
||||
|
||||
/* By default, don't show the data-block selector since it's not usually necessary for assets. */
|
||||
nmd->flag |= NODES_MODIFIER_HIDE_DATABLOCK_SELECTOR;
|
||||
|
||||
STRNCPY(nmd->modifier.name, DATA_(node_group->id.name + 2));
|
||||
|
||||
WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, object);
|
||||
|
||||
@@ -3027,6 +3027,10 @@ static int drop_geometry_nodes_invoke(bContext *C, wmOperator *op, const wmEvent
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
if (!RNA_boolean_get(op->ptr, "show_datablock_in_modifier")) {
|
||||
nmd->flag |= NODES_MODIFIER_HIDE_DATABLOCK_SELECTOR;
|
||||
}
|
||||
|
||||
nmd->node_group = node_tree;
|
||||
id_us_plus(&node_tree->id);
|
||||
MOD_nodes_update_interface(ob, nmd);
|
||||
@@ -3057,6 +3061,11 @@ void OBJECT_OT_drop_geometry_nodes(wmOperatorType *ot)
|
||||
INT32_MIN,
|
||||
INT32_MAX);
|
||||
RNA_def_property_flag(prop, (PropertyFlag)(PROP_HIDDEN | PROP_SKIP_SAVE));
|
||||
RNA_def_boolean(ot->srna,
|
||||
"show_datablock_in_modifier",
|
||||
true,
|
||||
"Show the datablock selector in the modifier",
|
||||
"");
|
||||
}
|
||||
|
||||
/** \} */
|
||||
|
||||
@@ -911,6 +911,13 @@ static void view3d_id_drop_copy(bContext *C, wmDrag *drag, wmDropBox *drop)
|
||||
ID *id = WM_drag_get_local_ID_or_import_from_asset(C, drag, 0);
|
||||
|
||||
WM_operator_properties_id_lookup_set_from_id(drop->ptr, id);
|
||||
RNA_boolean_set(drop->ptr, "show_datablock_in_modifier", (drag->type != WM_DRAG_ASSET));
|
||||
}
|
||||
|
||||
static void view3d_geometry_nodes_drop_copy(bContext *C, wmDrag *drag, wmDropBox *drop)
|
||||
{
|
||||
view3d_id_drop_copy(C, drag, drop);
|
||||
RNA_boolean_set(drop->ptr, "show_datablock_in_modifier", (drag->type != WM_DRAG_ASSET));
|
||||
}
|
||||
|
||||
static void view3d_id_drop_copy_with_type(bContext *C, wmDrag *drag, wmDropBox *drop)
|
||||
@@ -1008,7 +1015,7 @@ static void view3d_dropboxes()
|
||||
WM_dropbox_add(lb,
|
||||
"OBJECT_OT_drop_geometry_nodes",
|
||||
view3d_geometry_nodes_drop_poll,
|
||||
view3d_id_drop_copy,
|
||||
view3d_geometry_nodes_drop_copy,
|
||||
WM_drag_free_imported_drag_ID,
|
||||
view3d_geometry_nodes_drop_tooltip);
|
||||
WM_dropbox_add(lb,
|
||||
|
||||
@@ -2333,9 +2333,19 @@ typedef struct NodesModifierData {
|
||||
* Directory where baked simulation states are stored. This may be relative to the .blend file.
|
||||
*/
|
||||
char *simulation_bake_directory;
|
||||
|
||||
/** NodesModifierFlag. */
|
||||
int8_t flag;
|
||||
|
||||
char _pad[7];
|
||||
|
||||
NodesModifierRuntimeHandle *runtime;
|
||||
} NodesModifierData;
|
||||
|
||||
typedef enum NodesModifierFlag {
|
||||
NODES_MODIFIER_HIDE_DATABLOCK_SELECTOR = (1 << 0),
|
||||
} NodesModifierFlag;
|
||||
|
||||
typedef struct MeshToVolumeModifierData {
|
||||
ModifierData modifier;
|
||||
|
||||
|
||||
@@ -7075,6 +7075,13 @@ static void rna_def_modifier_nodes(BlenderRNA *brna)
|
||||
prop, "Simulation Bake Directory", "Location on disk where the bake data is stored");
|
||||
RNA_def_property_update(prop, 0, nullptr);
|
||||
|
||||
prop = RNA_def_property(srna, "show_group_selector", PROP_BOOLEAN, PROP_NONE);
|
||||
RNA_def_property_boolean_negative_sdna(
|
||||
prop, nullptr, "flag", NODES_MODIFIER_HIDE_DATABLOCK_SELECTOR);
|
||||
RNA_def_property_ui_text(prop, "Show Node Group Selector", "");
|
||||
RNA_def_property_flag(prop, PROP_NO_DEG_UPDATE);
|
||||
RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, nullptr);
|
||||
|
||||
RNA_define_lib_overridable(false);
|
||||
}
|
||||
|
||||
|
||||
@@ -1487,16 +1487,18 @@ static void panel_draw(const bContext *C, Panel *panel)
|
||||
* attribute/value toggle requires a manually built layout anyway. */
|
||||
uiLayoutSetPropDecorate(layout, false);
|
||||
|
||||
uiTemplateID(layout,
|
||||
C,
|
||||
ptr,
|
||||
"node_group",
|
||||
"node.new_geometry_node_group_assign",
|
||||
nullptr,
|
||||
nullptr,
|
||||
0,
|
||||
false,
|
||||
nullptr);
|
||||
if (!(nmd->flag & NODES_MODIFIER_HIDE_DATABLOCK_SELECTOR)) {
|
||||
uiTemplateID(layout,
|
||||
C,
|
||||
ptr,
|
||||
"node_group",
|
||||
"node.new_geometry_node_group_assign",
|
||||
nullptr,
|
||||
nullptr,
|
||||
0,
|
||||
false,
|
||||
nullptr);
|
||||
}
|
||||
|
||||
if (nmd->node_group != nullptr && nmd->settings.properties != nullptr) {
|
||||
PointerRNA bmain_ptr = RNA_main_pointer_create(bmain);
|
||||
|
||||
@@ -288,6 +288,7 @@ static void modifier_ops_extra_draw(bContext *C, uiLayout *layout, void *md_v)
|
||||
WM_OP_INVOKE_DEFAULT,
|
||||
UI_ITEM_NONE,
|
||||
&op_ptr);
|
||||
uiItemR(layout, &ptr, "show_group_selector", UI_ITEM_NONE, nullptr, ICON_NONE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user