Geometry Nodes: Don't create empty components when realizing instances
Previously even if the input goemetry set had no point cloud or no mesh instances, `geometry_set_realize_instances` would create empty data. This isn't necessarily bad, but it can complicate things down the line if there are a bunch of empty components getting passed around.
This commit is contained in:
parent
b1150fa1f5
commit
894e8b18e4
|
@ -230,6 +230,11 @@ static Mesh *join_mesh_topology_and_builtin_attributes(Span<GeometryInstanceGrou
|
|||
}
|
||||
}
|
||||
|
||||
/* Don't create an empty mesh. */
|
||||
if ((totverts + totloops + totedges + totpolys) == 0) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Mesh *new_mesh = BKE_mesh_new_nomain(totverts, totedges, 0, totloops, totpolys);
|
||||
/* Copy settings from the first input geometry set with a mesh. */
|
||||
for (const GeometryInstanceGroup &set_group : set_groups) {
|
||||
|
@ -366,6 +371,9 @@ static void join_instance_groups_mesh(Span<GeometryInstanceGroup> set_groups,
|
|||
{
|
||||
Mesh *new_mesh = join_mesh_topology_and_builtin_attributes(set_groups,
|
||||
convert_points_to_vertices);
|
||||
if (new_mesh == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
MeshComponent &dst_component = result.get_component_for_write<MeshComponent>();
|
||||
dst_component.replace(new_mesh);
|
||||
|
@ -397,6 +405,9 @@ static void join_instance_groups_pointcloud(Span<GeometryInstanceGroup> set_grou
|
|||
totpoint += component.attribute_domain_size(ATTR_DOMAIN_POINT);
|
||||
}
|
||||
}
|
||||
if (totpoint == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
PointCloudComponent &dst_component = result.get_component_for_write<PointCloudComponent>();
|
||||
PointCloud *pointcloud = BKE_pointcloud_new_nomain(totpoint);
|
||||
|
|
Loading…
Reference in New Issue