Fix #121366: Invalid mat_nr after exact boolean

Material index of faces could be a invalid value after booleaning in
exact boolean in "Index Based" mode against objects with no material
slots, this is caused by the lack of initilization material remapping
array. Now all initilized to 0.

Assigning 0 explicitly in Fast mode as well for consistency.

Pull Request: https://projects.blender.org/blender/blender/pulls/121380
This commit is contained in:
YimingWu
2024-05-04 13:29:35 +02:00
committed by YimingWu
parent 7ec4218d1d
commit 3be6dbb02a

View File

@@ -330,6 +330,9 @@ static void BMD_mesh_intersection(BMesh *bm,
if (LIKELY(efa->mat_nr < operand_ob->totcol)) {
efa->mat_nr = material_remap[efa->mat_nr];
}
else {
efa->mat_nr = 0;
}
if (++i == i_faces_end) {
break;
@@ -373,9 +376,9 @@ static void BMD_mesh_intersection(BMesh *bm,
* or to zero if there aren't enough slots in the destination. */
static Array<short> get_material_remap_index_based(Object *dest_ob, Object *src_ob)
{
int n = src_ob->totcol;
const int n = src_ob->totcol;
if (n <= 0) {
n = 1;
return Array<short>(1, 0);
}
Array<short> remap(n);
BKE_object_material_remap_calc(dest_ob, src_ob, remap.data());