diff options
author | Jacques Lucke <jacques@blender.org> | 2021-09-27 18:35:26 +0300 |
---|---|---|
committer | Jacques Lucke <jacques@blender.org> | 2021-09-27 18:35:45 +0300 |
commit | 0559971ab3772e3b5efb0fcad396735ea4ac22fe (patch) | |
tree | e373f64625d71d643e03f28a1383ee7c9b276d42 /source/blender/blenkernel/BKE_geometry_set.hh | |
parent | 2189dfd6e25a7bb6b734116619d87bc2d2a535ff (diff) |
Geometry Nodes: add utility to process all instances separately
This adds a new `GeometrySet::modify_geometry_sets` method that can be
used to update each sub-geometry-set separately without making any
instances real.
Differential Revision: https://developer.blender.org/D12650
Diffstat (limited to 'source/blender/blenkernel/BKE_geometry_set.hh')
-rw-r--r-- | source/blender/blenkernel/BKE_geometry_set.hh | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/source/blender/blenkernel/BKE_geometry_set.hh b/source/blender/blenkernel/BKE_geometry_set.hh index 571c6c6a0a0..08bfdbf2382 100644 --- a/source/blender/blenkernel/BKE_geometry_set.hh +++ b/source/blender/blenkernel/BKE_geometry_set.hh @@ -309,6 +309,10 @@ struct GeometrySet { bool include_instances, blender::Map<blender::bke::AttributeIDRef, AttributeKind> &r_attributes) const; + using ForeachSubGeometryCallback = blender::FunctionRef<void(GeometrySet &geometry_set)>; + + void modify_geometry_sets(ForeachSubGeometryCallback callback); + /* Utility methods for creation. */ static GeometrySet create_with_mesh( Mesh *mesh, GeometryOwnershipType ownership = GeometryOwnershipType::Owned); @@ -479,7 +483,7 @@ class InstanceReference { Type type_ = Type::None; /** Depending on the type this is either null, an Object or Collection pointer. */ void *data_ = nullptr; - std::shared_ptr<GeometrySet> geometry_set_; + std::unique_ptr<GeometrySet> geometry_set_; public: InstanceReference() = default; @@ -494,8 +498,25 @@ class InstanceReference { InstanceReference(GeometrySet geometry_set) : type_(Type::GeometrySet), - geometry_set_(std::make_shared<GeometrySet>(std::move(geometry_set))) + geometry_set_(std::make_unique<GeometrySet>(std::move(geometry_set))) + { + } + + InstanceReference(const InstanceReference &other) : type_(other.type_), data_(other.data_) { + if (other.geometry_set_) { + geometry_set_ = std::make_unique<GeometrySet>(*other.geometry_set_); + } + } + + InstanceReference &operator=(const InstanceReference &other) + { + if (this == &other) { + return *this; + } + this->~InstanceReference(); + new (this) InstanceReference(other); + return *this; } Type type() const |