diff options
author | Jacques Lucke <jacques@blender.org> | 2021-02-19 14:29:37 +0300 |
---|---|---|
committer | Jacques Lucke <jacques@blender.org> | 2021-02-19 14:31:38 +0300 |
commit | 14f1d8962f6c8ab609daff3cca1702b35eee5b68 (patch) | |
tree | 9b4e8014a1919e929bc127dc6caf4e0cea89d51d /source/blender/blenkernel | |
parent | ed070dd51d4805f0af57acad02abf93ab80872a6 (diff) |
Geometry Nodes: add method to get all geometry components in a set
Previously, functions would have to ask for every geometry type explicitely.
Using a vector is return type is fine. In practice this will probably never
allocate because of the small buffer optimization in vector.
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r-- | source/blender/blenkernel/BKE_geometry_set.hh | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/geometry_set.cc | 12 |
2 files changed, 14 insertions, 0 deletions
diff --git a/source/blender/blenkernel/BKE_geometry_set.hh b/source/blender/blenkernel/BKE_geometry_set.hh index 02b3c88183a..5b1882d0d4c 100644 --- a/source/blender/blenkernel/BKE_geometry_set.hh +++ b/source/blender/blenkernel/BKE_geometry_set.hh @@ -308,6 +308,8 @@ struct GeometrySet { void add(const GeometryComponent &component); + blender::Vector<const GeometryComponent *> get_components_for_read() const; + void compute_boundbox_without_instances(blender::float3 *r_min, blender::float3 *r_max) const; friend std::ostream &operator<<(std::ostream &stream, const GeometrySet &geometry_set); diff --git a/source/blender/blenkernel/intern/geometry_set.cc b/source/blender/blenkernel/intern/geometry_set.cc index 74d8b9afd82..0274dfdbd1c 100644 --- a/source/blender/blenkernel/intern/geometry_set.cc +++ b/source/blender/blenkernel/intern/geometry_set.cc @@ -160,6 +160,18 @@ void GeometrySet::add(const GeometryComponent &component) components_.add_new(component.type(), std::move(component_ptr)); } +/** + * Get all geometry components in this geometry set for read-only access. + */ +Vector<const GeometryComponent *> GeometrySet::get_components_for_read() const +{ + Vector<const GeometryComponent *> components; + for (const GeometryComponentPtr &ptr : components_.values()) { + components.append(ptr.get()); + } + return components; +} + void GeometrySet::compute_boundbox_without_instances(float3 *r_min, float3 *r_max) const { const PointCloud *pointcloud = this->get_pointcloud_for_read(); |