[Bf-blender-cvs] [d2004326a1f] master: Geometry Nodes: remove empty mesh component in distribute node output
Jacques Lucke
noreply at git.blender.org
Tue Sep 28 15:53:05 CEST 2021
Commit: d2004326a1f96f85cb1b6f7c57712de8998ecca0
Author: Jacques Lucke
Date: Tue Sep 28 15:52:04 2021 +0200
Branches: master
https://developer.blender.org/rBd2004326a1f96f85cb1b6f7c57712de8998ecca0
Geometry Nodes: remove empty mesh component in distribute node output
===================================================================
M source/blender/blenkernel/BKE_geometry_set.hh
M source/blender/blenkernel/intern/geometry_set.cc
M source/blender/nodes/geometry/nodes/node_geo_distribute_points_on_faces.cc
===================================================================
diff --git a/source/blender/blenkernel/BKE_geometry_set.hh b/source/blender/blenkernel/BKE_geometry_set.hh
index f6a58e57298..4954b1d5ab2 100644
--- a/source/blender/blenkernel/BKE_geometry_set.hh
+++ b/source/blender/blenkernel/BKE_geometry_set.hh
@@ -281,6 +281,8 @@ struct GeometrySet {
return this->remove(Component::static_type);
}
+ void keep_only(const blender::Span<GeometryComponentType> component_types);
+
void add(const GeometryComponent &component);
blender::Vector<const GeometryComponent *> get_components_for_read() const;
diff --git a/source/blender/blenkernel/intern/geometry_set.cc b/source/blender/blenkernel/intern/geometry_set.cc
index e8e2f64d6e1..400e0fda518 100644
--- a/source/blender/blenkernel/intern/geometry_set.cc
+++ b/source/blender/blenkernel/intern/geometry_set.cc
@@ -152,6 +152,19 @@ void GeometrySet::remove(const GeometryComponentType component_type)
components_.remove(component_type);
}
+/**
+ * Remove all geometry components with types that are not in the provided list.
+ */
+void GeometrySet::keep_only(const blender::Span<GeometryComponentType> component_types)
+{
+ for (auto it = components_.keys().begin(); it != components_.keys().end(); ++it) {
+ const GeometryComponentType type = *it;
+ if (!component_types.contains(type)) {
+ components_.remove(it);
+ }
+ }
+}
+
void GeometrySet::add(const GeometryComponent &component)
{
BLI_assert(!components_.contains(component.type()));
diff --git a/source/blender/nodes/geometry/nodes/node_geo_distribute_points_on_faces.cc b/source/blender/nodes/geometry/nodes/node_geo_distribute_points_on_faces.cc
index 3f2541dcded..f27544cbdda 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_distribute_points_on_faces.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_distribute_points_on_faces.cc
@@ -523,8 +523,6 @@ static void point_distribution_calculate(GeometrySet &geometry_set,
compute_attribute_outputs(
mesh_component, point_component, bary_coords, looptri_indices, attribute_outputs);
-
- geometry_set.replace_mesh(nullptr);
}
static void geo_node_point_distribute_points_on_faces_exec(GeoNodeExecParams params)
@@ -551,6 +549,9 @@ static void geo_node_point_distribute_points_on_faces_exec(GeoNodeExecParams par
geometry_set.modify_geometry_sets([&](GeometrySet &geometry_set) {
point_distribution_calculate(
geometry_set, selection_field, method, seed, attribute_outputs, params);
+ /* Keep instances because the original geometry set may contain instances that are processed as
+ * well. */
+ geometry_set.keep_only({GEO_COMPONENT_TYPE_POINT_CLOUD, GEO_COMPONENT_TYPE_INSTANCES});
});
params.set_output("Points", std::move(geometry_set));
More information about the Bf-blender-cvs
mailing list