Changeset View
Changeset View
Standalone View
Standalone View
source/blender/nodes/geometry/nodes/node_geo_points_to_vertices.cc
| Show All 19 Lines | |||||
| #include "BKE_mesh.h" | #include "BKE_mesh.h" | ||||
| #include "node_geometry_util.hh" | #include "node_geometry_util.hh" | ||||
| namespace blender::nodes::node_geo_points_to_vertices_cc { | namespace blender::nodes::node_geo_points_to_vertices_cc { | ||||
| using blender::Array; | using blender::Array; | ||||
| static void geo_node_points_to_vertices_declare(NodeDeclarationBuilder &b) | static void node_declare(NodeDeclarationBuilder &b) | ||||
| { | { | ||||
| b.add_input<decl::Geometry>(N_("Points")).supported_type(GEO_COMPONENT_TYPE_POINT_CLOUD); | b.add_input<decl::Geometry>(N_("Points")).supported_type(GEO_COMPONENT_TYPE_POINT_CLOUD); | ||||
| b.add_input<decl::Bool>(N_("Selection")).default_value(true).supports_field().hide_value(); | b.add_input<decl::Bool>(N_("Selection")).default_value(true).supports_field().hide_value(); | ||||
| b.add_output<decl::Geometry>(N_("Mesh")); | b.add_output<decl::Geometry>(N_("Mesh")); | ||||
| } | } | ||||
| template<typename T> | template<typename T> | ||||
| static void copy_attribute_to_vertices(const Span<T> src, const IndexMask mask, MutableSpan<T> dst) | static void copy_attribute_to_vertices(const Span<T> src, const IndexMask mask, MutableSpan<T> dst) | ||||
| ▲ Show 20 Lines • Show All 50 Lines • ▼ Show 20 Lines | if (dst && src) { | ||||
| }); | }); | ||||
| dst.save(); | dst.save(); | ||||
| } | } | ||||
| } | } | ||||
| geometry_set.keep_only({GEO_COMPONENT_TYPE_MESH, GEO_COMPONENT_TYPE_INSTANCES}); | geometry_set.keep_only({GEO_COMPONENT_TYPE_MESH, GEO_COMPONENT_TYPE_INSTANCES}); | ||||
| } | } | ||||
| static void geo_node_points_to_vertices_exec(GeoNodeExecParams params) | static void node_geo_exec(GeoNodeExecParams params) | ||||
| { | { | ||||
| GeometrySet geometry_set = params.extract_input<GeometrySet>("Points"); | GeometrySet geometry_set = params.extract_input<GeometrySet>("Points"); | ||||
| Field<bool> selection_field = params.extract_input<Field<bool>>("Selection"); | Field<bool> selection_field = params.extract_input<Field<bool>>("Selection"); | ||||
| geometry_set.modify_geometry_sets([&](GeometrySet &geometry_set) { | geometry_set.modify_geometry_sets([&](GeometrySet &geometry_set) { | ||||
| geometry_set_points_to_vertices(geometry_set, selection_field); | geometry_set_points_to_vertices(geometry_set, selection_field); | ||||
| }); | }); | ||||
| params.set_output("Mesh", std::move(geometry_set)); | params.set_output("Mesh", std::move(geometry_set)); | ||||
| } | } | ||||
| } // namespace blender::nodes::node_geo_points_to_vertices_cc | } // namespace blender::nodes::node_geo_points_to_vertices_cc | ||||
| void register_node_type_geo_points_to_vertices() | void register_node_type_geo_points_to_vertices() | ||||
| { | { | ||||
| namespace file_ns = blender::nodes::node_geo_points_to_vertices_cc; | namespace file_ns = blender::nodes::node_geo_points_to_vertices_cc; | ||||
| static bNodeType ntype; | static bNodeType ntype; | ||||
| geo_node_type_base( | geo_node_type_base( | ||||
| &ntype, GEO_NODE_POINTS_TO_VERTICES, "Points to Vertices", NODE_CLASS_GEOMETRY, 0); | &ntype, GEO_NODE_POINTS_TO_VERTICES, "Points to Vertices", NODE_CLASS_GEOMETRY, 0); | ||||
| ntype.declare = file_ns::geo_node_points_to_vertices_declare; | ntype.declare = file_ns::node_declare; | ||||
| ntype.geometry_node_execute = file_ns::geo_node_points_to_vertices_exec; | ntype.geometry_node_execute = file_ns::node_geo_exec; | ||||
| nodeRegisterType(&ntype); | nodeRegisterType(&ntype); | ||||
| } | } | ||||