Merge branch 'blender-v4.5-release'

This commit is contained in:
Hans Goudey
2025-06-12 08:48:23 -04:00
3 changed files with 35 additions and 0 deletions

View File

@@ -245,6 +245,22 @@ void mesh_convert_storage_to_customdata(Mesh &mesh)
{AttrDomain::Edge, {mesh.edge_data, mesh.edges_num}},
{AttrDomain::Face, {mesh.face_data, mesh.faces_num}},
{AttrDomain::Corner, {mesh.corner_data, mesh.corners_num}}});
if (const char *name = mesh.active_uv_map_attribute) {
const int layer_n = CustomData_get_named_layer(&mesh.corner_data, CD_PROP_FLOAT2, name);
if (layer_n != -1) {
CustomData_set_layer_active(&mesh.corner_data, CD_PROP_FLOAT2, layer_n);
}
MEM_freeN(mesh.active_uv_map_attribute);
mesh.active_uv_map_attribute = nullptr;
}
if (const char *name = mesh.default_uv_map_attribute) {
const int layer_n = CustomData_get_named_layer(&mesh.corner_data, CD_PROP_FLOAT2, name);
if (layer_n != -1) {
CustomData_set_layer_render(&mesh.corner_data, CD_PROP_FLOAT2, layer_n);
}
MEM_freeN(mesh.default_uv_map_attribute);
mesh.default_uv_map_attribute = nullptr;
}
}
void mesh_convert_customdata_to_storage(Mesh &mesh)
{

View File

@@ -200,6 +200,10 @@ static void mesh_copy_data(Main *bmain,
MEM_dupallocN(mesh_src->active_color_attribute));
mesh_dst->default_color_attribute = static_cast<char *>(
MEM_dupallocN(mesh_src->default_color_attribute));
mesh_dst->active_uv_map_attribute = static_cast<char *>(
MEM_dupallocN(mesh_src->active_uv_map_attribute));
mesh_dst->default_uv_map_attribute = static_cast<char *>(
MEM_dupallocN(mesh_src->default_uv_map_attribute));
CustomData_init_from(
&mesh_src->vert_data, &mesh_dst->vert_data, mask.vmask, mesh_dst->verts_num);
@@ -247,6 +251,8 @@ static void mesh_free_data(ID *id)
BLI_freelistN(&mesh->vertex_group_names);
MEM_SAFE_FREE(mesh->active_color_attribute);
MEM_SAFE_FREE(mesh->default_color_attribute);
MEM_SAFE_FREE(mesh->active_uv_map_attribute);
MEM_SAFE_FREE(mesh->default_uv_map_attribute);
mesh->attribute_storage.wrap().~AttributeStorage();
if (mesh->face_offset_indices) {
blender::implicit_sharing::free_shared_data(&mesh->face_offset_indices,
@@ -409,6 +415,8 @@ static void mesh_blend_read_data(BlendDataReader *reader, ID *id)
}
BLO_read_string(reader, &mesh->active_color_attribute);
BLO_read_string(reader, &mesh->default_color_attribute);
BLO_read_string(reader, &mesh->active_uv_map_attribute);
BLO_read_string(reader, &mesh->default_uv_map_attribute);
/* Forward compatibility. To be removed when runtime format changes. */
blender::bke::mesh_convert_storage_to_customdata(*mesh);

View File

@@ -178,6 +178,17 @@ typedef struct Mesh {
/** The color attribute used by default (i.e. for rendering) if no name is given explicitly. */
char *default_color_attribute;
/**
* The UV map currently selected in the list and edited by a user.
* Currently only used for file forward compatibility (see #AttributeStorage).
*/
char *active_uv_map_attribute;
/**
* The UV map used by default (i.e. for rendering) if no name is given explicitly.
* Currently only used for file forward compatibility (see #AttributeStorage).
*/
char *default_uv_map_attribute;
/**
* User-defined symmetry flag (#eMeshSymmetryType) that causes editing operations to maintain
* symmetrical geometry. Supported by operations such as transform and weight-painting.