Commit: 110a889be367dc9c2460b35b4514cde9acb7c001
Author: Campbell Barton
Date:   Thu Oct 29 18:34:02 2015 +1100
Branches: bmesh-boolean-experiment
https://developer.blender.org/rB110a889be367dc9c2460b35b4514cde9acb7c001

Tessellate faces before transforming vertices

Without this, ngons were tessellated with their old normals & transformed 
vertices.

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

M       source/blender/modifiers/intern/MOD_boolean.c

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

diff --git a/source/blender/modifiers/intern/MOD_boolean.c 
b/source/blender/modifiers/intern/MOD_boolean.c
index 38b05d2..877ab91 100644
--- a/source/blender/modifiers/intern/MOD_boolean.c
+++ b/source/blender/modifiers/intern/MOD_boolean.c
@@ -190,28 +190,8 @@ static DerivedMesh *applyModifier(
                        bm = BM_mesh_create(&allocsize);
 
                        DM_to_bmesh_ex(dm_other, bm, true);
-
-                       {
-                               BMIter iter;
-                               BMVert *eve;
-
-                               float mat[4][4];
-                               float omat[4][4];
-                               invert_m4_m4(mat, ob->obmat);
-                               mul_m4_m4m4(omat, mat, bmd->object->obmat);
-
-
-                               BM_ITER_MESH (eve, &iter, bm, BM_VERTS_OF_MESH) 
{
-                                       mul_m4_v3(omat, eve->co);
-                               }
-                       }
-
                        DM_to_bmesh_ex(dm, bm, true);
 
-                       /* not needed, but normals for 'dm' will be invalid,
-                        * currently this is ok for 'BM_mesh_intersect' */
-                       // BM_mesh_normals_update(bm);
-
                        if (1) {
                                /* create tessface & intersect */
                                const int looptris_tot = 
poly_to_tri_count(bm->totface, bm->totloop);
@@ -226,6 +206,31 @@ static DerivedMesh *applyModifier(
 
                                user_data.face_tot_first_mesh = 
dm_other->getNumPolys(dm_other);
 
+                               /* postpone this until after tessellating
+                                * so we can use the original normals before 
the vertex are moved */
+                               {
+                                       BMIter iter;
+                                       BMVert *eve;
+                                       int i = 0, i_end = 
dm_other->getNumVerts(dm_other);
+
+                                       float mat[4][4];
+                                       float omat[4][4];
+                                       invert_m4_m4(mat, ob->obmat);
+                                       mul_m4_m4m4(omat, mat, 
bmd->object->obmat);
+
+
+                                       BM_ITER_MESH (eve, &iter, bm, 
BM_VERTS_OF_MESH) {
+                                               mul_m4_v3(omat, eve->co);
+                                               if (++i == i_end) {
+                                                       break;
+                                               }
+                                       }
+                               }
+
+                               /* not needed, but normals for 'dm' will be 
invalid,
+                                * currently this is ok for 'BM_mesh_intersect' 
*/
+                               // BM_mesh_normals_update(bm);
+
                                BM_mesh_intersect(
                                        bm,
                                        looptris, tottri,

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to