diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2018-02-22 17:22:44 +0300 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2018-02-22 17:22:44 +0300 |
commit | 4ee3d7e3ac359dd04f80af88a46c5f3b14f49708 (patch) | |
tree | 33ed7ecc447a19b634a65d46eda3cb046f0dab8f /source/blender/editors/mesh/mesh_data.c | |
parent | 5aff002f7b3ad52f6a88dc0a3c2eac482b57da3e (diff) | |
parent | 0eee776e454f6b78ffa33b2ed8b19c747d8193ec (diff) |
Merge branch 'master' into blender2.8
Conflicts:
source/blender/bmesh/intern/bmesh_mesh.c
Diffstat (limited to 'source/blender/editors/mesh/mesh_data.c')
-rw-r--r-- | source/blender/editors/mesh/mesh_data.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/source/blender/editors/mesh/mesh_data.c b/source/blender/editors/mesh/mesh_data.c index bd3d2f652c0..305c18f5b62 100644 --- a/source/blender/editors/mesh/mesh_data.c +++ b/source/blender/editors/mesh/mesh_data.c @@ -882,9 +882,38 @@ static int mesh_customdata_custom_splitnormals_add_exec(bContext *C, wmOperator CustomData *data = GET_CD_DATA(me, ldata); if (me->edit_btmesh) { + /* Tag edges as sharp according to smooth threshold if needed, to preserve autosmooth shading. */ + if (me->flag & ME_AUTOSMOOTH) { + BM_edges_sharp_from_angle_set(me->edit_btmesh->bm, me->smoothresh); + + me->drawflag |= ME_DRAWSHARP; + } + BM_data_layer_add(me->edit_btmesh->bm, data, CD_CUSTOMLOOPNORMAL); } else { + /* Tag edges as sharp according to smooth threshold if needed, to preserve autosmooth shading. */ + if (me->flag & ME_AUTOSMOOTH) { + float (*polynors)[3] = MEM_mallocN(sizeof(*polynors) * (size_t)me->totpoly, __func__); + + BKE_mesh_calc_normals_poly( + me->mvert, NULL, me->totvert, + me->mloop, me->mpoly, + me->totloop, me->totpoly, + polynors, true); + + BKE_edges_sharp_from_angle_set( + me->mvert, me->totvert, + me->medge, me->totedge, + me->mloop, me->totloop, + me->mpoly, polynors, me->totpoly, + me->smoothresh); + + MEM_freeN(polynors); + + me->drawflag |= ME_DRAWSHARP; + } + CustomData_add_layer(data, CD_CUSTOMLOOPNORMAL, CD_DEFAULT, NULL, me->totloop); } |