Changeset View
Changeset View
Standalone View
Standalone View
source/blender/nodes/geometry/nodes/node_geo_point_separate.cc
| Context not available. | |||||
| static void geo_node_point_instance_declare(NodeDeclarationBuilder &b) | static void geo_node_point_instance_declare(NodeDeclarationBuilder &b) | ||||
| { | { | ||||
| b.add_input<decl::Geometry>("Geometry"); | b.add_input<decl::Geometry>("Geometry"); | ||||
| b.add_input<decl::String>("Mask"); | b.add_input<decl::Bool>("Mask").default_value(false).hide_value(); | ||||
| b.add_output<decl::Geometry>("Geometry 1"); | b.add_output<decl::Geometry>("Geometry 1"); | ||||
| b.add_output<decl::Geometry>("Geometry 2"); | b.add_output<decl::Geometry>("Geometry 2"); | ||||
| } | } | ||||
| Context not available. | |||||
| static void separate_points_from_component(const GeometryComponent &in_component, | static void separate_points_from_component(const GeometryComponent &in_component, | ||||
| GeometryComponent &out_component, | GeometryComponent &out_component, | ||||
| const StringRef mask_name, | Field<bool> selection_field, | ||||
| const bool invert) | const bool invert) | ||||
| { | { | ||||
| if (!in_component.attribute_domain_supported(ATTR_DOMAIN_POINT) || | if (!in_component.attribute_domain_supported(ATTR_DOMAIN_POINT) || | ||||
| Context not available. | |||||
| return; | return; | ||||
| } | } | ||||
| const GVArray_Typed<bool> mask_attribute = in_component.attribute_get_for_read<bool>( | GeometryComponentFieldContext field_context{in_component, ATTR_DOMAIN_POINT}; | ||||
| mask_name, ATTR_DOMAIN_POINT, false); | const int domain_size = in_component.attribute_domain_size(ATTR_DOMAIN_POINT); | ||||
| VArray_Span<bool> masks{mask_attribute}; | |||||
| fn::FieldEvaluator selection_evaluator{field_context, domain_size}; | |||||
| selection_evaluator.add(selection_field); | |||||
| selection_evaluator.evaluate(); | |||||
| VArray_Span<bool> masks{selection_evaluator.get_evaluated<bool>(0)}; | |||||
| const int total = masks.count(!invert); | const int total = masks.count(!invert); | ||||
| if (total == 0) { | if (total == 0) { | ||||
| Context not available. | |||||
| } | } | ||||
| create_component_points(out_component, total); | create_component_points(out_component, total); | ||||
| copy_point_attributes_based_on_mask(in_component, out_component, masks, invert); | copy_point_attributes_based_on_mask(in_component, out_component, masks, invert); | ||||
| } | } | ||||
| static GeometrySet separate_geometry_set(const GeometrySet &set_in, | static GeometrySet separate_geometry_set(const GeometrySet &set_in, | ||||
| const StringRef mask_name, | Field<bool> selection_field, | ||||
| const bool invert) | const bool invert) | ||||
| { | { | ||||
| GeometrySet set_out; | GeometrySet set_out; | ||||
| Context not available. | |||||
| continue; | continue; | ||||
| } | } | ||||
| GeometryComponent &out_component = set_out.get_component_for_write(component->type()); | GeometryComponent &out_component = set_out.get_component_for_write(component->type()); | ||||
| separate_points_from_component(*component, out_component, mask_name, invert); | separate_points_from_component(*component, out_component, selection_field, invert); | ||||
| } | } | ||||
| return set_out; | return set_out; | ||||
| } | } | ||||
| Context not available. | |||||
| if (wait_for_inputs) { | if (wait_for_inputs) { | ||||
| return; | return; | ||||
| } | } | ||||
| const std::string mask_attribute_name = params.get_input<std::string>("Mask"); | |||||
| GeometrySet geometry_set = params.get_input<GeometrySet>("Geometry"); | GeometrySet geometry_set = params.get_input<GeometrySet>("Geometry"); | ||||
| /* TODO: This is not necessary-- the input geometry set can be read only, | /* TODO: This is not necessary-- the input geometry set can be read only, | ||||
| * but it must be rewritten to handle instance groups. */ | * but it must be rewritten to handle instance groups. */ | ||||
| geometry_set = geometry_set_realize_instances(geometry_set); | geometry_set = geometry_set_realize_instances(geometry_set); | ||||
| Field<bool> selection_field = params.extract_input<Field<bool>>("Mask"); | |||||
| if (params.lazy_output_is_required("Geometry 1")) { | if (params.lazy_output_is_required("Geometry 1")) { | ||||
| params.set_output("Geometry 1", | params.set_output("Geometry 1", separate_geometry_set(geometry_set, selection_field, true)); | ||||
| separate_geometry_set(geometry_set, mask_attribute_name, true)); | |||||
| } | } | ||||
| if (params.lazy_output_is_required("Geometry 2")) { | if (params.lazy_output_is_required("Geometry 2")) { | ||||
| params.set_output("Geometry 2", | params.set_output("Geometry 2", separate_geometry_set(geometry_set, selection_field, false)); | ||||
| separate_geometry_set(geometry_set, mask_attribute_name, false)); | |||||
| } | } | ||||
| } | } | ||||
| Context not available. | |||||
| { | { | ||||
| static bNodeType ntype; | static bNodeType ntype; | ||||
| geo_node_type_base( | geo_node_type_base(&ntype, GEO_NODE_POINT_SEPARATE, "Point Separate", NODE_CLASS_GEOMETRY, 0); | ||||
| &ntype, GEO_NODE_LEGACY_POINT_SEPARATE, "Point Separate", NODE_CLASS_GEOMETRY, 0); | |||||
| ntype.declare = blender::nodes::geo_node_point_instance_declare; | ntype.declare = blender::nodes::geo_node_point_instance_declare; | ||||
| ntype.geometry_node_execute = blender::nodes::geo_node_point_separate_exec; | ntype.geometry_node_execute = blender::nodes::geo_node_point_separate_exec; | ||||
| ntype.geometry_node_execute_supports_laziness = true; | ntype.geometry_node_execute_supports_laziness = true; | ||||
| Context not available. | |||||