diff options
author | Campbell Barton <ideasman42@gmail.com> | 2021-08-13 08:36:49 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2021-08-13 08:39:39 +0300 |
commit | 41e650981861c2f18ab0548e18851d1d761066ff (patch) | |
tree | f739cc70e57289fbaa47ef11e863b2e3cae2d18c /source/blender/blenkernel/intern/mesh_normals.cc | |
parent | 8fa05efe0a19126b44cc283232e05e0e53d6db84 (diff) |
Mesh: replace saacos with acosf for normal calculation
The clamped version of acos isn't needed as degenerate (nan) coordinates
result in zeroed vectors which don't need clamping.
Diffstat (limited to 'source/blender/blenkernel/intern/mesh_normals.cc')
-rw-r--r-- | source/blender/blenkernel/intern/mesh_normals.cc | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/source/blender/blenkernel/intern/mesh_normals.cc b/source/blender/blenkernel/intern/mesh_normals.cc index 9a761c6fa11..aae50fa165e 100644 --- a/source/blender/blenkernel/intern/mesh_normals.cc +++ b/source/blender/blenkernel/intern/mesh_normals.cc @@ -230,8 +230,10 @@ static void mesh_calc_normals_poly_and_vertex_accum_fn( copy_v3_v3(edvec_next, edvec_end); } - /* Calculate angle between the two poly edges incident on this vertex. */ - const float fac = saacos(-dot_v3v3(edvec_prev, edvec_next)); + /* Calculate angle between the two poly edges incident on this vertex. + * NOTE: no need for #saacos here as the input has been sanitized, + * `nan` values in coordinates normalize to zero which works for `acosf`. */ + const float fac = acosf(-dot_v3v3(edvec_prev, edvec_next)); const float vnor_add[3] = {pnor[0] * fac, pnor[1] * fac, pnor[2] * fac}; add_v3_v3_atomic(vnors[ml[i_curr].v], vnor_add); @@ -1156,9 +1158,11 @@ static void split_loop_nor_fan_do(LoopSplitTaskDataCommon *common_data, LoopSpli // printf("\thandling edge %d / loop %d\n", mlfan_curr->e, mlfan_curr_index); { - /* Code similar to accumulate_vertex_normals_poly_v3. */ - /* Calculate angle between the two poly edges incident on this vertex. */ - const float fac = saacos(dot_v3v3(vec_curr, vec_prev)); + /* Code similar to #accumulate_vertex_normals_poly_v3. */ + /* Calculate angle between the two poly edges incident on this vertex. + * NOTE: no need for #saacos here as the input has been sanitized, + * `nan` values in coordinates normalize to zero which works for `acosf`. */ + const float fac = acosf(dot_v3v3(vec_curr, vec_prev)); /* Accumulate */ madd_v3_v3fl(lnor, polynors[mpfan_curr_index], fac); |