[Bf-blender-cvs] [e5e65b1] master: Fix T45984: Setting custom normals properly requires multiple calls to normals_split_custom_set()
Bastien Montagne
noreply at git.blender.org
Thu Sep 3 12:24:59 CEST 2015
Commit: e5e65b1099c2d146614691c9e54c95b99f8d8685
Author: Bastien Montagne
Date: Thu Sep 3 12:20:50 2015 +0200
Branches: master
https://developer.blender.org/rBe5e65b1099c2d146614691c9e54c95b99f8d8685
Fix T45984: Setting custom normals properly requires multiple calls to normals_split_custom_set()
The detection of needed sharp edges (based on given loop normals) would not fully work
on first run in case we started with a complete smooth cyclic loop fan (edge between
first and last loop of the fan would not get checked).
===================================================================
M source/blender/blenkernel/intern/mesh_evaluate.c
===================================================================
diff --git a/source/blender/blenkernel/intern/mesh_evaluate.c b/source/blender/blenkernel/intern/mesh_evaluate.c
index d4787bd..a25ea46 100644
--- a/source/blender/blenkernel/intern/mesh_evaluate.c
+++ b/source/blender/blenkernel/intern/mesh_evaluate.c
@@ -1432,7 +1432,30 @@ static void mesh_normals_loop_custom_set(
loops = loops->next;
BLI_BITMAP_ENABLE(done_loops, lidx);
}
- BLI_BITMAP_ENABLE(done_loops, i); /* For single loops, where lnors_spacearr.lspacearr[i]->loops is NULL. */
+
+ /* We also have to check between last and first loops, otherwise we may miss some sharp edges here!
+ * This is just a simplified version of above while loop.
+ * See T45984. */
+ loops = lnors_spacearr.lspacearr[i]->loops;
+ if (loops && org_nor) {
+ const int lidx = GET_INT_FROM_POINTER(loops->link);
+ MLoop *ml = &mloops[lidx];
+ const int nidx = lidx;
+ float *nor = custom_loopnors[nidx];
+
+ if (is_zero_v3(nor)) {
+ nor = lnors[nidx];
+ }
+
+ if (dot_v3v3(org_nor, nor) < LNOR_SPACE_TRIGO_THRESHOLD) {
+ const MPoly *mp = &mpolys[loop_to_poly[lidx]];
+ const MLoop *mlp = &mloops[(lidx == mp->loopstart) ? mp->loopstart + mp->totloop - 1 : lidx - 1];
+ medges[(prev_ml->e == mlp->e) ? prev_ml->e : ml->e].flag |= ME_SHARP;
+ }
+ }
+
+ /* For single loops, where lnors_spacearr.lspacearr[i]->loops is NULL. */
+ BLI_BITMAP_ENABLE(done_loops, i);
}
}
More information about the Bf-blender-cvs
mailing list