diff options
author | Jacques Lucke <jacques@blender.org> | 2021-09-23 18:50:33 +0300 |
---|---|---|
committer | Jacques Lucke <jacques@blender.org> | 2021-09-23 18:59:44 +0300 |
commit | 38af29df5c307517dfdd0803b7e00d979be7185d (patch) | |
tree | 67ea679dda4bfd8255e050c24e7671d713084371 /source/blender/blenkernel/BKE_geometry_set.hh | |
parent | 105115da9f601c53d87cdc038f795f00f56a3495 (diff) |
Geometry Nodes: simplify looping over attributes in geometry set
This adds three new methods:
* `InstancesComponent::foreach_reference_as_geometry(...)`
* `GeometrySet::attribute_foreach(...)`
* `GeometrySet::gather_attributes_for_propagation(...)`
The goal is that these iteration primitives can be used in places
where we use more specialized iterators currently.
Differential Revision: https://developer.blender.org/D12613
Diffstat (limited to 'source/blender/blenkernel/BKE_geometry_set.hh')
-rw-r--r-- | source/blender/blenkernel/BKE_geometry_set.hh | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/source/blender/blenkernel/BKE_geometry_set.hh b/source/blender/blenkernel/BKE_geometry_set.hh index 317d513dae6..a6c77c74b9e 100644 --- a/source/blender/blenkernel/BKE_geometry_set.hh +++ b/source/blender/blenkernel/BKE_geometry_set.hh @@ -25,6 +25,7 @@ #include "BLI_float3.hh" #include "BLI_float4x4.hh" +#include "BLI_function_ref.hh" #include "BLI_hash.hh" #include "BLI_map.hh" #include "BLI_set.hh" @@ -293,6 +294,21 @@ struct GeometrySet { bool owns_direct_data() const; void ensure_owns_direct_data(); + using AttributeForeachCallback = + blender::FunctionRef<void(const blender::bke::AttributeIDRef &attribute_id, + const AttributeMetaData &meta_data, + const GeometryComponent &component)>; + + void attribute_foreach(blender::Span<GeometryComponentType> component_types, + bool include_instances, + AttributeForeachCallback callback) const; + + void gather_attributes_for_propagation( + blender::Span<GeometryComponentType> component_types, + GeometryComponentType dst_component_type, + bool include_instances, + blender::Map<blender::bke::AttributeIDRef, AttributeKind> &r_attributes) const; + /* Utility methods for creation. */ static GeometrySet create_with_mesh( Mesh *mesh, GeometryOwnershipType ownership = GeometryOwnershipType::Owned); @@ -597,6 +613,9 @@ class InstancesComponent : public GeometryComponent { int attribute_domain_size(const AttributeDomain domain) const final; + void foreach_referenced_geometry( + blender::FunctionRef<void(const GeometrySet &geometry_set)> callback) const; + bool is_empty() const final; bool owns_direct_data() const override; |