From 0bfae1b12078ef278a56c6e932c13be5bc9781aa Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Tue, 26 Oct 2021 20:00:03 +0200 Subject: Geometry Nodes: geometry component type warning system Previously, every node had to create warnings for unsupported input geometry manually. Now this is automated. Nodes just have to specify the geometry types they support in the node declaration. Differential Revision: https://developer.blender.org/D12899 --- source/blender/blenkernel/intern/geometry_set.cc | 34 ++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'source/blender/blenkernel/intern/geometry_set.cc') diff --git a/source/blender/blenkernel/intern/geometry_set.cc b/source/blender/blenkernel/intern/geometry_set.cc index 4753a9e0768..cd1bafe445a 100644 --- a/source/blender/blenkernel/intern/geometry_set.cc +++ b/source/blender/blenkernel/intern/geometry_set.cc @@ -527,6 +527,40 @@ void GeometrySet::gather_attributes_for_propagation( delete dummy_component; } +static void gather_component_types_recursive(const GeometrySet &geometry_set, + const bool include_instances, + const bool ignore_empty, + Vector &r_types) +{ + for (const GeometryComponent *component : geometry_set.get_components_for_read()) { + if (ignore_empty) { + if (component->is_empty()) { + continue; + } + } + r_types.append_non_duplicates(component->type()); + } + if (!include_instances) { + return; + } + const InstancesComponent *instances = geometry_set.get_component_for_read(); + if (instances == nullptr) { + return; + } + instances->foreach_referenced_geometry([&](const GeometrySet &instance_geometry_set) { + gather_component_types_recursive( + instance_geometry_set, include_instances, ignore_empty, r_types); + }); +} + +blender::Vector GeometrySet::gather_component_types( + const bool include_instances, bool ignore_empty) const +{ + Vector types; + gather_component_types_recursive(*this, include_instances, ignore_empty, types); + return types; +} + static void gather_mutable_geometry_sets(GeometrySet &geometry_set, Vector &r_geometry_sets) { -- cgit v1.2.3