Changeset View
Changeset View
Standalone View
Standalone View
source/blender/nodes/geometry/nodes/node_geo_separate_geometry.cc
| Show All 9 Lines | |||||
| NODE_STORAGE_FUNCS(NodeGeometrySeparateGeometry) | NODE_STORAGE_FUNCS(NodeGeometrySeparateGeometry) | ||||
| static void node_declare(NodeDeclarationBuilder &b) | static void node_declare(NodeDeclarationBuilder &b) | ||||
| { | { | ||||
| b.add_input<decl::Geometry>(N_("Geometry")); | b.add_input<decl::Geometry>(N_("Geometry")); | ||||
| b.add_input<decl::Bool>(N_("Selection")) | b.add_input<decl::Bool>(N_("Selection")) | ||||
| .default_value(true) | .default_value(true) | ||||
| .hide_value() | .hide_value() | ||||
| .supports_field() | .field_on_auto() | ||||
| .description(N_("The parts of the geometry that go into the first output")); | .description(N_("The parts of the geometry that go into the first output")); | ||||
| b.add_output<decl::Geometry>(N_("Selection")) | b.add_output<decl::Geometry>(N_("Selection")) | ||||
| .propagate_from_auto() | |||||
| .description(N_("The parts of the geometry in the selection")); | .description(N_("The parts of the geometry in the selection")); | ||||
| b.add_output<decl::Geometry>(N_("Inverted")) | b.add_output<decl::Geometry>(N_("Inverted")) | ||||
| .propagate_from_auto() | |||||
| .description(N_("The parts of the geometry not in the selection")); | .description(N_("The parts of the geometry not in the selection")); | ||||
| } | } | ||||
| static void node_layout(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr) | static void node_layout(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr) | ||||
| { | { | ||||
| uiItemR(layout, ptr, "domain", 0, "", ICON_NONE); | uiItemR(layout, ptr, "domain", 0, "", ICON_NONE); | ||||
| } | } | ||||
| Show All 9 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 eAttrDomain domain = eAttrDomain(storage.domain); | const eAttrDomain domain = eAttrDomain(storage.domain); | ||||
| auto separate_geometry_maybe_recursively = [&](GeometrySet &geometry_set, | auto separate_geometry_maybe_recursively = | ||||
| const Field<bool> &selection) { | [&](GeometrySet &geometry_set, | ||||
| const Field<bool> &selection, | |||||
| const AnonymousAttributePropagationInfo &propagation_info) { | |||||
| bool is_error; | bool is_error; | ||||
| if (domain == ATTR_DOMAIN_INSTANCE) { | if (domain == ATTR_DOMAIN_INSTANCE) { | ||||
| /* Only delete top level instances. */ | /* Only delete top level instances. */ | ||||
| separate_geometry( | separate_geometry(geometry_set, | ||||
| geometry_set, domain, GEO_NODE_DELETE_GEOMETRY_MODE_ALL, selection, is_error); | domain, | ||||
| GEO_NODE_DELETE_GEOMETRY_MODE_ALL, | |||||
| selection, | |||||
| propagation_info, | |||||
| is_error); | |||||
| } | } | ||||
| else { | else { | ||||
| geometry_set.modify_geometry_sets([&](GeometrySet &geometry_set) { | geometry_set.modify_geometry_sets([&](GeometrySet &geometry_set) { | ||||
| separate_geometry( | separate_geometry(geometry_set, | ||||
| geometry_set, domain, GEO_NODE_DELETE_GEOMETRY_MODE_ALL, selection, is_error); | domain, | ||||
| GEO_NODE_DELETE_GEOMETRY_MODE_ALL, | |||||
| selection, | |||||
| propagation_info, | |||||
| is_error); | |||||
| }); | }); | ||||
| } | } | ||||
| }; | }; | ||||
| GeometrySet second_set(geometry_set); | GeometrySet second_set(geometry_set); | ||||
| if (params.output_is_required("Selection")) { | if (params.output_is_required("Selection")) { | ||||
| separate_geometry_maybe_recursively(geometry_set, selection_field); | separate_geometry_maybe_recursively( | ||||
| geometry_set, selection_field, params.get_output_propagation_info("Selection")); | |||||
| params.set_output("Selection", std::move(geometry_set)); | params.set_output("Selection", std::move(geometry_set)); | ||||
| } | } | ||||
| if (params.output_is_required("Inverted")) { | if (params.output_is_required("Inverted")) { | ||||
| separate_geometry_maybe_recursively(second_set, fn::invert_boolean_field(selection_field)); | separate_geometry_maybe_recursively(second_set, | ||||
| fn::invert_boolean_field(selection_field), | |||||
| params.get_output_propagation_info("Inverted")); | |||||
| params.set_output("Inverted", std::move(second_set)); | 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() | ||||
| { | { | ||||
| Show All 18 Lines | |||||