WIP: Geometry Nodes: Viewer Node Group #112152
@ -25,33 +25,48 @@ def add_node_type(layout, node_type, *, label=None, poll=None):
|
||||
return props
|
||||
|
||||
|
||||
def draw_node_group_add_menu(context, layout):
|
||||
"""Add items to the layout used for interacting with node groups."""
|
||||
def node_groups(context):
|
||||
"""All node groups allowed in current context."""
|
||||
space_node = context.space_data
|
||||
node_tree = space_node.edit_tree
|
||||
all_node_groups = context.blend_data.node_groups
|
||||
if node_tree is None:
|
||||
return None
|
||||
|
||||
def group_allowed_in_context(group):
|
||||
if group.bl_idname is node_tree.bl_idname:
|
||||
return False
|
||||
if group.name.startswith('.'):
|
||||
return False
|
||||
if group.contains_tree(node_tree):
|
||||
return False
|
||||
return True
|
||||
|
||||
return [group for group in all_node_groups if group_allowed_in_context(group)]
|
||||
|
||||
|
||||
def draw_node_group_add_menu(context, layout, groups = None):
|
||||
"""Add items to the layout used for interacting with node groups."""
|
||||
space_node = context.space_data
|
||||
node_tree = space_node.edit_tree
|
||||
if groups is None:
|
||||
groups = node_groups(context)
|
||||
|
||||
all_node_groups = context.blend_data.node_groups
|
||||
if node_tree in all_node_groups.values():
|
||||
layout.separator()
|
||||
add_node_type(layout, "NodeGroupInput")
|
||||
add_node_type(layout, "NodeGroupOutput")
|
||||
|
||||
if node_tree:
|
||||
if node_tree and groups:
|
||||
from nodeitems_builtins import node_tree_group_type
|
||||
|
||||
groups = [
|
||||
group for group in context.blend_data.node_groups
|
||||
if (group.bl_idname == node_tree.bl_idname and
|
||||
not group.contains_tree(node_tree) and
|
||||
not group.name.startswith('.'))
|
||||
]
|
||||
if groups:
|
||||
layout.separator()
|
||||
for group in groups:
|
||||
props = add_node_type(layout, node_tree_group_type[group.bl_idname], label=group.name)
|
||||
ops = props.settings.add()
|
||||
ops.name = "node_tree"
|
||||
ops.value = "bpy.data.node_groups[%r]" % group.name
|
||||
layout.separator()
|
||||
for group in groups:
|
||||
props = add_node_type(layout, node_tree_group_type[group.bl_idname], label=group.name)
|
||||
ops = props.settings.add()
|
||||
ops.name = "node_tree"
|
||||
ops.value = "bpy.data.node_groups[%r]" % group.name
|
||||
|
||||
|
||||
def draw_assets_for_catalog(layout, catalog_path):
|
||||
|
@ -453,10 +453,13 @@ class NODE_MT_category_GEO_OUTPUT(Menu):
|
||||
bl_idname = "NODE_MT_category_GEO_OUTPUT"
|
||||
bl_label = "Output"
|
||||
|
||||
def draw(self, _context):
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
node_add_menu.add_node_type(layout, "NodeGroupOutput")
|
||||
node_add_menu.add_node_type(layout, "GeometryNodeViewer")
|
||||
groups = node_add_menu.node_groups(context)
|
||||
groups = [group for group in groups if group.is_viewer]
|
||||
node_add_menu.draw_node_group_add_menu(context, layout, groups)
|
||||
node_add_menu.draw_assets_for_catalog(layout, self.bl_label)
|
||||
|
||||
|
||||
|
@ -3323,6 +3323,8 @@ static StructRNA *rna_viewer_path_elem_refine(PointerRNA *ptr)
|
||||
return &RNA_ModifierViewerPathElem;
|
||||
case VIEWER_PATH_ELEM_TYPE_GROUP_NODE:
|
||||
return &RNA_GroupNodeViewerPathElem;
|
||||
case VIEWER_PATH_ELEM_TYPE_VIEWER_NODE_GROUP:
|
||||
return &RNA_ViewerNodeGroupViewerPathElem;
|
||||
case VIEWER_PATH_ELEM_TYPE_SIMULATION_ZONE:
|
||||
return &RNA_SimulationZoneViewerPathElem;
|
||||
case VIEWER_PATH_ELEM_TYPE_VIEWER_NODE:
|
||||
@ -8073,6 +8075,11 @@ static const EnumPropertyItem viewer_path_elem_type_items[] = {
|
||||
{VIEWER_PATH_ELEM_TYPE_SIMULATION_ZONE, "SIMULATION_ZONE", ICON_NONE, "Simulation Zone", ""},
|
||||
{VIEWER_PATH_ELEM_TYPE_VIEWER_NODE, "VIEWER_NODE", ICON_NONE, "Viewer Node", ""},
|
||||
{VIEWER_PATH_ELEM_TYPE_REPEAT_ZONE, "REPEAT_ZONE", ICON_NONE, "Repeat", ""},
|
||||
{VIEWER_PATH_ELEM_TYPE_VIEWER_NODE_GROUP,
|
||||
"VIEWER_NODE_GROUP",
|
||||
ICON_NONE,
|
||||
"Viewer Node Group",
|
||||
""},
|
||||
{0, nullptr, 0, nullptr, nullptr},
|
||||
};
|
||||
|
||||
@ -8162,6 +8169,17 @@ static void rna_def_viewer_node_viewer_path_elem(BlenderRNA *brna)
|
||||
RNA_def_property_ui_text(prop, "Node ID", "");
|
||||
}
|
||||
|
||||
static void rna_def_viewer_node_group_viewer_path_elem(BlenderRNA *brna)
|
||||
{
|
||||
StructRNA *srna;
|
||||
PropertyRNA *prop;
|
||||
|
||||
srna = RNA_def_struct(brna, "ViewerNodeGroupViewerPathElem", "ViewerPathElem");
|
||||
|
||||
prop = RNA_def_property(srna, "node_id", PROP_INT, PROP_NONE);
|
||||
RNA_def_property_ui_text(prop, "Node ID", "");
|
||||
}
|
||||
|
||||
static void rna_def_viewer_path(BlenderRNA *brna)
|
||||
{
|
||||
StructRNA *srna;
|
||||
@ -8174,6 +8192,7 @@ static void rna_def_viewer_path(BlenderRNA *brna)
|
||||
rna_def_simulation_zone_viewer_path_elem(brna);
|
||||
rna_def_repeat_zone_viewer_path_elem(brna);
|
||||
rna_def_viewer_node_viewer_path_elem(brna);
|
||||
rna_def_viewer_node_group_viewer_path_elem(brna);
|
||||
|
||||
srna = RNA_def_struct(brna, "ViewerPath", nullptr);
|
||||
RNA_def_struct_ui_text(srna, "Viewer Path", "Path to data that is viewed");
|
||||
|
@ -725,7 +725,6 @@ const ViewerNodeLog *GeoModifierLog::find_viewer_node_log_for_path(const ViewerP
|
||||
|
||||
iter_node_tree = iter_node_tree = reinterpret_cast<const bNodeTree *>(viewer_node->id);
|
||||
while (const bNode *viewer = lookup_viewer(*iter_node_tree)) {
|
||||
std::cout << "Step\n";
|
||||
const bke::bNodeTreeZones *tree_zones = iter_node_tree->zones();
|
||||
if (tree_zones == nullptr) {
|
||||
return nullptr;
|
||||
|
Loading…
Reference in New Issue
Block a user