From 325ceabb0998b76b4763a1dcc1d19b877ed39955 Mon Sep 17 00:00:00 2001 From: Hans Goudey Date: Thu, 10 Jul 2025 10:02:25 -0400 Subject: [PATCH] Fix #141721: Adding curve attributes doesn't invalidate caches In this report, adding the "resolution" attribute didn't clear the evaluated positions cache. In some cases capturing an attribute on the mesh might just add the mesh rather than using an attribute writer. --- source/blender/blenkernel/intern/curves_attributes.cc | 6 ++++-- .../blender/blenkernel/intern/grease_pencil_attributes.cc | 6 ++++-- source/blender/blenkernel/intern/instances_attributes.cc | 6 ++++-- source/blender/blenkernel/intern/pointcloud_attributes.cc | 6 ++++-- .../modeling/geometry_nodes/curves/resolution_add.blend | 3 +++ 5 files changed, 19 insertions(+), 8 deletions(-) create mode 100644 tests/files/modeling/geometry_nodes/curves/resolution_add.blend diff --git a/source/blender/blenkernel/intern/curves_attributes.cc b/source/blender/blenkernel/intern/curves_attributes.cc index 0142e375ba5..e3f5b5a4c63 100644 --- a/source/blender/blenkernel/intern/curves_attributes.cc +++ b/source/blender/blenkernel/intern/curves_attributes.cc @@ -421,8 +421,10 @@ static AttributeAccessorFunctions get_curves_accessor_functions() if (storage.lookup(name)) { return false; } - Attribute::DataVariant data = attribute_init_to_data(type, domain_size, initializer); - storage.add(name, domain, type, std::move(data)); + storage.add(name, domain, type, attribute_init_to_data(type, domain_size, initializer)); + if (const std::optional fn = changed_tags().lookup_try(name)) { + (*fn)(owner); + } return true; }; diff --git a/source/blender/blenkernel/intern/grease_pencil_attributes.cc b/source/blender/blenkernel/intern/grease_pencil_attributes.cc index 4cc1fdc0336..0ea12d63649 100644 --- a/source/blender/blenkernel/intern/grease_pencil_attributes.cc +++ b/source/blender/blenkernel/intern/grease_pencil_attributes.cc @@ -134,8 +134,10 @@ static AttributeAccessorFunctions get_grease_pencil_accessor_functions() if (storage.lookup(name)) { return false; } - Attribute::DataVariant data = attribute_init_to_data(type, domain_size, initializer); - storage.add(name, domain, type, std::move(data)); + storage.add(name, domain, type, attribute_init_to_data(type, domain_size, initializer)); + if (const std::optional fn = changed_tags().lookup_try(name)) { + (*fn)(owner); + } return true; }; diff --git a/source/blender/blenkernel/intern/instances_attributes.cc b/source/blender/blenkernel/intern/instances_attributes.cc index 96e84381dea..ad3761cc933 100644 --- a/source/blender/blenkernel/intern/instances_attributes.cc +++ b/source/blender/blenkernel/intern/instances_attributes.cc @@ -159,8 +159,10 @@ static constexpr AttributeAccessorFunctions get_instances_accessor_functions() if (storage.lookup(name)) { return false; } - Attribute::DataVariant data = attribute_init_to_data(type, domain_size, initializer); - storage.add(name, domain, type, std::move(data)); + storage.add(name, domain, type, attribute_init_to_data(type, domain_size, initializer)); + if (const std::optional fn = changed_tags().lookup_try(name)) { + (*fn)(owner); + } return true; }; diff --git a/source/blender/blenkernel/intern/pointcloud_attributes.cc b/source/blender/blenkernel/intern/pointcloud_attributes.cc index d1bb03cf8d2..10984ff22a7 100644 --- a/source/blender/blenkernel/intern/pointcloud_attributes.cc +++ b/source/blender/blenkernel/intern/pointcloud_attributes.cc @@ -154,8 +154,10 @@ static constexpr AttributeAccessorFunctions get_pointcloud_accessor_functions() if (storage.lookup(name)) { return false; } - Attribute::DataVariant data = attribute_init_to_data(type, domain_size, initializer); - storage.add(name, domain, type, std::move(data)); + storage.add(name, domain, type, attribute_init_to_data(type, domain_size, initializer)); + if (const std::optional fn = changed_tags().lookup_try(name)) { + (*fn)(owner); + } return true; }; diff --git a/tests/files/modeling/geometry_nodes/curves/resolution_add.blend b/tests/files/modeling/geometry_nodes/curves/resolution_add.blend new file mode 100644 index 00000000000..9abca8c87d2 --- /dev/null +++ b/tests/files/modeling/geometry_nodes/curves/resolution_add.blend @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:30f4a4e7edd99888870dd4d9b9c1ecd29d912a3d344f99e8b6a5c3b543193f92 +size 337841