[Bf-blender-cvs] [d48c7a0419e] refactor-mesh-hide-generic: Merge branch 'master' into refactor-mesh-hide-generic
Hans Goudey
noreply at git.blender.org
Mon Aug 8 22:20:16 CEST 2022
Commit: d48c7a0419e248464102391f0b776df7e7c41b25
Author: Hans Goudey
Date: Mon Aug 8 15:19:58 2022 -0500
Branches: refactor-mesh-hide-generic
https://developer.blender.org/rBd48c7a0419e248464102391f0b776df7e7c41b25
Merge branch 'master' into refactor-mesh-hide-generic
===================================================================
===================================================================
diff --cc source/blender/blenkernel/intern/customdata.cc
index 75f9a67e992,acb978642aa..969b9903a39
--- a/source/blender/blenkernel/intern/customdata.cc
+++ b/source/blender/blenkernel/intern/customdata.cc
@@@ -2327,44 -2342,7 +2342,44 @@@ bool CustomData_merge(const CustomData
return changed;
}
+static bool attribute_stored_in_bmesh_flag(const StringRef name)
+{
+ return ELEM(name, ".hide_vert", ".hide_edge", ".hide_face");
+}
+
+static CustomData shallow_copy_remove_non_bmesh_attributes(const CustomData &src)
+{
+ Vector<CustomDataLayer> dst_layers;
+ for (const CustomDataLayer &layer : Span<CustomDataLayer>{src.layers, src.totlayer}) {
+ if (!attribute_stored_in_bmesh_flag(layer.name)) {
+ dst_layers.append(layer);
+ }
+ }
+
+ CustomData dst = src;
+ dst.layers = static_cast<CustomDataLayer *>(
+ MEM_calloc_arrayN(dst_layers.size(), sizeof(CustomDataLayer), __func__));
+ dst.totlayer = dst_layers.size();
+ memcpy(dst.layers, dst_layers.data(), dst_layers.as_span().size_in_bytes());
+
+ CustomData_update_typemap(&dst);
+
+ return dst;
+}
+
+bool CustomData_merge_mesh_to_bmesh(const CustomData *source,
+ CustomData *dest,
- eCustomDataMask mask,
- eCDAllocType alloctype,
- int totelem)
++ const eCustomDataMask mask,
++ const eCDAllocType alloctype,
++ const int totelem)
+{
+ CustomData source_copy = shallow_copy_remove_non_bmesh_attributes(*source);
+ const bool result = CustomData_merge(&source_copy, dest, mask, alloctype, totelem);
+ MEM_SAFE_FREE(source_copy.layers);
+ return result;
+}
+
- void CustomData_realloc(CustomData *data, int totelem)
+ void CustomData_realloc(CustomData *data, const int totelem)
{
BLI_assert(totelem >= 0);
for (int i = 0; i < data->totlayer; i++) {
@@@ -2395,18 -2373,7 +2410,18 @@@ void CustomData_copy(const CustomData *
CustomData_merge(source, dest, mask, alloctype, totelem);
}
+void CustomData_copy_mesh_to_bmesh(const CustomData *source,
+ CustomData *dest,
- eCustomDataMask mask,
- eCDAllocType alloctype,
- int totelem)
++ const eCustomDataMask mask,
++ const eCDAllocType alloctype,
++ const int totelem)
+{
+ CustomData source_copy = shallow_copy_remove_non_bmesh_attributes(*source);
+ CustomData_copy(&source_copy, dest, mask, alloctype, totelem);
+ MEM_SAFE_FREE(source_copy.layers);
+}
+
- static void customData_free_layer__internal(CustomDataLayer *layer, int totelem)
+ static void customData_free_layer__internal(CustomDataLayer *layer, const int totelem)
{
const LayerTypeInfo *typeInfo;
More information about the Bf-blender-cvs
mailing list