Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorHans Goudey <h.goudey@me.com>2022-09-13 01:17:11 +0300
committerHans Goudey <h.goudey@me.com>2022-09-13 01:17:11 +0300
commitad245f1970343ed41098ed9611a38b167fd757d4 (patch)
tree8c8bb2f6faa62ba1fbfc1641f5d99c03b43a470f /source
parentea474dda620036ff7003cbb6f2826952a08ceb14 (diff)
Fix T101013: Reordering materials broken with only one assigned
When there was only a single material assigned to the mesh, the material index attribute didn't necessarily exist. Changing the oder of the slots wouldn't change the first material index as necessary.
Diffstat (limited to 'source')
-rw-r--r--source/blender/blenkernel/intern/mesh.cc14
1 files changed, 5 insertions, 9 deletions
diff --git a/source/blender/blenkernel/intern/mesh.cc b/source/blender/blenkernel/intern/mesh.cc
index 636be0dc032..8616b056d7f 100644
--- a/source/blender/blenkernel/intern/mesh.cc
+++ b/source/blender/blenkernel/intern/mesh.cc
@@ -1416,19 +1416,15 @@ void BKE_mesh_material_remap(Mesh *me, const uint *remap, uint remap_len)
}
else {
MutableAttributeAccessor attributes = me->attributes_for_write();
- AttributeWriter<int> material_indices = attributes.lookup_for_write<int>("material_index");
+ SpanAttributeWriter<int> material_indices = attributes.lookup_or_add_for_write_span<int>(
+ "material_index", ATTR_DOMAIN_FACE);
if (!material_indices) {
return;
}
- if (material_indices.domain != ATTR_DOMAIN_FACE) {
- BLI_assert_unreachable();
- return;
- }
- MutableVArraySpan<int> indices_span(material_indices.varray);
- for (const int i : indices_span.index_range()) {
- MAT_NR_REMAP(indices_span[i]);
+ for (const int i : material_indices.span.index_range()) {
+ MAT_NR_REMAP(material_indices.span[i]);
}
- indices_span.save();
+ material_indices.span.save();
material_indices.finish();
}