Fix T95532: Merge node deletes everything for empty selections

The problem was that nullptr was returned which is a valid value for
Mesh * and hence the returned optional was treated as having some value.
There was no check for point clouds so that was fixed as well.

Differential Revision: https://developer.blender.org/D14026
This commit is contained in:
Wannes Malfait 2022-02-07 16:08:36 -06:00 committed by Hans Goudey
parent 11d785edea
commit 229d0ace02
Notes: blender-bot 2023-02-14 08:24:03 +01:00
Referenced by issue #95532, merge by distance node deletes everything when selection is all false
1 changed files with 4 additions and 2 deletions

View File

@ -60,7 +60,7 @@ static std::optional<Mesh *> mesh_merge_by_distance(const MeshComponent &mesh_co
const IndexMask selection = evaluator.get_evaluated_as_mask(0);
if (selection.is_empty()) {
return nullptr;
return std::nullopt;
}
const Mesh &mesh = *mesh_component.get_for_read();
@ -78,7 +78,9 @@ static void node_geo_exec(GeoNodeExecParams params)
if (geometry_set.has_pointcloud()) {
PointCloud *result = pointcloud_merge_by_distance(
*geometry_set.get_component_for_read<PointCloudComponent>(), merge_distance, selection);
geometry_set.replace_pointcloud(result);
if (result) {
geometry_set.replace_pointcloud(result);
}
}
if (geometry_set.has_mesh()) {
std::optional<Mesh *> result = mesh_merge_by_distance(