Hi, This commit broke shading of mesh with boolean modifier. Sample file http://www.pasteall.org/blend/12728
Calculating of normals before applying boolean operation in MOD_boolean seems to help here but not sure if it's correct way of solving the issue. On Sun, Mar 18, 2012 at 7:49 AM, Campbell Barton <[email protected]>wrote: > Revision: 44960 > > http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=44960 > Author: campbellbarton > Date: 2012-03-18 06:49:32 +0000 (Sun, 18 Mar 2012) > Log Message: > ----------- > ngons draw with uniform normals in object mode now, I had this code > disabled for speed (it was being called when it didnt need to), but for > CDDM meshes without face normal layers this should still be called. > > Modified Paths: > -------------- > trunk/blender/source/blender/blenkernel/BKE_cdderivedmesh.h > trunk/blender/source/blender/blenkernel/intern/DerivedMesh.c > trunk/blender/source/blender/blenkernel/intern/cdderivedmesh.c > > Modified: trunk/blender/source/blender/blenkernel/BKE_cdderivedmesh.h > =================================================================== > --- trunk/blender/source/blender/blenkernel/BKE_cdderivedmesh.h 2012-03-18 > 06:01:33 UTC (rev 44959) > +++ trunk/blender/source/blender/blenkernel/BKE_cdderivedmesh.h 2012-03-18 > 06:49:32 UTC (rev 44960) > @@ -96,6 +96,7 @@ > > /* recalculates vertex and face normals for a CDDerivedMesh > */ > +void CDDM_calc_normals_mapping_ex(struct DerivedMesh *dm, const short > only_face_normals); > void CDDM_calc_normals_mapping(struct DerivedMesh *dm); > void CDDM_calc_normals(struct DerivedMesh *dm); > void CDDM_calc_normals_tessface(struct DerivedMesh *dm); > > Modified: trunk/blender/source/blender/blenkernel/intern/DerivedMesh.c > =================================================================== > --- trunk/blender/source/blender/blenkernel/intern/DerivedMesh.c > 2012-03-18 06:01:33 UTC (rev 44959) > +++ trunk/blender/source/blender/blenkernel/intern/DerivedMesh.c > 2012-03-18 06:49:32 UTC (rev 44960) > @@ -1699,6 +1699,19 @@ > /* Need to watch this, it can cause issues, see bug > [#29338] */ > /* take care with this block, we really need testing > frameworks */ > /* > --------------------------------------------------------------------- */ > + > + > + /* without this, drawing ngon tri's faces will show ugly > tessellated face > + * normals and will also have to calculate normals on the > fly, try avoid > + * this where possible since calculating polygon normals > isn't fast, > + * note that this isn't a problem for subsurf (only quads) > or editmode > + * which deals with drawing differently. > + * > + * Never calc vertex normals because other code ensures > these are up to date. > + */ > + if ((finaldm->type == DM_TYPE_CDDM) && > (CustomData_has_layer(&finaldm->faceData, CD_NORMAL) == FALSE)) { > + CDDM_calc_normals_mapping_ex(finaldm, TRUE); > + } > } > > > > Modified: trunk/blender/source/blender/blenkernel/intern/cdderivedmesh.c > =================================================================== > --- trunk/blender/source/blender/blenkernel/intern/cdderivedmesh.c > 2012-03-18 06:01:33 UTC (rev 44959) > +++ trunk/blender/source/blender/blenkernel/intern/cdderivedmesh.c > 2012-03-18 06:49:32 UTC (rev 44960) > @@ -2069,24 +2069,21 @@ > copy_v3_v3_short(vert->no, vertNormals[i]); > } > > -void CDDM_calc_normals_mapping(DerivedMesh *dm) > +void CDDM_calc_normals_mapping_ex(DerivedMesh *dm, const short > only_face_normals) > { > CDDerivedMesh *cddm = (CDDerivedMesh*)dm; > float (*face_nors)[3] = NULL; > > - /* use this to skip calculating normals on original vert's, this > may need to be changed */ > - const short only_face_normals = > CustomData_is_referenced_layer(&dm->vertData, CD_MVERT); > - > if(dm->numVertData == 0) return; > > /* now we skip calculating vertex normals for referenced layer, > * no need to duplicate verts. > * WATCH THIS, bmesh only change!, > * need to take care of the side effects here - campbell */ > -#if 0 > + #if 0 > /* we don't want to overwrite any referenced layers */ > cddm->mvert = CustomData_duplicate_referenced_layer(&dm->vertData, > CD_MVERT, dm->numVertData); > -#endif > + #endif > > > if (dm->numTessFaceData == 0) { > @@ -2105,17 +2102,24 @@ > > > face_nors = MEM_mallocN(sizeof(float)*3*dm->numTessFaceData, > "face_nors"); > - > + > /* calculate face normals */ > mesh_calc_normals_mapping_ex(cddm->mvert, dm->numVertData, > CDDM_get_loops(dm), CDDM_get_polys(dm), > - dm->numLoopData, dm->numPolyData, > NULL, cddm->mface, dm->numTessFaceData, > - CustomData_get_layer(&dm->faceData, > CD_POLYINDEX), face_nors, > - only_face_normals); > - > - CustomData_add_layer(&dm->faceData, CD_NORMAL, CD_ASSIGN, > - face_nors, dm->numTessFaceData); > + > dm->numLoopData, dm->numPolyData, NULL, cddm->mface, dm->numTessFaceData, > + > CustomData_get_layer(&dm->faceData, CD_POLYINDEX), face_nors, > + > only_face_normals); > > + CustomData_add_layer(&dm->faceData, CD_NORMAL, CD_ASSIGN, > + face_nors, > dm->numTessFaceData); > +} > > + > +void CDDM_calc_normals_mapping(DerivedMesh *dm) > +{ > + /* use this to skip calculating normals on original vert's, this > may need to be changed */ > + const short only_face_normals = > CustomData_is_referenced_layer(&dm->vertData, CD_MVERT); > + > + CDDM_calc_normals_mapping_ex(dm, only_face_normals); > } > > /* bmesh note: this matches what we have in trunk */ > > _______________________________________________ > Bf-blender-cvs mailing list > [email protected] > http://lists.blender.org/mailman/listinfo/bf-blender-cvs > -- With best regards, Sergey Sharybin _______________________________________________ Bf-committers mailing list [email protected] http://lists.blender.org/mailman/listinfo/bf-committers
