[Bf-blender-cvs] [215a6f1c10c] blender-v2.93-release: Fix T92384: Wrong UV layers used with Boolean Modifier (Fast Solver)

Campbell Barton noreply at git.blender.org
Tue Nov 23 10:08:16 CET 2021


Commit: 215a6f1c10ce0b52e84153547fcc4d4073c16524
Author: Campbell Barton
Date:   Tue Nov 9 16:58:45 2021 +1100
Branches: blender-v2.93-release
https://developer.blender.org/rB215a6f1c10ce0b52e84153547fcc4d4073c16524

Fix T92384: Wrong UV layers used with Boolean Modifier (Fast Solver)

Ensure the layers from the source mesh are used instead of the
object referenced by the boolean modifier.

===================================================================

M	source/blender/bmesh/intern/bmesh_construct.c
M	source/blender/bmesh/intern/bmesh_construct.h
M	source/blender/modifiers/intern/MOD_boolean.cc

===================================================================

diff --git a/source/blender/bmesh/intern/bmesh_construct.c b/source/blender/bmesh/intern/bmesh_construct.c
index 3eab252df7a..fc5ee0d86f7 100644
--- a/source/blender/bmesh/intern/bmesh_construct.c
+++ b/source/blender/bmesh/intern/bmesh_construct.c
@@ -31,6 +31,7 @@
 
 #include "BKE_customdata.h"
 
+#include "DNA_mesh_types.h"
 #include "DNA_meshdata_types.h"
 
 #include "bmesh.h"
@@ -589,6 +590,25 @@ static BMFace *bm_mesh_copy_new_face(
   return f_new;
 }
 
+void BM_mesh_copy_init_customdata_from_mesh(BMesh *bm_dst,
+                                            const Mesh *me_src,
+                                            const BMAllocTemplate *allocsize)
+{
+  if (allocsize == NULL) {
+    allocsize = &bm_mesh_allocsize_default;
+  }
+
+  CustomData_copy(&me_src->vdata, &bm_dst->vdata, CD_MASK_BMESH.vmask, CD_CALLOC, 0);
+  CustomData_copy(&me_src->edata, &bm_dst->edata, CD_MASK_BMESH.emask, CD_CALLOC, 0);
+  CustomData_copy(&me_src->ldata, &bm_dst->ldata, CD_MASK_BMESH.lmask, CD_CALLOC, 0);
+  CustomData_copy(&me_src->pdata, &bm_dst->pdata, CD_MASK_BMESH.pmask, CD_CALLOC, 0);
+
+  CustomData_bmesh_init_pool(&bm_dst->vdata, allocsize->totvert, BM_VERT);
+  CustomData_bmesh_init_pool(&bm_dst->edata, allocsize->totedge, BM_EDGE);
+  CustomData_bmesh_init_pool(&bm_dst->ldata, allocsize->totloop, BM_LOOP);
+  CustomData_bmesh_init_pool(&bm_dst->pdata, allocsize->totface, BM_FACE);
+}
+
 void BM_mesh_copy_init_customdata(BMesh *bm_dst, BMesh *bm_src, const BMAllocTemplate *allocsize)
 {
   if (allocsize == NULL) {
diff --git a/source/blender/bmesh/intern/bmesh_construct.h b/source/blender/bmesh/intern/bmesh_construct.h
index f5102283ede..f2b5e2b4daa 100644
--- a/source/blender/bmesh/intern/bmesh_construct.h
+++ b/source/blender/bmesh/intern/bmesh_construct.h
@@ -23,6 +23,7 @@
 #include "bmesh_core.h"
 
 struct BMAllocTemplate;
+struct Mesh;
 
 bool BM_verts_from_edges(BMVert **vert_arr, BMEdge **edge_arr, const int len);
 
@@ -66,6 +67,9 @@ void BM_elem_attrs_copy_ex(BMesh *bm_src,
 void BM_elem_attrs_copy(BMesh *bm_src, BMesh *bm_dst, const void *ele_src_v, void *ele_dst_v);
 void BM_elem_select_copy(BMesh *bm_dst, void *ele_dst_v, const void *ele_src_v);
 
+void BM_mesh_copy_init_customdata_from_mesh(BMesh *bm_dst,
+                                            const struct Mesh *me_src,
+                                            const struct BMAllocTemplate *allocsize);
 void BM_mesh_copy_init_customdata(BMesh *bm_dst,
                                   BMesh *bm_src,
                                   const struct BMAllocTemplate *allocsize);
diff --git a/source/blender/modifiers/intern/MOD_boolean.cc b/source/blender/modifiers/intern/MOD_boolean.cc
index 846be9bc1df..2677ffe2477 100644
--- a/source/blender/modifiers/intern/MOD_boolean.cc
+++ b/source/blender/modifiers/intern/MOD_boolean.cc
@@ -248,6 +248,10 @@ static BMesh *BMD_mesh_bm_create(
   BMeshCreateParams bmcp = {false};
   BMesh *bm = BM_mesh_create(&allocsize, &bmcp);
 
+  /* Needed so active layers are set based on `mesh` not `mesh_operand_ob`,
+   * otherwise the wrong active render layer is used, see T92384. */
+  BM_mesh_copy_init_customdata_from_mesh(bm, mesh, &allocsize);
+
   BMeshFromMeshParams params{};
   params.calc_face_normal = true;
   BM_mesh_bm_from_me(bm, mesh_operand_ob, &params);



More information about the Bf-blender-cvs mailing list