[Bf-blender-cvs] [8f773072a97] refactor-mesh-corners-generic: Merge branch 'refactor-mesh-position-generic' into refactor-mesh-corners-generic

Hans Goudey noreply at git.blender.org
Mon Dec 12 15:50:59 CET 2022


Commit: 8f773072a97f021e41e415ee8947b17491743bfe
Author: Hans Goudey
Date:   Sun Dec 11 23:56:50 2022 -0600
Branches: refactor-mesh-corners-generic
https://developer.blender.org/rB8f773072a97f021e41e415ee8947b17491743bfe

Merge branch 'refactor-mesh-position-generic' into refactor-mesh-corners-generic

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



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

diff --cc source/blender/blenkernel/BKE_mesh_mapping.h
index 34194f901e9,fd68adc2584..948cd1027ec
--- a/source/blender/blenkernel/BKE_mesh_mapping.h
+++ b/source/blender/blenkernel/BKE_mesh_mapping.h
@@@ -351,14 -349,12 +351,14 @@@ namespace blender::bke::mesh_topology 
  Array<int> build_loop_to_poly_map(Span<MPoly> polys, int loops_num);
  
  Array<Vector<int>> build_vert_to_edge_map(Span<MEdge> edges, int verts_num);
 -Array<Vector<int>> build_vert_to_poly_map(Span<MPoly> polys, Span<MLoop> loops, int verts_num);
 -Array<Vector<int>> build_vert_to_loop_map(Span<MLoop> loops, int verts_num);
 -Array<Vector<int>> build_edge_to_loop_map(Span<MLoop> loops, int edges_num);
 -Vector<Vector<int>> build_edge_to_loop_map_resizable(Span<MLoop> loops, int edges_num);
 +Array<Vector<int>> build_vert_to_poly_map(Span<MPoly> polys,
 +                                          Span<int> corner_verts,
 +                                          int verts_num);
 +Array<Vector<int>> build_vert_to_loop_map(Span<int> corner_verts, int verts_num);
 +Array<Vector<int>> build_edge_to_loop_map(Span<int> corner_edges, int edges_num);
 +Vector<Vector<int>> build_edge_to_loop_map_resizable(Span<int> corner_edges, int edges_num);
  
- inline int previous_poly_loop(const MPoly &poly, int loop_i)
+ inline int poly_loop_prev(const MPoly &poly, int loop_i)
  {
    return loop_i - 1 + (loop_i == poly.loopstart) * poly.totloop;
  }
diff --cc source/blender/blenkernel/intern/geometry_component_mesh.cc
index eb7a0c39817,a482f56a178..9558be4f09d
--- a/source/blender/blenkernel/intern/geometry_component_mesh.cc
+++ b/source/blender/blenkernel/intern/geometry_component_mesh.cc
@@@ -605,11 -618,11 +605,11 @@@ void adapt_mesh_domain_edge_to_corner_i
  
      /* For every corner, mix the values from the adjacent edges on the face. */
      for (const int loop_index : IndexRange(poly.loopstart, poly.totloop)) {
-       const int loop_index_prev = mesh_topology::previous_poly_loop(poly, loop_index);
+       const int loop_index_prev = mesh_topology::poly_loop_prev(poly, loop_index);
 -      const MLoop &loop = loops[loop_index];
 -      const MLoop &loop_prev = loops[loop_index_prev];
 -      mixer.mix_in(loop_index, old_values[loop.e]);
 -      mixer.mix_in(loop_index, old_values[loop_prev.e]);
 +      const int edge_i = corner_edges[loop_index];
 +      const int edge_i_prev = corner_edges[loop_index_prev];
 +      mixer.mix_in(loop_index, old_values[edge_i]);
 +      mixer.mix_in(loop_index, old_values[edge_i_prev]);
      }
    }
  
@@@ -632,10 -645,10 +632,10 @@@ void adapt_mesh_domain_edge_to_corner_i
      for (const int poly_index : range) {
        const MPoly &poly = polys[poly_index];
        for (const int loop_index : IndexRange(poly.loopstart, poly.totloop)) {
-         const int loop_index_prev = mesh_topology::previous_poly_loop(poly, loop_index);
+         const int loop_index_prev = mesh_topology::poly_loop_prev(poly, loop_index);
 -        const MLoop &loop = loops[loop_index];
 -        const MLoop &loop_prev = loops[loop_index_prev];
 -        if (old_values[loop.e] && old_values[loop_prev.e]) {
 +        const int edge_i = corner_edges[loop_index];
 +        const int edge_i_prev = corner_edges[loop_index_prev];
 +        if (old_values[edge_i] && old_values[edge_i_prev]) {
            r_values[loop_index] = true;
          }
        }
diff --cc source/blender/blenkernel/intern/mesh_normals.cc
index 3569c7b3a1d,9bfe1f8d8c1..02f81ae98c9
--- a/source/blender/blenkernel/intern/mesh_normals.cc
+++ b/source/blender/blenkernel/intern/mesh_normals.cc
@@@ -773,10 -772,9 +772,10 @@@ struct LoopSplitTaskDataCommon 
    /* Read-only. */
    Span<float3> positions;
    Span<MEdge> edges;
 -  Span<MLoop> loops;
 +  Span<int> corner_verts;
 +  Span<int> corner_edges;
    Span<MPoly> polys;
-   MutableSpan<int2> edge_to_loops;
+   Span<int2> edge_to_loops;
    Span<int> loop_to_poly;
    Span<float3> polynors;
    Span<float3> vert_normals;
@@@ -910,7 -905,8 +909,8 @@@ static void loop_manifold_fan_around_ve
                                                 int *r_mlfan_vert_index,
                                                 int *r_mpfan_curr_index)
  {
-   const int fan_vert_curr = corner_verts[*r_mlfan_curr_index];
+   const int mlfan_curr_orig = *r_mlfan_curr_index;
 -  const uint vert_fan_orig = loops[mlfan_curr_orig].v;
++  const uint vert_fan_orig = corner_verts[mlfan_curr_orig];
  
    /* WARNING: This is rather complex!
     * We have to find our next edge around the vertex (fan mode).
@@@ -925,12 -921,10 +925,10 @@@
    BLI_assert(*r_mlfan_curr_index >= 0);
    BLI_assert(*r_mpfan_curr_index >= 0);
  
-   const int fan_vert_next = corner_verts[*r_mlfan_curr_index];
- 
 -  const uint vert_fan_next = loops[*r_mlfan_curr_index].v;
++  const uint vert_fan_next = corner_verts[*r_mlfan_curr_index];
    const MPoly &mpfan_next = polys[*r_mpfan_curr_index];
- 
-   if ((fan_vert_curr == fan_vert_next && fan_vert_curr == mv_pivot_index) ||
-       (fan_vert_curr != fan_vert_next && fan_vert_curr != mv_pivot_index)) {
+   if ((vert_fan_orig == vert_fan_next && vert_fan_orig == mv_pivot_index) ||
+       (vert_fan_orig != vert_fan_next && vert_fan_orig != mv_pivot_index)) {
      /* We need the previous loop, but current one is our vertex's loop. */
      *r_mlfan_vert_index = *r_mlfan_curr_index;
      if (--(*r_mlfan_curr_index) < mpfan_next.loopstart) {
@@@ -953,18 -947,13 +951,14 @@@ static void split_loop_nor_single_do(Lo
  
    const Span<float3> positions = common_data->positions;
    const Span<MEdge> edges = common_data->edges;
-   const Span<float3> polynors = common_data->polynors;
 -  const Span<MLoop> loops = common_data->loops;
 +  const Span<int> corner_verts = common_data->corner_verts;
 +  const Span<int> corner_edges = common_data->corner_edges;
+   const Span<float3> polynors = common_data->polynors;
+   MutableSpan<float3> loop_normals = common_data->loopnors;
  
    MLoopNorSpace *lnor_space = data->lnor_space;
-   float3 *lnor = data->lnor;
    const int ml_curr_index = data->ml_curr_index;
-   const int ml_prev_index = data->ml_curr_index;
- #if 0 /* Not needed for 'single' loop. */
    const int ml_prev_index = data->ml_prev_index;
-   const int *e2l_prev = data->e2l_prev;
- #endif
    const int mp_index = data->mp_index;
  
    /* Simple case (both edges around that vertex are sharp in current polygon),
@@@ -984,22 -973,18 +978,19 @@@
    if (lnors_spacearr) {
      float vec_curr[3], vec_prev[3];
  
-     /* The vertex we are "fanning" around! */
-     const int mv_pivot_index = corner_verts[ml_curr_index];
-     const float3 &mv_pivot = positions[mv_pivot_index];
 -    const uint mv_pivot_index = loops[ml_curr_index].v; /* The vertex we are "fanning" around! */
 -    const MEdge *me_curr = &edges[loops[ml_curr_index].e];
++    const uint mv_pivot_index =
++        corner_verts[ml_curr_index]; /* The vertex we are "fanning" around! */
 +    const MEdge *me_curr = &edges[corner_edges[ml_curr_index]];
-     const float3 &mv_2 = (me_curr->v1 == mv_pivot_index) ? positions[me_curr->v2] :
-                                                            positions[me_curr->v1];
+     const int vert_2 = me_curr->v1 == mv_pivot_index ? me_curr->v2 : me_curr->v1;
 -    const MEdge *me_prev = &edges[loops[ml_prev_index].e];
 +    const MEdge *me_prev = &edges[corner_edges[ml_prev_index]];
-     const float3 &mv_3 = (me_prev->v1 == mv_pivot_index) ? positions[me_prev->v2] :
-                                                            positions[me_prev->v1];
+     const int vert_3 = me_prev->v1 == mv_pivot_index ? me_prev->v2 : me_prev->v1;
  
-     sub_v3_v3v3(vec_curr, mv_2, mv_pivot);
+     sub_v3_v3v3(vec_curr, positions[vert_2], positions[mv_pivot_index]);
      normalize_v3(vec_curr);
-     sub_v3_v3v3(vec_prev, mv_3, mv_pivot);
+     sub_v3_v3v3(vec_prev, positions[vert_3], positions[mv_pivot_index]);
      normalize_v3(vec_prev);
  
-     BKE_lnor_space_define(lnor_space, *lnor, vec_curr, vec_prev, nullptr);
+     BKE_lnor_space_define(lnor_space, loop_normals[ml_curr_index], vec_curr, vec_prev, nullptr);
      /* We know there is only one loop in this space, no need to create a link-list in this case. */
      BKE_lnor_space_add_loop(lnors_spacearr, lnor_space, ml_curr_index, nullptr, true);
  
@@@ -1041,11 -1025,10 +1032,11 @@@ static void split_loop_nor_fan_do(LoopS
     * same as the vertex normal, but I do not see any easy way to detect that (would need to count
     * number of sharp edges per vertex, I doubt the additional memory usage would be worth it,
     * especially as it should not be a common case in real-life meshes anyway). */
-   const int mv_pivot_index = corner_verts[ml_curr_index]; /* The vertex we are "fanning" around! */
-   const float3 &mv_pivot = positions[mv_pivot_index];
 -  const uint mv_pivot_index = loops[ml_curr_index].v; /* The vertex we are "fanning" around! */
++  const uint mv_pivot_index =
++      corner_verts[ml_curr_index]; /* The vertex we are "fanning" around! */
  
-   /* `ml_curr` would be mlfan_prev if we needed that one. */
+   /* `ml_curr_index` would be mlfan_prev if we needed that one. */
 -  const MEdge *me_org = &edges[loops[ml_curr_index].e];
 +  const MEdge *me_org = &edges[corner_edges[ml_curr_index]];
  
    float vec_curr[3], vec_prev[3], vec_org[3];
    float lnor[3] = {0.0f, 0.0f, 0.0f};
@@@ -1141,7 -1123,7 +1131,7 @@@
        }
      }
  
-     if (IS_EDGE_SHARP(e2lfan_curr) || (me_curr == me_org)) {
 -    if (IS_EDGE_SHARP(edge_to_loops[loops[mlfan_curr_index].e]) || (me_curr == me_org)) {
++    if (IS_EDGE_SHARP(edge_to_loops[corner_edges[mlfan_curr_index]]) || (me_curr == me_org)) {
        /* Current edge is sharp and we have finished with this fan of faces around this vert,
         * or this vert is smooth, and we have completed a full turn around it. */
        // printf("FAN: Finished!\n");
@@@ -1151,10 -1133,10 +1141,10 @@@
      copy_v3_v3(vec_prev, vec_curr);
  
      /* Find next loop of the smooth fan. */
 -    loop_manifold_fan_around_vert_next(loops,
 +    loop_manifold_fan_around_vert_next(corner_verts,
                                         polys,
                                      

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list