[Bf-blender-cvs] [87b418193a6] refactor-mesh-uv-map-generic: Make sure the name of newly added UV maps is unique over all domains.

Baardaap noreply at git.blender.org
Tue Dec 27 21:24:04 CET 2022


Commit: 87b418193a62577da7c26dc66be5eced1ef639bf
Author: Baardaap
Date:   Tue Dec 27 21:23:56 2022 +0100
Branches: refactor-mesh-uv-map-generic
https://developer.blender.org/rB87b418193a62577da7c26dc66be5eced1ef639bf

Make sure the name of newly added UV maps is unique over all domains.

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

M	source/blender/editors/mesh/mesh_data.cc

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

diff --git a/source/blender/editors/mesh/mesh_data.cc b/source/blender/editors/mesh/mesh_data.cc
index bd99dc92db3..d14a69d3c23 100644
--- a/source/blender/editors/mesh/mesh_data.cc
+++ b/source/blender/editors/mesh/mesh_data.cc
@@ -265,6 +265,9 @@ int ED_mesh_uv_add(
     name = DATA_("UVMap");
   }
 
+  char unique_name[MAX_CUSTOMDATA_LAYER_NAME];
+
+  BKE_id_attribute_calc_unique_name(&me->id, name, unique_name);
   bool is_init = false;
 
   if (me->edit_mesh) {
@@ -276,7 +279,7 @@ int ED_mesh_uv_add(
       return -1;
     }
 
-    BM_data_layer_add_named(em->bm, &em->bm->ldata, CD_PROP_FLOAT2, name);
+    BM_data_layer_add_named(em->bm, &em->bm->ldata, CD_PROP_FLOAT2, unique_name);
     BM_uv_map_ensure_selection_and_pin_attributes(em->bm);
     /* copy data from active UV */
     if (layernum_dst && do_init) {
@@ -302,13 +305,13 @@ int ED_mesh_uv_add(
                                  CD_DUPLICATE,
                                  CustomData_get_layer(&me->ldata, CD_PROP_FLOAT2),
                                  me->totloop,
-                                 name);
+                                 unique_name);
 
       is_init = true;
     }
     else {
       CustomData_add_layer_named(
-          &me->ldata, CD_PROP_FLOAT2, CD_SET_DEFAULT, nullptr, me->totloop, name);
+          &me->ldata, CD_PROP_FLOAT2, CD_SET_DEFAULT, nullptr, me->totloop, unique_name);
     }
 
     if (active_set || layernum_dst == 0) {



More information about the Bf-blender-cvs mailing list