[Bf-blender-cvs] [894e8b18e42] master: Geometry Nodes: Don't create empty components when realizing instances
Hans Goudey
noreply at git.blender.org
Thu Mar 18 21:33:10 CET 2021
Commit: 894e8b18e4266d1784cc98a20ab72dbd9c76e1cc
Author: Hans Goudey
Date: Thu Mar 18 16:32:49 2021 -0400
Branches: master
https://developer.blender.org/rB894e8b18e4266d1784cc98a20ab72dbd9c76e1cc
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.
===================================================================
M source/blender/blenkernel/intern/geometry_set_instances.cc
===================================================================
diff --git a/source/blender/blenkernel/intern/geometry_set_instances.cc b/source/blender/blenkernel/intern/geometry_set_instances.cc
index ce54ec7911f..24a402ac545 100644
--- a/source/blender/blenkernel/intern/geometry_set_instances.cc
+++ b/source/blender/blenkernel/intern/geometry_set_instances.cc
@@ -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);
More information about the Bf-blender-cvs
mailing list