[Bf-blender-cvs] [95df7aa7ce6] temp-geometry-nodes-extrude-mesh: Cleanup: Rename variables, add comment

Hans Goudey noreply at git.blender.org
Fri Jan 21 05:18:50 CET 2022


Commit: 95df7aa7ce6edc7aa14dcaa5165ba4a184bf7d87
Author: Hans Goudey
Date:   Thu Jan 20 22:18:44 2022 -0600
Branches: temp-geometry-nodes-extrude-mesh
https://developer.blender.org/rB95df7aa7ce6edc7aa14dcaa5165ba4a184bf7d87

Cleanup: Rename variables, add comment

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

M	source/blender/nodes/geometry/nodes/node_geo_extrude_mesh.cc

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

diff --git a/source/blender/nodes/geometry/nodes/node_geo_extrude_mesh.cc b/source/blender/nodes/geometry/nodes/node_geo_extrude_mesh.cc
index 93b603c01e4..f15af6e4269 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_extrude_mesh.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_extrude_mesh.cc
@@ -424,15 +424,13 @@ static void extrude_mesh_edges(MeshComponent &component,
     return;
   }
 
-  const VectorSet<int> new_vert_orig_indices = vert_indices_from_edges(mesh,
-                                                                       edge_selection.indices());
+  const VectorSet<int> new_vert_indices = vert_indices_from_edges(mesh, edge_selection.indices());
 
-  const IndexRange new_vert_range{orig_vert_size, new_vert_orig_indices.size()};
+  const IndexRange new_vert_range{orig_vert_size, new_vert_indices.size()};
   /* The extruded edges connect the original and duplicate edges. */
   const IndexRange connect_edge_range{orig_edges.size(), new_vert_range.size()};
   /* The duplicate edges are extruded copies of the selected edges. */
-  const IndexRange duplicate_edge_range{connect_edge_range.one_after_last(),
-                                        edge_selection.size()};
+  const IndexRange boundary_edge_range{connect_edge_range.one_after_last(), edge_selection.size()};
   /* There is a new polygon for every selected edge. */
   const IndexRange new_poly_range{orig_polys.size(), edge_selection.size()};
   /* Every new polygon is a quad with four corners. */
@@ -442,26 +440,26 @@ static void extrude_mesh_edges(MeshComponent &component,
 
   expand_mesh_size(mesh,
                    new_vert_range.size(),
-                   connect_edge_range.size() + duplicate_edge_range.size(),
+                   connect_edge_range.size() + boundary_edge_range.size(),
                    new_poly_range.size(),
                    new_loop_range.size());
 
   MutableSpan<MVert> new_verts = mesh_verts(mesh).slice(new_vert_range);
   MutableSpan<MEdge> connect_edges = mesh_edges(mesh).slice(connect_edge_range);
-  MutableSpan<MEdge> duplicate_edges = mesh_edges(mesh).slice(duplicate_edge_range);
+  MutableSpan<MEdge> duplicate_edges = mesh_edges(mesh).slice(boundary_edge_range);
   MutableSpan<MPoly> polys = mesh_polys(mesh);
   MutableSpan<MPoly> new_polys = polys.slice(new_poly_range);
   MutableSpan<MLoop> loops = mesh_loops(mesh);
   MutableSpan<MLoop> new_loops = loops.slice(new_loop_range);
 
   for (const int i : connect_edges.index_range()) {
-    connect_edges[i] = new_edge(new_vert_orig_indices[i], new_vert_range[i]);
+    connect_edges[i] = new_edge(new_vert_indices[i], new_vert_range[i]);
   }
 
   for (const int i : duplicate_edges.index_range()) {
     const MEdge &orig_edge = mesh.medge[edge_selection[i]];
-    const int i_new_vert_1 = new_vert_orig_indices.index_of(orig_edge.v1);
-    const int i_new_vert_2 = new_vert_orig_indices.index_of(orig_edge.v2);
+    const int i_new_vert_1 = new_vert_indices.index_of(orig_edge.v1);
+    const int i_new_vert_2 = new_vert_indices.index_of(orig_edge.v2);
     duplicate_edges[i] = new_edge(new_vert_range[i_new_vert_1], new_vert_range[i_new_vert_2]);
   }
 
@@ -490,13 +488,13 @@ static void extrude_mesh_edges(MeshComponent &component,
     }
     fill_quad_consistent_direction(connected_poly_loops,
                                    new_loops.slice(4 * i, 4),
-                                   new_vert_orig_indices[extrude_index_1],
-                                   new_vert_orig_indices[extrude_index_2],
+                                   new_vert_indices[extrude_index_1],
+                                   new_vert_indices[extrude_index_2],
                                    new_vert_1,
                                    new_vert_2,
                                    orig_edge_index,
                                    connect_edge_range[extrude_index_1],
-                                   duplicate_edge_range[i],
+                                   boundary_edge_range[i],
                                    connect_edge_range[extrude_index_2]);
   }
 
@@ -519,12 +517,12 @@ static void extrude_mesh_edges(MeshComponent &component,
       switch (attribute.domain()) {
         case ATTR_DOMAIN_POINT: {
           /* New vertices copy the attribute values from their source vertex. */
-          copy_with_indices(data.slice(new_vert_range), data.as_span(), new_vert_orig_indices);
+          copy_with_indices(data.slice(new_vert_range), data.as_span(), new_vert_indices);
           break;
         }
         case ATTR_DOMAIN_EDGE: {
           /* Edges parallel to original edges copy the edge attributes from the original edges. */
-          MutableSpan<T> duplicate_data = data.slice(duplicate_edge_range);
+          MutableSpan<T> duplicate_data = data.slice(boundary_edge_range);
           copy_with_mask(duplicate_data, data.as_span(), edge_selection);
 
           /* Edges connected to original vertices mix values of selected connected edges. */
@@ -567,8 +565,8 @@ static void extrude_mesh_edges(MeshComponent &component,
               const MEdge &duplicate_edge = duplicate_edges[i_edge_selection];
               const int new_vert_1 = duplicate_edge.v1;
               const int new_vert_2 = duplicate_edge.v2;
-              const int orig_vert_1 = new_vert_orig_indices[new_vert_1 - orig_vert_size];
-              const int orig_vert_2 = new_vert_orig_indices[new_vert_2 - orig_vert_size];
+              const int orig_vert_1 = new_vert_indices[new_vert_1 - orig_vert_size];
+              const int orig_vert_2 = new_vert_indices[new_vert_2 - orig_vert_size];
 
               /* Average the corner data from the corners that share a vertex from the
                * polygons that share an edge with the extruded edge. */
@@ -640,7 +638,7 @@ static void extrude_mesh_edges(MeshComponent &component,
 
   if (attribute_outputs.top_id) {
     save_selection_as_attribute(
-        component, attribute_outputs.top_id.get(), ATTR_DOMAIN_EDGE, duplicate_edge_range);
+        component, attribute_outputs.top_id.get(), ATTR_DOMAIN_EDGE, boundary_edge_range);
   }
   if (attribute_outputs.side_id) {
     save_selection_as_attribute(
@@ -720,10 +718,12 @@ static void extrude_mesh_face_regions(MeshComponent &component,
 
   /* These edges are on top of an extruded region. Their vertices should be translated with the
    * offset, but the edges themselves should not be duplicated. */
-  Vector<int> in_between_edges;
+  Vector<int> inner_edge_indices;
   /* The extruded face corresponding to each extruded edge (and each extruded face). */
-  Vector<int> edge_orig_face_indices;
-  VectorSet<int> boundary_edge_orig_indices;
+  Vector<int> edge_extruded_face_indices;
+  /* Edges on the outside of selected regions, either because there are no
+   * other connected faces, or because all of the other faces aren't selected. */
+  VectorSet<int> boundary_edge_indices;
   for (const int i_edge : orig_edges.index_range()) {
     Span<int> polys = edge_to_poly_map[i_edge];
 
@@ -741,25 +741,25 @@ static void extrude_mesh_face_regions(MeshComponent &component,
     }
 
     if (selected_poly_count == 1) {
-      boundary_edge_orig_indices.add_new(i_edge);
-      edge_orig_face_indices.append(i_selected_poly);
+      boundary_edge_indices.add_new(i_edge);
+      edge_extruded_face_indices.append(i_selected_poly);
     }
     else if (selected_poly_count > 1) {
-      in_between_edges.append(i_edge);
+      inner_edge_indices.append(i_edge);
     }
   }
 
-  const VectorSet<int> new_vert_orig_indices = vert_indices_from_edges(
-      mesh, boundary_edge_orig_indices.as_span());
+  const VectorSet<int> new_vert_indices = vert_indices_from_edges(mesh,
+                                                                  boundary_edge_indices.as_span());
 
-  const IndexRange new_vert_range{orig_vert_size, new_vert_orig_indices.size()};
+  const IndexRange new_vert_range{orig_vert_size, new_vert_indices.size()};
   /* One edge connects each selected vertex to a new vertex on the extruded polygons. */
   const IndexRange connect_edge_range{orig_edges.size(), new_vert_range.size()};
   /* Each selected edge is duplicated to form a single edge on the extrusion. */
   const IndexRange duplicate_edge_range{connect_edge_range.one_after_last(),
-                                        boundary_edge_orig_indices.size()};
+                                        boundary_edge_indices.size()};
   /* Each edge selected for extrusion is extruded into a single face. */
-  const IndexRange side_poly_range{orig_polys.size(), boundary_edge_orig_indices.size()};
+  const IndexRange side_poly_range{orig_polys.size(), boundary_edge_indices.size()};
   const IndexRange side_loop_range{orig_loops.size(), side_poly_range.size() * 4};
 
   expand_mesh_size(mesh,
@@ -778,14 +778,14 @@ static void extrude_mesh_face_regions(MeshComponent &component,
 
   /* Initialize the edges that form the sides of the extrusion. */
   for (const int i : connect_edges.index_range()) {
-    connect_edges[i] = new_edge(new_vert_orig_indices[i], new_vert_range[i]);
+    connect_edges[i] = new_edge(new_vert_indices[i], new_vert_range[i]);
   }
 
   /* Initialize the edges that form the top of the extrusion. */
   for (const int i : boundary_edges.index_range()) {
-    const MEdge &orig_edge = edges[boundary_edge_orig_indices[i]];
-    const int i_new_vert_1 = new_vert_orig_indices.index_of(orig_edge.v1);
-    const int i_new_vert_2 = new_vert_orig_indices.index_of(orig_edge.v2);
+    const MEdge &orig_edge = edges[boundary_edge_indices[i]];
+    const int i_new_vert_1 = new_vert_indices.index_of(orig_edge.v1);
+    const int i_new_vert_2 = new_vert_indices.index_of(orig_edge.v2);
     boundary_edges[i] = new_edge(new_vert_range[i_new_vert_1], new_vert_range[i_new_vert_2]);
   }
 
@@ -795,10 +795,10 @@ static void extrude_mesh_face_regions(MeshComponent &component,
   }
 
   /* Connect original edges that are in between two selected faces to the new vertices. */
-  for (const int i : in_between_edges) {
+  for (const int i : inner_edge_indices) {
     MEdge &edge = edges[i];
-    const int i_new_vert_1 = new_vert_orig_indices.index_of_try(edge.v1);
-    const

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list