[Bf-blender-cvs] [4b068c4d6f9] master: Cleanup: clnor code: more 'do not use same varname for two different things'.

Bastien Montagne noreply at git.blender.org
Thu Feb 22 15:20:52 CET 2018


Commit: 4b068c4d6f960e0a4da7e252c1d69743e282362f
Author: Bastien Montagne
Date:   Thu Feb 22 10:35:08 2018 +0100
Branches: master
https://developer.blender.org/rB4b068c4d6f960e0a4da7e252c1d69743e282362f

Cleanup: clnor code: more 'do not use same varname for two different things'.

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

M	source/blender/blenkernel/intern/mesh_evaluate.c
M	source/blender/bmesh/intern/bmesh_mesh.c

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

diff --git a/source/blender/blenkernel/intern/mesh_evaluate.c b/source/blender/blenkernel/intern/mesh_evaluate.c
index 8ec93ce6a09..528a1c0f552 100644
--- a/source/blender/blenkernel/intern/mesh_evaluate.c
+++ b/source/blender/blenkernel/intern/mesh_evaluate.c
@@ -1318,6 +1318,7 @@ void BKE_mesh_normals_loop_split(
 
 	/* When using custom loop normals, disable the angle feature! */
 	const bool check_angle = (split_angle < (float)M_PI) && (clnors_data == NULL);
+	const float split_angle_cos = check_angle ? cosf(split_angle) : -1.0f;
 
 	MLoopNorSpaceArray _lnors_spacearr = {NULL};
 
@@ -1325,8 +1326,6 @@ void BKE_mesh_normals_loop_split(
 	TIMEIT_START_AVERAGED(BKE_mesh_normals_loop_split);
 #endif
 
-	const float split_angle_cos = check_angle ? cosf(split_angle) : -1.0f;
-
 	if (!r_lnors_spacearr && clnors_data) {
 		/* We need to compute lnor spacearr if some custom lnor data are given to us! */
 		r_lnors_spacearr = &_lnors_spacearr;
diff --git a/source/blender/bmesh/intern/bmesh_mesh.c b/source/blender/bmesh/intern/bmesh_mesh.c
index 67db51446df..2eb9c1c6597 100644
--- a/source/blender/bmesh/intern/bmesh_mesh.c
+++ b/source/blender/bmesh/intern/bmesh_mesh.c
@@ -524,7 +524,7 @@ void BM_verts_calc_normal_vcos(BMesh *bm, const float (*fnos)[3], const float (*
  * Helpers for #BM_mesh_loop_normals_update and #BM_loops_calc_normals_vnos
  */
 static void bm_mesh_edges_sharp_tag(
-        BMesh *bm, const float (*vnos)[3], const float (*fnos)[3], float split_angle,
+        BMesh *bm, const float (*vnos)[3], const float (*fnos)[3], const float split_angle,
         float (*r_lnos)[3])
 {
 	BMIter eiter;
@@ -532,10 +532,7 @@ static void bm_mesh_edges_sharp_tag(
 	int i;
 
 	const bool check_angle = (split_angle < (float)M_PI);
-
-	if (check_angle) {
-		split_angle = cosf(split_angle);
-	}
+	const float split_angle_cos = check_angle ? cosf(split_angle) : -1.0f;
 
 	{
 		char htype = BM_VERT | BM_LOOP;
@@ -560,7 +557,7 @@ static void bm_mesh_edges_sharp_tag(
 			if (check_angle) {
 				const float *no_a = fnos ? fnos[BM_elem_index_get(l_a->f)] : l_a->f->no;
 				const float *no_b = fnos ? fnos[BM_elem_index_get(l_b->f)] : l_b->f->no;
-				is_angle_smooth = (dot_v3v3(no_a, no_b) >= split_angle);
+				is_angle_smooth = (dot_v3v3(no_a, no_b) >= split_angle_cos);
 			}
 
 			/* We only tag edges that are *really* smooth:



More information about the Bf-blender-cvs mailing list