Geometry Nodes: add utility to ensure that no geometry components are shared
This commit is contained in:
@@ -245,6 +245,13 @@ struct GeometrySet {
|
||||
* instances so that they can be owned.
|
||||
*/
|
||||
void ensure_owns_all_data();
|
||||
/**
|
||||
* Typically, multiple #GeometrySet may share the same #GeometryComponent. This is fine as long
|
||||
* as we can guarantee that the data is read-only. However, if some geometry is available in
|
||||
* Python, that guarantee is not possible currently. For that case it can make sense that the
|
||||
* #GeometrySet is the unique owner of the geometries it contains.
|
||||
*/
|
||||
void ensure_no_shared_components();
|
||||
|
||||
using AttributeForeachCallback = FunctionRef<void(StringRef attribute_id,
|
||||
const AttributeMetaData &meta_data,
|
||||
|
||||
@@ -296,6 +296,15 @@ bool GeometrySet::owns_direct_data() const
|
||||
return true;
|
||||
}
|
||||
|
||||
void GeometrySet::ensure_no_shared_components()
|
||||
{
|
||||
for (const int i : IndexRange(this->components_.size())) {
|
||||
if (components_[i]) {
|
||||
this->get_component_for_write(GeometryComponent::Type(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const Mesh *GeometrySet::get_mesh() const
|
||||
{
|
||||
const MeshComponent *component = this->get_component<MeshComponent>();
|
||||
|
||||
Reference in New Issue
Block a user