Geometry Nodes: add utility to ensure that no geometry components are shared

This commit is contained in:
Jacques Lucke
2025-03-27 20:27:50 +01:00
parent 695acd83a6
commit 94edc7e77a
2 changed files with 16 additions and 0 deletions

View File

@@ -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,

View File

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