Changeset View
Changeset View
Standalone View
Standalone View
source/blender/nodes/geometry/nodes/node_geo_separate_geometry.cc
| Show First 20 Lines • Show All 53 Lines • ▼ Show 20 Lines | |||||
| { | { | ||||
| GeometrySet geometry_set = params.extract_input<GeometrySet>("Geometry"); | GeometrySet geometry_set = params.extract_input<GeometrySet>("Geometry"); | ||||
| const Field<bool> selection_field = params.extract_input<Field<bool>>("Selection"); | const Field<bool> selection_field = params.extract_input<Field<bool>>("Selection"); | ||||
| const NodeGeometrySeparateGeometry &storage = node_storage(params.node()); | const NodeGeometrySeparateGeometry &storage = node_storage(params.node()); | ||||
| const AttributeDomain domain = static_cast<AttributeDomain>(storage.domain); | const AttributeDomain domain = static_cast<AttributeDomain>(storage.domain); | ||||
| bool all_is_error = false; | auto separate_geometry_maybe_recursively = [&](bool invert) { | ||||
| GeometrySet second_set(geometry_set); | bool is_error; | ||||
| if (params.output_is_required("Selection")) { | if (domain == ATTR_DOMAIN_INSTANCE) { | ||||
| geometry_set.modify_geometry_sets([&](GeometrySet &geometry_set) { | /* Only delete top level instances. */ | ||||
| bool this_is_error = false; | |||||
| separate_geometry(geometry_set, | separate_geometry(geometry_set, | ||||
| domain, | domain, | ||||
| GEO_NODE_DELETE_GEOMETRY_MODE_ALL, | GEO_NODE_DELETE_GEOMETRY_MODE_ALL, | ||||
| selection_field, | selection_field, | ||||
| false, | invert, | ||||
| this_is_error); | is_error); | ||||
| all_is_error &= this_is_error; | |||||
| }); | |||||
| params.set_output("Selection", std::move(geometry_set)); | |||||
| } | } | ||||
| if (params.output_is_required("Inverted")) { | else { | ||||
| second_set.modify_geometry_sets([&](GeometrySet &geometry_set) { | geometry_set.modify_geometry_sets([&](GeometrySet &geometry_set) { | ||||
| bool this_is_error = false; | |||||
| separate_geometry(geometry_set, | separate_geometry(geometry_set, | ||||
| domain, | domain, | ||||
| GEO_NODE_DELETE_GEOMETRY_MODE_ALL, | GEO_NODE_DELETE_GEOMETRY_MODE_ALL, | ||||
| selection_field, | selection_field, | ||||
| true, | invert, | ||||
| this_is_error); | is_error); | ||||
| all_is_error &= this_is_error; | |||||
| }); | }); | ||||
| params.set_output("Inverted", std::move(second_set)); | |||||
| } | } | ||||
| if (all_is_error) { | }; | ||||
| /* Only show this if none of the instances/components actually changed. */ | |||||
| params.error_message_add(NodeWarningType::Info, TIP_("No geometry with given domain")); | GeometrySet second_set(geometry_set); | ||||
| if (params.output_is_required("Selection")) { | |||||
| separate_geometry_maybe_recursively(false); | |||||
| params.set_output("Selection", std::move(geometry_set)); | |||||
| } | |||||
| if (params.output_is_required("Inverted")) { | |||||
| separate_geometry_maybe_recursively(true); | |||||
| params.set_output("Inverted", std::move(second_set)); | |||||
| } | } | ||||
| } | } | ||||
| } // namespace blender::nodes::node_geo_separate_geometry_cc | } // namespace blender::nodes::node_geo_separate_geometry_cc | ||||
| void register_node_type_geo_separate_geometry() | void register_node_type_geo_separate_geometry() | ||||
| { | { | ||||
| namespace file_ns = blender::nodes::node_geo_separate_geometry_cc; | namespace file_ns = blender::nodes::node_geo_separate_geometry_cc; | ||||
| Show All 17 Lines | |||||