[Bf-blender-cvs] [ba523bd010a] master: Cleanup: Reduce indentation in corner normal calculation
Hans Goudey
noreply at git.blender.org
Thu Dec 8 22:14:43 CET 2022
Commit: ba523bd010a80537ddc5ca516ea21110a8f4a4e6
Author: Hans Goudey
Date: Thu Dec 8 14:48:28 2022 -0600
Branches: master
https://developer.blender.org/rBba523bd010a80537ddc5ca516ea21110a8f4a4e6
Cleanup: Reduce indentation in corner normal calculation
===================================================================
M source/blender/blenkernel/intern/mesh_normals.cc
===================================================================
diff --git a/source/blender/blenkernel/intern/mesh_normals.cc b/source/blender/blenkernel/intern/mesh_normals.cc
index 900785ace5c..c6faedf2531 100644
--- a/source/blender/blenkernel/intern/mesh_normals.cc
+++ b/source/blender/blenkernel/intern/mesh_normals.cc
@@ -1799,70 +1799,71 @@ static void mesh_normals_loop_custom_set(const MVert *mverts,
}
continue;
}
+ if (done_loops[i]) {
+ continue;
+ }
- if (!done_loops[i]) {
- /* Notes:
- * - In case of mono-loop smooth fan, we have nothing to do.
- * - Loops in this linklist are ordered (in reversed order compared to how they were
- * discovered by BKE_mesh_normals_loop_split(), but this is not a problem).
- * Which means if we find a mismatching clnor,
- * we know all remaining loops will have to be in a new, different smooth fan/lnor space.
- * - In smooth fan case, we compare each clnor against a ref one,
- * to avoid small differences adding up into a real big one in the end!
- */
- if (lnors_spacearr.lspacearr[i]->flags & MLNOR_SPACE_IS_SINGLE) {
- done_loops[i].set();
- continue;
- }
-
- LinkNode *loops = lnors_spacearr.lspacearr[i]->loops;
- const MLoop *prev_ml = nullptr;
- const float *org_nor = nullptr;
+ /* Notes:
+ * - In case of mono-loop smooth fan, we have nothing to do.
+ * - Loops in this linklist are ordered (in reversed order compared to how they were
+ * discovered by BKE_mesh_normals_loop_split(), but this is not a problem).
+ * Which means if we find a mismatching clnor,
+ * we know all remaining loops will have to be in a new, different smooth fan/lnor space.
+ * - In smooth fan case, we compare each clnor against a ref one,
+ * to avoid small differences adding up into a real big one in the end!
+ */
+ if (lnors_spacearr.lspacearr[i]->flags & MLNOR_SPACE_IS_SINGLE) {
+ done_loops[i].set();
+ continue;
+ }
- while (loops) {
- const int lidx = POINTER_AS_INT(loops->link);
- const MLoop *ml = &mloops[lidx];
- const int nidx = lidx;
- float *nor = r_custom_loopnors[nidx];
+ LinkNode *loops = lnors_spacearr.lspacearr[i]->loops;
+ const MLoop *prev_ml = nullptr;
+ const float *org_nor = nullptr;
- if (!org_nor) {
- org_nor = nor;
- }
- else if (dot_v3v3(org_nor, nor) < LNOR_SPACE_TRIGO_THRESHOLD) {
- /* Current normal differs too much from org one, we have to tag the edge between
- * previous loop's face and current's one as sharp.
- * We know those two loops do not point to the same edge,
- * since we do not allow reversed winding in a same smooth fan. */
- const MPoly *mp = &mpolys[loop_to_poly[lidx]];
- const MLoop *mlp =
- &mloops[(lidx == mp->loopstart) ? mp->loopstart + mp->totloop - 1 : lidx - 1];
- medges[(prev_ml->e == mlp->e) ? prev_ml->e : ml->e].flag |= ME_SHARP;
-
- org_nor = nor;
- }
+ while (loops) {
+ const int lidx = POINTER_AS_INT(loops->link);
+ const MLoop *ml = &mloops[lidx];
+ const int nidx = lidx;
+ float *nor = r_custom_loopnors[nidx];
- prev_ml = ml;
- loops = loops->next;
- done_loops[lidx].set();
+ if (!org_nor) {
+ org_nor = nor;
+ }
+ else if (dot_v3v3(org_nor, nor) < LNOR_SPACE_TRIGO_THRESHOLD) {
+ /* Current normal differs too much from org one, we have to tag the edge between
+ * previous loop's face and current's one as sharp.
+ * We know those two loops do not point to the same edge,
+ * since we do not allow reversed winding in a same smooth fan. */
+ const MPoly *mp = &mpolys[loop_to_poly[lidx]];
+ const MLoop *mlp =
+ &mloops[(lidx == mp->loopstart) ? mp->loopstart + mp->totloop - 1 : lidx - 1];
+ medges[(prev_ml->e == mlp->e) ? prev_ml->e : ml->e].flag |= ME_SHARP;
+
+ org_nor = nor;
}
- /* We also have to check between last and first loops,
- * otherwise we may miss some sharp edges here!
- * This is just a simplified version of above while loop.
- * See T45984. */
- loops = lnors_spacearr.lspacearr[i]->loops;
- if (loops && org_nor) {
- const int lidx = POINTER_AS_INT(loops->link);
- const MLoop *ml = &mloops[lidx];
- const int nidx = lidx;
- float *nor = r_custom_loopnors[nidx];
+ prev_ml = ml;
+ loops = loops->next;
+ done_loops[lidx].set();
+ }
- if (dot_v3v3(org_nor, nor) < LNOR_SPACE_TRIGO_THRESHOLD) {
- const MPoly *mp = &mpolys[loop_to_poly[lidx]];
- const MLoop *mlp =
- &mloops[(lidx == mp->loopstart) ? mp->loopstart + mp->totloop - 1 : lidx - 1];
- medges[(prev_ml->e == mlp->e) ? prev_ml->e : ml->e].flag |= ME_SHARP;
- }
+ /* We also have to check between last and first loops,
+ * otherwise we may miss some sharp edges here!
+ * This is just a simplified version of above while loop.
+ * See T45984. */
+ loops = lnors_spacearr.lspacearr[i]->loops;
+ if (loops && org_nor) {
+ const int lidx = POINTER_AS_INT(loops->link);
+ const MLoop *ml = &mloops[lidx];
+ const int nidx = lidx;
+ float *nor = r_custom_loopnors[nidx];
+
+ if (dot_v3v3(org_nor, nor) < LNOR_SPACE_TRIGO_THRESHOLD) {
+ const MPoly *mp = &mpolys[loop_to_poly[lidx]];
+ const MLoop *mlp =
+ &mloops[(lidx == mp->loopstart) ? mp->loopstart + mp->totloop - 1 : lidx - 1];
+ medges[(prev_ml->e == mlp->e) ? prev_ml->e : ml->e].flag |= ME_SHARP;
}
}
}
More information about the Bf-blender-cvs
mailing list