Geometry Nodes: reorganize panels in modifier

The goal is to simplify the interface of the geometry nodes modifier while also
making it more scalable. This allows creating better looking modifiers which
feel more built-in. No functionality is removed by this patch.

The following changes are done:
* The `Output Attributes` panel is hidden when there are no output attributes.
* The `Internal Dependencies` panel is replaced by a new `Manage` panel that
  contains all the stuff that is common to all geometry nodes modifiers. It
  contains new `Bake` and `Named Attributes` panels for now.

Potential next steps:
* Merge `Output Attributes` panel with the rest of the input list.
* Support hiding the `Manage` panel under some circumstances.

Pull Request: https://projects.blender.org/blender/blender/pulls/117170
This commit is contained in:
Jacques Lucke
2024-01-17 13:40:30 +01:00
parent 8feba61c41
commit 9df4ffc0c2
2 changed files with 48 additions and 16 deletions

View File

@@ -7332,7 +7332,9 @@ static void rna_def_modifier_nodes(BlenderRNA *brna)
RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, nullptr);
rna_def_modifier_panel_open_prop(srna, "open_output_attributes_panel", 0);
rna_def_modifier_panel_open_prop(srna, "open_internal_dependencies_panel", 1);
rna_def_modifier_panel_open_prop(srna, "open_manage_panel", 1);
rna_def_modifier_panel_open_prop(srna, "open_bake_panel", 2);
rna_def_modifier_panel_open_prop(srna, "open_named_attributes_panel", 3);
RNA_define_lib_overridable(false);
}

View File

@@ -1931,37 +1931,48 @@ static void draw_interface_panel_content(const bContext *C,
}
}
static bool has_output_attribute(const NodesModifierData &nmd)
{
if (!nmd.node_group) {
return false;
}
for (const bNodeTreeInterfaceSocket *interface_socket : nmd.node_group->interface_outputs()) {
const bNodeSocketType *typeinfo = interface_socket->socket_typeinfo();
const eNodeSocketDatatype type = typeinfo ? eNodeSocketDatatype(typeinfo->type) : SOCK_CUSTOM;
if (nodes::socket_type_has_attribute_toggle(type)) {
return true;
}
}
return false;
}
static void draw_output_attributes_panel(const bContext *C,
uiLayout *layout,
const NodesModifierData &nmd,
PointerRNA *ptr)
{
bool has_output_attribute = false;
if (nmd.node_group != nullptr && nmd.settings.properties != nullptr) {
for (const bNodeTreeInterfaceSocket *socket : nmd.node_group->interface_outputs()) {
const bNodeSocketType *typeinfo = socket->socket_typeinfo();
const eNodeSocketDatatype type = typeinfo ? eNodeSocketDatatype(typeinfo->type) :
SOCK_CUSTOM;
if (nodes::socket_type_has_attribute_toggle(type)) {
has_output_attribute = true;
draw_property_for_output_socket(*C, layout, nmd, ptr, *socket);
}
}
}
if (!has_output_attribute) {
uiItemL(layout, RPT_("No group output attributes connected"), ICON_INFO);
}
}
static void draw_internal_dependencies_panel(uiLayout *layout,
PointerRNA *ptr,
const NodesModifierData &nmd)
static void draw_bake_panel(uiLayout *layout, PointerRNA *modifier_ptr)
{
uiLayout *col = uiLayoutColumn(layout, false);
uiLayoutSetPropSep(col, true);
uiLayoutSetPropDecorate(col, false);
uiItemR(col, ptr, "bake_directory", UI_ITEM_NONE, IFACE_("Bake"), ICON_NONE);
uiItemR(col, modifier_ptr, "bake_directory", UI_ITEM_NONE, IFACE_("Bake Path"), ICON_NONE);
}
static void draw_named_attributes_panel(uiLayout *layout, NodesModifierData &nmd)
{
geo_log::GeoTreeLog *tree_log = get_root_tree_log(nmd);
if (tree_log == nullptr) {
return;
@@ -2026,6 +2037,23 @@ static void draw_internal_dependencies_panel(uiLayout *layout,
}
}
static void draw_manage_panel(const bContext *C,
uiLayout *layout,
PointerRNA *modifier_ptr,
NodesModifierData &nmd)
{
if (uiLayout *panel_layout = uiLayoutPanel(
C, layout, IFACE_("Bake"), modifier_ptr, "open_bake_panel"))
{
draw_bake_panel(panel_layout, modifier_ptr);
}
if (uiLayout *panel_layout = uiLayoutPanel(
C, layout, IFACE_("Named Attributes"), modifier_ptr, "open_named_attributes_panel"))
{
draw_named_attributes_panel(panel_layout, nmd);
}
}
static void panel_draw(const bContext *C, Panel *panel)
{
uiLayout *layout = panel->layout;
@@ -2069,15 +2097,17 @@ static void panel_draw(const bContext *C, Panel *panel)
modifier_panel_end(layout, ptr);
if (uiLayout *panel_layout = uiLayoutPanel(
C, layout, IFACE_("Output Attributes"), ptr, "open_output_attributes_panel"))
{
draw_output_attributes_panel(C, panel_layout, *nmd, ptr);
if (has_output_attribute(*nmd)) {
if (uiLayout *panel_layout = uiLayoutPanel(
C, layout, IFACE_("Output Attributes"), ptr, "open_output_attributes_panel"))
{
draw_output_attributes_panel(C, panel_layout, *nmd, ptr);
}
}
if (uiLayout *panel_layout = uiLayoutPanel(
C, layout, IFACE_("Internal Dependencies"), ptr, "open_internal_dependencies_panel"))
C, layout, IFACE_("Manage"), ptr, "open_manage_panel"))
{
draw_internal_dependencies_panel(panel_layout, ptr, *nmd);
draw_manage_panel(C, panel_layout, ptr, *nmd);
}
}