[Bf-blender-cvs] [065826a3b41] refactor-mesh-uv-map-generic: Handle UV map associated bool lyers on attribute duplication

Martijn Versteegh noreply at git.blender.org
Tue Jan 3 13:10:25 CET 2023


Commit: 065826a3b41da8931e313acc51865f4000e50c22
Author: Martijn Versteegh
Date:   Tue Jan 3 13:09:58 2023 +0100
Branches: refactor-mesh-uv-map-generic
https://developer.blender.org/rB065826a3b41da8931e313acc51865f4000e50c22

Handle UV map associated bool lyers on attribute duplication

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

M	source/blender/blenkernel/intern/attribute.cc

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

diff --git a/source/blender/blenkernel/intern/attribute.cc b/source/blender/blenkernel/intern/attribute.cc
index 490f7d48833..bc174adc5df 100644
--- a/source/blender/blenkernel/intern/attribute.cc
+++ b/source/blender/blenkernel/intern/attribute.cc
@@ -293,6 +293,27 @@ CustomDataLayer *BKE_id_attribute_new(
   return (index == -1) ? nullptr : &(customdata->layers[index]);
 }
 
+
+static void bke_id_attribute_copy_if_exists(ID *id, const char *srcname, const char *dstname)
+{
+  using namespace blender::bke;
+
+  std::optional<MutableAttributeAccessor> attributes = get_attribute_accessor_for_write(*id);
+  if (!attributes) {
+    return;
+  }
+
+  GAttributeReader src = attributes->lookup(srcname);
+  if (!src) {
+    return;
+  }
+
+  const eCustomDataType type = cpp_type_to_custom_data_type(src.varray.type());
+  attributes->add(dstname, src.domain, type, AttributeInitVArray(src.varray));
+
+}
+
+
 CustomDataLayer *BKE_id_attribute_duplicate(ID *id, const char *name, ReportList *reports)
 {
   using namespace blender::bke;
@@ -322,6 +343,23 @@ CustomDataLayer *BKE_id_attribute_duplicate(ID *id, const char *name, ReportList
   const eCustomDataType type = cpp_type_to_custom_data_type(src.varray.type());
   attributes->add(uniquename, src.domain, type, AttributeInitVArray(src.varray));
 
+  if (GS(id->name) == ID_ME && type == CD_PROP_FLOAT2) {
+    /* Duplicate UV sub-attributes. */
+    char buffer_src[MAX_CUSTOMDATA_LAYER_NAME];
+    char buffer_dst[MAX_CUSTOMDATA_LAYER_NAME];
+
+    bke_id_attribute_copy_if_exists(id,
+                            BKE_uv_map_vert_selection_name_get(name, buffer_src),
+                            BKE_uv_map_vert_selection_name_get(uniquename, buffer_dst));
+    bke_id_attribute_copy_if_exists(id,
+                            BKE_uv_map_edge_selection_name_get(name, buffer_src),
+                            BKE_uv_map_edge_selection_name_get(uniquename, buffer_dst));
+    bke_id_attribute_copy_if_exists(id,
+                            BKE_uv_map_pin_name_get(name, buffer_src),
+                            BKE_uv_map_pin_name_get(uniquename, buffer_dst));
+  }
+
+
   return BKE_id_attribute_search(id, uniquename, CD_MASK_PROP_ALL, ATTR_DOMAIN_MASK_ALL);
 }



More information about the Bf-blender-cvs mailing list