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
diff options
context:
space:
mode:
authorHans Goudey <h.goudey@me.com>2022-05-03 10:28:35 +0300
committerHans Goudey <h.goudey@me.com>2022-05-03 10:47:40 +0300
commitf80e4f0046ed93714c1c71a60264e9d012237654 (patch)
treeadf2a19c324f29823a128967d6f0126c31409a79 /source/blender/blenkernel/intern/mesh_boolean_convert.cc
parentaf2740abc0b003fd9d307933480ace3a99803669 (diff)
Fix T93272: Material index mapping missing for mesh boolean node
This commit implements copying of materials and material indices from all of the boolean node's input meshes. The materials are added to the final mesh in the order that they appear when looking through the materials of the input meshes in the same order of the multi-socket input node. All material remapping is done with mesh-level materials. Object-level materials are not considered, since the meshes don't come from objects. Merging all materials rather than just the materials on the first mesh requires a change to the boolean-mesh conversion. This subtly changes the behavior for object linked materials, but in a good way I think; now the material remap arrays are respected no matter the number of materials on the first mesh input. Differential Revision: https://developer.blender.org/D14788
Diffstat (limited to 'source/blender/blenkernel/intern/mesh_boolean_convert.cc')
-rw-r--r--source/blender/blenkernel/intern/mesh_boolean_convert.cc12
1 files changed, 3 insertions, 9 deletions
diff --git a/source/blender/blenkernel/intern/mesh_boolean_convert.cc b/source/blender/blenkernel/intern/mesh_boolean_convert.cc
index 9e77b138359..14bd6aa5b2f 100644
--- a/source/blender/blenkernel/intern/mesh_boolean_convert.cc
+++ b/source/blender/blenkernel/intern/mesh_boolean_convert.cc
@@ -407,17 +407,11 @@ static void copy_poly_attributes(Mesh *dest_mesh,
int index_in_orig_me,
Span<short> material_remap)
{
- mp->mat_nr = orig_mp->mat_nr;
- if (mp->mat_nr >= dest_mesh->totcol) {
- mp->mat_nr = 0;
+ if (material_remap.size() > 0 && material_remap.index_range().contains(orig_mp->mat_nr)) {
+ mp->mat_nr = material_remap[orig_mp->mat_nr];
}
else {
- if (material_remap.size() > 0) {
- short mat_nr = material_remap[orig_mp->mat_nr];
- if (mat_nr >= 0 && mat_nr < dest_mesh->totcol) {
- mp->mat_nr = mat_nr;
- }
- }
+ mp->mat_nr = orig_mp->mat_nr;
}
mp->flag = orig_mp->flag;