diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2015-09-03 13:20:50 +0300 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2015-09-03 13:20:50 +0300 |
commit | e5e65b1099c2d146614691c9e54c95b99f8d8685 (patch) | |
tree | 3622c17acab5b855b5f36d8a55ab4193931fde25 /source/blender/blenkernel/intern/mesh_evaluate.c | |
parent | 357e749957dc4899f11b6a9335a9cab2aac42b21 (diff) |
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).
Diffstat (limited to 'source/blender/blenkernel/intern/mesh_evaluate.c')
-rw-r--r-- | source/blender/blenkernel/intern/mesh_evaluate.c | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/source/blender/blenkernel/intern/mesh_evaluate.c b/source/blender/blenkernel/intern/mesh_evaluate.c index d4787bd250c..a25ea463718 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); } } |