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-03-18 23:32:49 +0300
committerHans Goudey <h.goudey@me.com>2021-03-18 23:32:49 +0300
commit894e8b18e4266d1784cc98a20ab72dbd9c76e1cc (patch)
treefe36656fddfefef2d7fc748dbe2ed1d69d3264cf /source/blender
parentb1150fa1f5a5d5fa500d26c4b466e3f03fc30feb (diff)
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.
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/blenkernel/intern/geometry_set_instances.cc11
1 files changed, 11 insertions, 0 deletions
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);