Cleanup: Avoid passing redundant face index in normal calculation

The current face index can always be retrieved from the "loop_to_face"
map, so passing it around and updating it manually just adds more
state to track.
This commit is contained in:
Hans Goudey 2023-07-25 10:56:07 -04:00
parent 0e87e25b37
commit bd4be36894

@ -829,8 +829,7 @@ static void loop_manifold_fan_around_vert_next(const Span<int> corner_verts,
const int *e2lfan_curr,
const int vert_pivot,
int *r_mlfan_curr_index,
int *r_mlfan_vert_index,
int *r_mpfan_curr_index)
int *r_mlfan_vert_index)
{
const int mlfan_curr_orig = *r_mlfan_curr_index;
const int vert_fan_orig = corner_verts[mlfan_curr_orig];
@ -843,13 +842,11 @@ static void loop_manifold_fan_around_vert_next(const Span<int> corner_verts,
* mlfan_curr_index is the index of mlfan_next here, and mlfan_next is not the real next one
* (i.e. not the future `mlfan_curr`). */
*r_mlfan_curr_index = (e2lfan_curr[0] == *r_mlfan_curr_index) ? e2lfan_curr[1] : e2lfan_curr[0];
*r_mpfan_curr_index = loop_to_face[*r_mlfan_curr_index];
BLI_assert(*r_mlfan_curr_index >= 0);
BLI_assert(*r_mpfan_curr_index >= 0);
const int vert_fan_next = corner_verts[*r_mlfan_curr_index];
const IndexRange face_fan_next = faces[*r_mpfan_curr_index];
const IndexRange face_fan_next = faces[loop_to_face[*r_mlfan_curr_index]];
if ((vert_fan_orig == vert_fan_next && vert_fan_orig == vert_pivot) ||
!ELEM(vert_fan_orig, vert_fan_next, vert_pivot))
{
@ -961,11 +958,9 @@ static void split_loop_nor_fan_do(LoopSplitTaskDataCommon *common_data,
*/
int mlfan_curr_index = ml_prev_index;
int mlfan_vert_index = ml_curr_index;
int mpfan_curr_index = face_index;
BLI_assert(mlfan_curr_index >= 0);
BLI_assert(mlfan_vert_index >= 0);
BLI_assert(mpfan_curr_index >= 0);
/* Only need to compute previous edge's vector once, then we can just reuse old current one! */
{
@ -998,7 +993,7 @@ static void split_loop_nor_fan_do(LoopSplitTaskDataCommon *common_data,
/* Code similar to accumulate_vertex_normals_poly_v3. */
/* Calculate angle between the two face edges incident on this vertex. */
lnor += face_normals[mpfan_curr_index] * saacos(math::dot(vec_curr, vec_prev));
lnor += face_normals[loop_to_face[mlfan_curr_index]] * saacos(math::dot(vec_curr, vec_prev));
if (!clnors_data.is_empty()) {
/* Accumulate all clnors, if they are not all equal we have to fix that! */
@ -1040,8 +1035,7 @@ static void split_loop_nor_fan_do(LoopSplitTaskDataCommon *common_data,
edge_to_loops[corner_edges[mlfan_curr_index]],
vert_pivot,
&mlfan_curr_index,
&mlfan_vert_index,
&mpfan_curr_index);
&mlfan_vert_index);
}
float length;
@ -1099,8 +1093,7 @@ static bool loop_split_generator_check_cyclic_smooth_fan(const Span<int> corner_
const int *e2l_prev,
MutableBitSpan skip_loops,
const int ml_curr_index,
const int ml_prev_index,
const int mp_curr_index)
const int ml_prev_index)
{
/* The vertex we are "fanning" around. */
const int vert_pivot = corner_verts[ml_curr_index];
@ -1115,11 +1108,9 @@ static bool loop_split_generator_check_cyclic_smooth_fan(const Span<int> corner_
*/
int mlfan_curr_index = ml_prev_index;
int mlfan_vert_index = ml_curr_index;
int mpfan_curr_index = mp_curr_index;
BLI_assert(mlfan_curr_index >= 0);
BLI_assert(mlfan_vert_index >= 0);
BLI_assert(mpfan_curr_index >= 0);
BLI_assert(!skip_loops[mlfan_vert_index]);
skip_loops[mlfan_vert_index].set();
@ -1132,8 +1123,7 @@ static bool loop_split_generator_check_cyclic_smooth_fan(const Span<int> corner_
e2lfan_curr,
vert_pivot,
&mlfan_curr_index,
&mlfan_vert_index,
&mpfan_curr_index);
&mlfan_vert_index);
e2lfan_curr = edge_to_loops[corner_edges[mlfan_curr_index]];
@ -1211,8 +1201,7 @@ static void loop_split_generator(LoopSplitTaskDataCommon *common_data,
edge_to_loops[corner_edges[ml_prev_index]],
skip_loops,
ml_curr_index,
ml_prev_index,
face_index)))
ml_prev_index)))
{
// printf("SKIPPING!\n");
}