[Bf-blender-cvs] [05b685989b5] master: Fix T88732: Curve to mesh node crash with empty input curve

Hans Goudey noreply at git.blender.org
Wed Jun 2 17:11:39 CEST 2021


Commit: 05b685989b5288bcfdc5bd4ae5c387a1da4dd58e
Author: Hans Goudey
Date:   Wed Jun 2 11:11:34 2021 -0400
Branches: master
https://developer.blender.org/rB05b685989b5288bcfdc5bd4ae5c387a1da4dd58e

Fix T88732: Curve to mesh node crash with empty input curve

The mesh to curve node generated an empty curve because no edges were
selected. This commit changes that node to not add a curve in that case.

This also changes the curve to mesh node to not add a material when
no mesh was created. Even though we don't expect null curves or meshes
in this case, the change is harmless.

===================================================================

M	source/blender/nodes/geometry/nodes/node_geo_curve_to_mesh.cc
M	source/blender/nodes/geometry/nodes/node_geo_mesh_to_curve.cc

===================================================================

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 8979949736c..fe1b23bf6d7 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
@@ -237,6 +237,7 @@ static Mesh *curve_to_mesh_calculate(const CurveEval &curve, const CurveEval &pr
   }
 
   Mesh *mesh = BKE_mesh_new_nomain(vert_total, edge_total, 0, corner_total, poly_total);
+  BKE_id_material_eval_ensure_default_slot(&mesh->id);
   MutableSpan<MVert> verts{mesh->mvert, mesh->totvert};
   MutableSpan<MEdge> edges{mesh->medge, mesh->totedge};
   MutableSpan<MLoop> loops{mesh->mloop, mesh->totloop};
@@ -297,7 +298,6 @@ static void geo_node_curve_to_mesh_exec(GeoNodeExecParams params)
 
   Mesh *mesh = curve_to_mesh_calculate(*curve_set.get_curve_for_read(),
                                        (profile_curve == nullptr) ? vert_curve : *profile_curve);
-  BKE_id_material_eval_ensure_default_slot(&mesh->id);
   params.set_output("Mesh", GeometrySet::create_with_mesh(mesh));
 }
 
diff --git a/source/blender/nodes/geometry/nodes/node_geo_mesh_to_curve.cc b/source/blender/nodes/geometry/nodes/node_geo_mesh_to_curve.cc
index b852f929b5f..0fb7910c904 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_mesh_to_curve.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_mesh_to_curve.cc
@@ -291,14 +291,12 @@ static void geo_node_mesh_to_curve_exec(GeoNodeExecParams params)
   const MeshComponent &component = *geometry_set.get_component_for_read<MeshComponent>();
   const Mesh &mesh = *component.get_for_read();
   Span<MVert> verts = Span{mesh.mvert, mesh.totvert};
-  Span<MEdge> edges = Span{mesh.medge, mesh.totedge};
-  if (edges.size() == 0) {
+  Vector<std::pair<int, int>> selected_edges = get_selected_edges(params, component);
+  if (selected_edges.size() == 0) {
     params.set_output("Curve", GeometrySet());
     return;
   }
 
-  Vector<std::pair<int, int>> selected_edges = get_selected_edges(params, component);
-
   CurveFromEdgesOutput output = mesh_to_curve(verts, selected_edges);
   copy_attributes_to_points(*output.curve, component, output.point_to_vert_maps);



More information about the Bf-blender-cvs mailing list