From 5d2d36b0686d7253f9d61c00a63d273aba17677a Mon Sep 17 00:00:00 2001 From: Rohan Rathi Date: Fri, 25 May 2018 22:24:24 +0530 Subject: Applied soc-2017-normal-tools --- source/blender/blenkernel/intern/editmesh.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'source/blender/blenkernel/intern/editmesh.c') diff --git a/source/blender/blenkernel/intern/editmesh.c b/source/blender/blenkernel/intern/editmesh.c index b63ab276b14..a7f93ca6c49 100644 --- a/source/blender/blenkernel/intern/editmesh.c +++ b/source/blender/blenkernel/intern/editmesh.c @@ -246,3 +246,26 @@ float (*BKE_editmesh_vertexCos_get_orco(BMEditMesh *em, int *r_numVerts))[3] return orco; } + +void BKE_editmesh_lnorspace_update(BMEditMesh *em) +{ + BMesh *bm = em->bm; + + /* We need to create clnors data is none exist yet, otherwise there is no way to edit them. */ + /* Similar code to MESH_OT_customdata_custom_splitnormals_add operator, we want to keep same shading + * in case we were using autosmooth so far... */ + /* Note: there is a problem here, which is that is someone starts a normal editing operation on previously + * autosmooth-ed mesh, and cancel that operation, generated clnors data remain, with related sharp edges + * (and hence autosmooth is 'lost'). + * Not sure how critical this is, and how to fix that issue? */ + if (!CustomData_has_layer(&bm->ldata, CD_CUSTOMLOOPNORMAL)) { + Mesh *me = em->ob->data; + if (me->flag & ME_AUTOSMOOTH) { + BM_edges_sharp_from_angle_set(bm, me->smoothresh); + + me->drawflag |= ME_DRAWSHARP; + } + } + + BM_lnorspace_update(bm); +} -- cgit v1.2.3