From bc2f4dd8b408eee35353c18a44ce0dc5b51394a9 Mon Sep 17 00:00:00 2001 From: Hans Goudey Date: Mon, 25 Oct 2021 09:10:44 -0500 Subject: Geometry Nodes: Add "Fill Caps" option to curve to mesh node This adds an option to fill the ends of the generated mesh for each spline combination with an N-gon. The resulting mesh is manifold, so it can be used for operations like Boolean. Differential Revision: https://developer.blender.org/D12982 --- .../nodes/geometry/nodes/node_geo_curve_to_mesh.cc | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'source/blender/nodes') diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_to_mesh.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_to_mesh.cc index 00451946af9..be755c7269e 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_to_mesh.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_to_mesh.cc @@ -29,19 +29,25 @@ static void geo_node_curve_to_mesh_declare(NodeDeclarationBuilder &b) { b.add_input("Curve"); b.add_input("Profile Curve"); + b.add_input("Fill Caps") + .description( + "If the profile spline is cyclic, fill the ends of the generated mesh with N-gons"); b.add_output("Mesh"); } -static void geometry_set_curve_to_mesh(GeometrySet &geometry_set, const GeometrySet &profile_set) +static void geometry_set_curve_to_mesh(GeometrySet &geometry_set, + const GeometrySet &profile_set, + const bool fill_caps) { + const CurveEval *curve = geometry_set.get_curve_for_read(); const CurveEval *profile_curve = profile_set.get_curve_for_read(); if (profile_curve == nullptr) { - Mesh *mesh = bke::curve_to_wire_mesh(*geometry_set.get_curve_for_read()); + Mesh *mesh = bke::curve_to_wire_mesh(*curve); geometry_set.replace_mesh(mesh); } else { - Mesh *mesh = bke::curve_to_mesh_sweep(*geometry_set.get_curve_for_read(), *profile_curve); + Mesh *mesh = bke::curve_to_mesh_sweep(*curve, *profile_curve, fill_caps); geometry_set.replace_mesh(mesh); } } @@ -50,6 +56,7 @@ static void geo_node_curve_to_mesh_exec(GeoNodeExecParams params) { GeometrySet curve_set = params.extract_input("Curve"); GeometrySet profile_set = params.extract_input("Profile Curve"); + const bool fill_caps = params.extract_input("Fill Caps"); if (profile_set.has_instances()) { params.error_message_add(NodeWarningType::Error, @@ -67,7 +74,7 @@ static void geo_node_curve_to_mesh_exec(GeoNodeExecParams params) curve_set.modify_geometry_sets([&](GeometrySet &geometry_set) { if (geometry_set.has_curve()) { has_curve = true; - geometry_set_curve_to_mesh(geometry_set, profile_set); + geometry_set_curve_to_mesh(geometry_set, profile_set, fill_caps); } geometry_set.keep_only({GEO_COMPONENT_TYPE_MESH, GEO_COMPONENT_TYPE_INSTANCES}); }); -- cgit v1.2.3