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.
This commit is contained in:
Jacques Lucke 2021-02-19 12:29:37 +01:00
parent ed070dd51d
commit 14f1d8962f
2 changed files with 14 additions and 0 deletions

View File

@ -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);

View File

@ -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();