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:
authorCampbell Barton <ideasman42@gmail.com>2015-12-12 16:34:09 +0300
committerCampbell Barton <ideasman42@gmail.com>2015-12-12 16:40:44 +0300
commitc61c312f97f6e23dabb8e4a6c488ddf4097369be (patch)
tree7ae2fde6cf4e1a5b79c391216b13ef9b31d514a7 /source/blender/modifiers
parentc1cfdc59a3f895b6b61dd55a48d18beff74adb7a (diff)
Use material remapping for bmesh-boolean
Diffstat (limited to 'source/blender/modifiers')
-rw-r--r--source/blender/modifiers/intern/MOD_boolean.c37
1 files changed, 26 insertions, 11 deletions
diff --git a/source/blender/modifiers/intern/MOD_boolean.c b/source/blender/modifiers/intern/MOD_boolean.c
index 57318e44eec..92570263856 100644
--- a/source/blender/modifiers/intern/MOD_boolean.c
+++ b/source/blender/modifiers/intern/MOD_boolean.c
@@ -54,7 +54,9 @@
#include "MOD_util.h"
#ifdef USE_BMESH
+#include "BLI_alloca.h"
#include "BLI_math_geom.h"
+#include "BKE_material.h"
#include "MEM_guardedalloc.h"
#include "bmesh.h"
@@ -238,17 +240,30 @@ static DerivedMesh *applyModifier_bmesh(
/* we need face normals because of 'BM_face_split_edgenet'
* we could calculate on the fly too (before calling split). */
- float nmat[4][4];
- invert_m4_m4(nmat, omat);
-
- BMFace *efa;
- i = 0;
- BM_ITER_MESH (efa, &iter, bm, BM_FACES_OF_MESH) {
- mul_transposed_mat3_m4_v3(nmat, efa->no);
- normalize_v3(efa->no);
- BM_elem_flag_enable(efa, BM_FACE_TAG); /* temp tag to test which side split faces are from */
- if (++i == i_faces_end) {
- break;
+ {
+ float nmat[4][4];
+ invert_m4_m4(nmat, omat);
+
+ const short ob_src_totcol = bmd->object->totcol;
+ short *material_remap = BLI_array_alloca(material_remap, ob_src_totcol ? ob_src_totcol : 1);
+
+ BKE_material_remap_object_calc(ob, bmd->object, material_remap);
+
+ BMFace *efa;
+ i = 0;
+ BM_ITER_MESH (efa, &iter, bm, BM_FACES_OF_MESH) {
+ mul_transposed_mat3_m4_v3(nmat, efa->no);
+ normalize_v3(efa->no);
+ BM_elem_flag_enable(efa, BM_FACE_TAG); /* temp tag to test which side split faces are from */
+
+ /* remap material */
+ if (LIKELY(efa->mat_nr < ob_src_totcol)) {
+ efa->mat_nr = material_remap[efa->mat_nr];
+ }
+
+ if (++i == i_faces_end) {
+ break;
+ }
}
}
}