[Bf-blender-cvs] [78151569d06] refactor-mesh-uv-map-generic: Making layernames unique should not let them grow too large.
Martijn Versteegh
noreply at git.blender.org
Fri Jan 6 00:31:59 CET 2023
Commit: 78151569d06cf804d471cff7eb9525a63edc8273
Author: Martijn Versteegh
Date: Fri Jan 6 00:13:56 2023 +0100
Branches: refactor-mesh-uv-map-generic
https://developer.blender.org/rB78151569d06cf804d471cff7eb9525a63edc8273
Making layernames unique should not let them grow too large.
The maximum size of the layernames internally now is
MAX_CUSTOMDATA_LAYER_SIZE , but except for layers with prefixes
like the uv map associated bool layers the size should never actually
be larger than MAX_CUSTMDATA_LAYER_NAME_GUI, which is 4 bytes
smaller to leave room for the prefixes.
===================================================================
M source/blender/blenkernel/intern/attribute.cc
M source/blender/blenkernel/intern/customdata.cc
===================================================================
diff --git a/source/blender/blenkernel/intern/attribute.cc b/source/blender/blenkernel/intern/attribute.cc
index 8b151e81354..183f33c4c81 100644
--- a/source/blender/blenkernel/intern/attribute.cc
+++ b/source/blender/blenkernel/intern/attribute.cc
@@ -243,18 +243,23 @@ static bool unique_name_cb(void *arg, const char *name)
bool BKE_id_attribute_calc_unique_name(ID *id, const char *name, char *outname)
{
AttrUniqueData data{id};
+ int maxlength = MAX_CUSTOMDATA_LAYER_NAME_GUI;
+
+ if (STREQLEN("." UV_VERTSEL_NAME ".", name, 4) || STREQLEN("." UV_EDGESEL_NAME ".", name, 4) ||
+ STREQLEN("." UV_PINNED_NAME ".", name, 4)) {
+ maxlength = MAX_CUSTOMDATA_LAYER_NAME;
+ }
/* Set default name if none specified.
* NOTE: We only call IFACE_() if needed to avoid locale lookup overhead. */
if (!name || name[0] == '\0') {
- BLI_strncpy(outname, IFACE_("Attribute"), MAX_CUSTOMDATA_LAYER_NAME);
+ BLI_strncpy(outname, IFACE_("Attribute"), maxlength);
}
else {
- BLI_strncpy_utf8(outname, name, MAX_CUSTOMDATA_LAYER_NAME);
+ BLI_strncpy_utf8(outname, name, maxlength);
}
- return BLI_uniquename_cb(
- unique_name_cb, &data, nullptr, '.', outname, MAX_CUSTOMDATA_LAYER_NAME);
+ return BLI_uniquename_cb(unique_name_cb, &data, nullptr, '.', outname, maxlength);
}
CustomDataLayer *BKE_id_attribute_new(
diff --git a/source/blender/blenkernel/intern/customdata.cc b/source/blender/blenkernel/intern/customdata.cc
index 0a2839bde32..3c0f434d17d 100644
--- a/source/blender/blenkernel/intern/customdata.cc
+++ b/source/blender/blenkernel/intern/customdata.cc
@@ -4319,14 +4319,21 @@ void CustomData_set_layer_unique_name(CustomData *data, const int index)
return;
}
+ int maxlength = MAX_CUSTOMDATA_LAYER_NAME_GUI;
+
+ if (STREQLEN("." UV_VERTSEL_NAME ".", nlayer->name, 4) ||
+ STREQLEN("." UV_EDGESEL_NAME ".", nlayer->name, 4) ||
+ STREQLEN("." UV_PINNED_NAME ".", nlayer->name, 4)) {
+ maxlength = MAX_CUSTOMDATA_LAYER_NAME;
+ }
+
/* Set default name if none specified. Note we only call DATA_() when
* needed to avoid overhead of locale lookups in the depsgraph. */
if (nlayer->name[0] == '\0') {
STRNCPY(nlayer->name, DATA_(typeInfo->defaultname));
}
- BLI_uniquename_cb(
- customdata_unique_check, &data_arg, nullptr, '.', nlayer->name, sizeof(nlayer->name));
+ BLI_uniquename_cb(customdata_unique_check, &data_arg, nullptr, '.', nlayer->name, maxlength);
}
void CustomData_validate_layer_name(const CustomData *data,
More information about the Bf-blender-cvs
mailing list