[Bf-blender-cvs] [c2a8d8b18dd] master: Fix T103301: Active and default color attributes lost in many operations

Hans Goudey noreply at git.blender.org
Mon Dec 19 21:56:50 CET 2022


Commit: c2a8d8b18ddbcbba9419c00f53f1313d5e1c6f7e
Author: Hans Goudey
Date:   Mon Dec 19 14:56:39 2022 -0600
Branches: master
https://developer.blender.org/rBc2a8d8b18ddbcbba9419c00f53f1313d5e1c6f7e

Fix T103301: Active and default color attributes lost in many operations

When creating a new mesh to change it in some way, the active and
default color attribute names should be copied to the new mesh.
Doing that in the generic "copy parameters for eval" function should
cover the vast majority of cases.

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

M	source/blender/blenkernel/intern/mesh.cc
M	source/blender/geometry/intern/realize_instances.cc

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

diff --git a/source/blender/blenkernel/intern/mesh.cc b/source/blender/blenkernel/intern/mesh.cc
index c9418266729..a7f1eb1df00 100644
--- a/source/blender/blenkernel/intern/mesh.cc
+++ b/source/blender/blenkernel/intern/mesh.cc
@@ -979,6 +979,18 @@ Mesh *BKE_mesh_new_nomain(
   return mesh;
 }
 
+static void copy_attribute_names(const Mesh &mesh_src, Mesh &mesh_dst)
+{
+  if (mesh_src.active_color_attribute) {
+    MEM_SAFE_FREE(mesh_dst.active_color_attribute);
+    mesh_dst.active_color_attribute = BLI_strdup(mesh_src.active_color_attribute);
+  }
+  if (mesh_src.default_color_attribute) {
+    MEM_SAFE_FREE(mesh_dst.default_color_attribute);
+    mesh_dst.default_color_attribute = BLI_strdup(mesh_src.default_color_attribute);
+  }
+}
+
 void BKE_mesh_copy_parameters(Mesh *me_dst, const Mesh *me_src)
 {
   /* Copy general settings. */
@@ -1008,6 +1020,7 @@ void BKE_mesh_copy_parameters_for_eval(Mesh *me_dst, const Mesh *me_src)
   BLI_assert(me_dst->id.tag & (LIB_TAG_NO_MAIN | LIB_TAG_COPIED_ON_WRITE));
 
   BKE_mesh_copy_parameters(me_dst, me_src);
+  copy_attribute_names(*me_src, *me_dst);
 
   /* Copy vertex group names. */
   BLI_assert(BLI_listbase_is_empty(&me_dst->vertex_group_names));
diff --git a/source/blender/geometry/intern/realize_instances.cc b/source/blender/geometry/intern/realize_instances.cc
index 2e6fb87e823..57a4ae70b5f 100644
--- a/source/blender/geometry/intern/realize_instances.cc
+++ b/source/blender/geometry/intern/realize_instances.cc
@@ -1125,15 +1125,6 @@ static void execute_realize_mesh_tasks(const RealizeInstancesOptions &options,
     }
   });
 
-  if (first_mesh.active_color_attribute) {
-    MEM_SAFE_FREE(dst_mesh->active_color_attribute);
-    dst_mesh->active_color_attribute = BLI_strdup(first_mesh.active_color_attribute);
-  }
-  if (first_mesh.default_color_attribute) {
-    MEM_SAFE_FREE(dst_mesh->default_color_attribute);
-    dst_mesh->default_color_attribute = BLI_strdup(first_mesh.default_color_attribute);
-  }
-
   /* Tag modified attributes. */
   for (GSpanAttributeWriter &dst_attribute : dst_attribute_writers) {
     dst_attribute.finish();



More information about the Bf-blender-cvs mailing list