Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans Goudey <h.goudey@me.com>2021-06-02 18:11:34 +0300
committerHans Goudey <h.goudey@me.com>2021-06-02 18:11:34 +0300
commit05b685989b5288bcfdc5bd4ae5c387a1da4dd58e (patch)
tree5c4acf8939b8202cfe6c259053b4b792906f6405 /source/blender/nodes
parent7654203cc8b6b81013eeef558d6d15a9344fb9d1 (diff)
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.
Diffstat (limited to 'source/blender/nodes')
-rw-r--r--source/blender/nodes/geometry/nodes/node_geo_curve_to_mesh.cc2
-rw-r--r--source/blender/nodes/geometry/nodes/node_geo_mesh_to_curve.cc6
2 files changed, 3 insertions, 5 deletions
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);