diff options
author | Jacques Lucke <jacques@blender.org> | 2021-10-29 10:28:31 +0300 |
---|---|---|
committer | Jacques Lucke <jacques@blender.org> | 2021-10-29 10:28:31 +0300 |
commit | cf771807b7997949611dbf76b43150592c9977cb (patch) | |
tree | d1b986d9cd4bf56c93edf9755d6163cc6263b0dc /source/blender/blenkernel/intern/geometry_component_instances.cc | |
parent | b546202a9afa5ee358893d82e6a1ba0f69cca254 (diff) |
Geometry Nodes: do cache invalidation after writing attributes
This is a better and more general fix for T92511 and T92508 than
the ones that I committed before.
Previously, we tagged caches dirty when first accessing attributes.
This led to incorrect caches when under some circumstances. Now
cache invalidation is part of `OutputAttribute.save()`.
A nice side benefit of this change is that it may make things more
efficient in some cases, because we don't invalidate caches when
they don't have to be invalidated.
Differential Revision: https://developer.blender.org/D13009
Diffstat (limited to 'source/blender/blenkernel/intern/geometry_component_instances.cc')
-rw-r--r-- | source/blender/blenkernel/intern/geometry_component_instances.cc | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/source/blender/blenkernel/intern/geometry_component_instances.cc b/source/blender/blenkernel/intern/geometry_component_instances.cc index d02121b44a6..5fe77000519 100644 --- a/source/blender/blenkernel/intern/geometry_component_instances.cc +++ b/source/blender/blenkernel/intern/geometry_component_instances.cc @@ -398,15 +398,16 @@ class InstancePositionAttributeProvider final : public BuiltinAttributeProvider transforms); } - GVMutableArrayPtr try_get_for_write(GeometryComponent &component) const final + WriteAttributeLookup try_get_for_write(GeometryComponent &component) const final { InstancesComponent &instances_component = static_cast<InstancesComponent &>(component); MutableSpan<float4x4> transforms = instances_component.instance_transforms(); - return std::make_unique<fn::GVMutableArray_For_DerivedSpan<float4x4, - float3, - get_transform_position, - set_transform_position>>( - transforms); + return { + std::make_unique<fn::GVMutableArray_For_DerivedSpan<float4x4, + float3, + get_transform_position, + set_transform_position>>(transforms), + domain_}; } bool try_delete(GeometryComponent &UNUSED(component)) const final @@ -443,13 +444,14 @@ class InstanceIDAttributeProvider final : public BuiltinAttributeProvider { return std::make_unique<fn::GVArray_For_Span<int>>(instances.instance_ids()); } - GVMutableArrayPtr try_get_for_write(GeometryComponent &component) const final + WriteAttributeLookup try_get_for_write(GeometryComponent &component) const final { InstancesComponent &instances = static_cast<InstancesComponent &>(component); if (instances.instance_ids().is_empty()) { return {}; } - return std::make_unique<fn::GVMutableArray_For_MutableSpan<int>>(instances.instance_ids()); + return {std::make_unique<fn::GVMutableArray_For_MutableSpan<int>>(instances.instance_ids()), + domain_}; } bool try_delete(GeometryComponent &component) const final |