[Bf-blender-cvs] [7313a84c5ac] blender-v3.1-release: Fix T95612: only overwrite existing attributes with matching domain and type

Jacques Lucke noreply at git.blender.org
Wed Feb 9 15:54:02 CET 2022


Commit: 7313a84c5acb401817f1c44cfd8bf22428f34424
Author: Jacques Lucke
Date:   Wed Feb 9 15:50:03 2022 +0100
Branches: blender-v3.1-release
https://developer.blender.org/rB7313a84c5acb401817f1c44cfd8bf22428f34424

Fix T95612: only overwrite existing attributes with matching domain and type

Also fixes T95611 and T95610.

Differential Revision: https://developer.blender.org/D14051

===================================================================

M	source/blender/modifiers/intern/MOD_nodes.cc

===================================================================

diff --git a/source/blender/modifiers/intern/MOD_nodes.cc b/source/blender/modifiers/intern/MOD_nodes.cc
index 7e65774b86e..c5ee4b9fb52 100644
--- a/source/blender/modifiers/intern/MOD_nodes.cc
+++ b/source/blender/modifiers/intern/MOD_nodes.cc
@@ -996,7 +996,11 @@ static void store_computed_output_attributes(
 {
   for (const OutputAttributeToStore &store : attributes_to_store) {
     GeometryComponent &component = geometry.get_component_for_write(store.component_type);
-    if (component.attribute_exists(store.name)) {
+    const CustomDataType data_type = blender::bke::cpp_type_to_custom_data_type(store.data.type());
+    const std::optional<AttributeMetaData> meta_data = component.attribute_get_meta_data(
+        store.name);
+    if (meta_data.has_value() && meta_data->domain == store.domain &&
+        meta_data->data_type == data_type) {
       /* Copy the data into an existing attribute. */
       blender::bke::WriteAttributeLookup write_attribute = component.attribute_try_get_for_write(
           store.name);
@@ -1010,6 +1014,10 @@ static void store_computed_output_attributes(
       MEM_freeN(store.data.data());
     }
     else {
+      /* Replace the existing attribute with the new data. */
+      if (meta_data.has_value()) {
+        component.attribute_try_delete(store.name);
+      }
       component.attribute_try_create(store.name,
                                      store.domain,
                                      blender::bke::cpp_type_to_custom_data_type(store.data.type()),



More information about the Bf-blender-cvs mailing list