Commit: dd6642bb80acedc601244ed841576c9082e90af3
Author: Rohan Rathi
Date:   Wed Feb 14 14:03:04 2018 +0530
Branches: soc-2017-normal-tools
https://developer.blender.org/rBdd6642bb80acedc601244ed841576c9082e90af3

Added custom loop normals to work correctly with autosmooth

===================================================================

M       release/datafiles/locale
M       release/scripts/addons
M       release/scripts/addons_contrib
M       source/blender/blenkernel/BKE_editmesh.h
M       source/blender/blenkernel/intern/editmesh.c
M       source/blender/editors/mesh/editmesh_tools.c
M       source/blender/editors/transform/transform.c
M       source/tools

===================================================================

diff --git a/release/datafiles/locale b/release/datafiles/locale
index 469c949d1ca..59495b4b590 160000
--- a/release/datafiles/locale
+++ b/release/datafiles/locale
@@ -1 +1 @@
-Subproject commit 469c949d1ca882be19daa128842f813b72a944d8
+Subproject commit 59495b4b59077aa1cc68fffbdae1463af980f08e
diff --git a/release/scripts/addons b/release/scripts/addons
index c88411ff777..27970761a18 160000
--- a/release/scripts/addons
+++ b/release/scripts/addons
@@ -1 +1 @@
-Subproject commit c88411ff7776a2db5d6ef6117a1b2faa42a95611
+Subproject commit 27970761a18926abe1b0020aa350305e3109a537
diff --git a/release/scripts/addons_contrib b/release/scripts/addons_contrib
index 310578043de..6a4f93c9b8f 160000
--- a/release/scripts/addons_contrib
+++ b/release/scripts/addons_contrib
@@ -1 +1 @@
-Subproject commit 310578043dec1aae382eb6a447ae1d103792d7e6
+Subproject commit 6a4f93c9b8f36b19bd02087abf3d7f5983df035a
diff --git a/source/blender/blenkernel/BKE_editmesh.h 
b/source/blender/blenkernel/BKE_editmesh.h
index 55a9db9b1e5..7c87eb40a60 100644
--- a/source/blender/blenkernel/BKE_editmesh.h
+++ b/source/blender/blenkernel/BKE_editmesh.h
@@ -93,6 +93,7 @@ void        BKE_editmesh_update_linked_customdata(BMEditMesh 
*em);
 void        BKE_editmesh_color_free(BMEditMesh *em);
 void        BKE_editmesh_color_ensure(BMEditMesh *em, const char htype);
 float     (*BKE_editmesh_vertexCos_get_orco(BMEditMesh *em, int 
*r_numVerts))[3];
+void           BKE_editmesh_lnorspace_update(BMEditMesh *em);
 
 /* editderivedmesh.c */
 /* should really be defined in editmesh.c, but they use 'EditDerivedBMesh' */
diff --git a/source/blender/blenkernel/intern/editmesh.c 
b/source/blender/blenkernel/intern/editmesh.c
index fea3c24d322..a0205a828e3 100644
--- a/source/blender/blenkernel/intern/editmesh.c
+++ b/source/blender/blenkernel/intern/editmesh.c
@@ -264,3 +264,27 @@ 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;
+       if (bm->lnor_spacearr == NULL) {
+               float split_angle = ((Mesh *)em->ob->data)->smoothresh;
+               split_angle = cosf(split_angle);
+
+               BMEdge *e;
+               BMIter eiter;
+               BM_ITER_MESH(e, &eiter, em->bm, BM_EDGES_OF_MESH) {
+                       BMLoop *l_1, *l_2;
+                       if (BM_edge_loop_pair(e, &l_1, &l_2)) {
+                               const float *no_1 = l_1->f->no;
+                               const float *no_2 = l_2->f->no;
+
+                               if (dot_v3v3(no_1, no_2) < split_angle && 
BM_elem_flag_test(e, BM_ELEM_SMOOTH)) {
+                                       BM_elem_flag_disable(e, BM_ELEM_SMOOTH);
+                               }
+                       }
+               }
+       }
+       BM_lnorspace_update(bm);
+}
diff --git a/source/blender/editors/mesh/editmesh_tools.c 
b/source/blender/editors/mesh/editmesh_tools.c
index 9d5751f4782..56042d1f5dd 100644
--- a/source/blender/editors/mesh/editmesh_tools.c
+++ b/source/blender/editors/mesh/editmesh_tools.c
@@ -5994,9 +5994,10 @@ void MESH_OT_mark_freestyle_face(wmOperatorType *ot)
 static int init_point_normals(bContext *C, wmOperator *op, const wmEvent 
*UNUSED(event))
 {
        Object *obedit = CTX_data_edit_object(C);
-       BMesh *bm = BKE_editmesh_from_object(obedit)->bm;
+       BMEditMesh *em = BKE_editmesh_from_object(obedit);
+       BMesh *bm = em->bm;
 
-       BM_lnorspace_update(bm);
+       BKE_editmesh_lnorspace_update(em);
        LoopNormalData *ld = BM_loop_normal_init(bm);
 
        ld->funcdata = NULL;
@@ -6520,7 +6521,7 @@ static int split_merge_loop_normals(bContext *C, const 
bool do_merge)
        BMEdge *e;
        BMIter eiter;
 
-       BM_lnorspace_update(bm);
+       BKE_editmesh_lnorspace_update(em);
 
        LoopNormalData *ld = do_merge ? BM_loop_normal_init(bm) : NULL;
 
@@ -6537,7 +6538,7 @@ static int split_merge_loop_normals(bContext *C, const 
bool do_merge)
        }
 
        bm->spacearr_dirty |= BM_SPACEARR_DIRTY_ALL;
-       BM_lnorspace_update(bm);
+       BKE_editmesh_lnorspace_update(em);
 
        if (do_merge) {
                merge_loop(C, ld);
@@ -6620,7 +6621,7 @@ static int edbm_average_loop_normals_exec(bContext *C, 
wmOperator *op)
        BMIter fiter;
 
        bm->spacearr_dirty |= BM_SPACEARR_DIRTY_ALL;
-       BM_lnorspace_update(bm);
+       BKE_editmesh_lnorspace_update(em);
 
        const int average_type = RNA_enum_get(op->ptr, "average_type");
        int cd_clnors_offset = CustomData_get_offset(&bm->ldata, 
CD_CUSTOMLOOPNORMAL);
@@ -6813,7 +6814,7 @@ static int edbm_custom_normal_tools_exec(bContext *C, 
wmOperator *op)
        const int mode = RNA_enum_get(op->ptr, "mode");
        const bool absolute = RNA_boolean_get(op->ptr, "absolute");
 
-       BM_lnorspace_update(bm);
+       BKE_editmesh_lnorspace_update(em);
        LoopNormalData *ld = BM_loop_normal_init(bm);
        TransDataLoopNormal *tld = ld->normal;
 
@@ -6965,7 +6966,7 @@ static int edbm_set_normals_from_faces_exec(bContext *C, 
wmOperator *op)
 
        const bool keep_sharp = RNA_boolean_get(op->ptr, "keep_sharp");
 
-       BM_lnorspace_update(bm);
+       BKE_editmesh_lnorspace_update(em);
 
        float(*vnors)[3] = MEM_callocN(sizeof(*vnors) * bm->totvert, __func__);
        BM_ITER_MESH(f, &fiter, bm, BM_FACES_OF_MESH) {
@@ -7057,7 +7058,7 @@ static int edbm_smoothen_normals_exec(bContext *C, 
wmOperator *op)
        BMLoop *l;
        BMIter fiter, liter;
 
-       BM_lnorspace_update(bm);
+       BKE_editmesh_lnorspace_update(em);
        LoopNormalData *ld = BM_loop_normal_init(bm);
 
        float(*smooth_normal)[3] = MEM_callocN(sizeof(*smooth_normal) * 
ld->totloop, __func__);
diff --git a/source/blender/editors/transform/transform.c 
b/source/blender/editors/transform/transform.c
index a81e775e12c..60e79a046a0 100644
--- a/source/blender/editors/transform/transform.c
+++ b/source/blender/editors/transform/transform.c
@@ -2411,7 +2411,7 @@ bool initTransform(bContext *C, TransInfo *t, wmOperator 
*op, const wmEvent *eve
                        if (!all_select) {
                                const bool preserve_clnor = 
RNA_property_boolean_get(op->ptr, prop);
                                if (preserve_clnor) {
-                                       BM_lnorspace_update(em->bm);
+                                       BKE_editmesh_lnorspace_update(em);
                                        t->flag |= T_CLNOR_REBUILD;
                                }
                                BM_lnorspace_invalidate(em->bm, true);
@@ -4280,7 +4280,7 @@ static void initNormalRotation(TransInfo *t)
        BMEditMesh *em = BKE_editmesh_from_object(t->obedit);
        BMesh *bm = em->bm;
 
-       BM_lnorspace_update(bm);
+       BKE_editmesh_lnorspace_update(em);
 
        StoreCustomlnorValue(t, bm);
        
diff --git a/source/tools b/source/tools
index 7695e14cfc5..88a1758d2d2 160000
--- a/source/tools
+++ b/source/tools
@@ -1 +1 @@
-Subproject commit 7695e14cfc5820ac66546e0e515914d85ab81af3
+Subproject commit 88a1758d2d2e862cc69c08b5b40a4e75f71592d3

_______________________________________________
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to