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:
authorJacques Lucke <jacques@blender.org>2021-09-28 16:52:04 +0300
committerJacques Lucke <jacques@blender.org>2021-09-28 16:52:31 +0300
commitd2004326a1f96f85cb1b6f7c57712de8998ecca0 (patch)
tree777d4a0183281111f301c4ae08f97fe934203009 /source/blender/blenkernel
parent3e78c9e5bb179e84d542bc698fc6f6d7c111d1e1 (diff)
Geometry Nodes: remove empty mesh component in distribute node output
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r--source/blender/blenkernel/BKE_geometry_set.hh2
-rw-r--r--source/blender/blenkernel/intern/geometry_set.cc13
2 files changed, 15 insertions, 0 deletions
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()));