[Bf-blender-cvs] [7df5695ce72] temp-T97352-3d-texturing-seam-bleeding-b2: Updated comments (c-style comments).

Jeroen Bakker noreply at git.blender.org
Mon Oct 10 13:29:19 CEST 2022


Commit: 7df5695ce723de700c6ded9c042f9d977ef33f0b
Author: Jeroen Bakker
Date:   Mon Oct 10 13:28:45 2022 +0200
Branches: temp-T97352-3d-texturing-seam-bleeding-b2
https://developer.blender.org/rB7df5695ce723de700c6ded9c042f9d977ef33f0b

Updated comments (c-style comments).

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

M	source/blender/blenkernel/intern/pbvh_uv_islands.cc
M	source/blender/blenkernel/intern/pbvh_uv_islands.hh
M	source/blender/blenlib/BLI_vector_list.hh

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

diff --git a/source/blender/blenkernel/intern/pbvh_uv_islands.cc b/source/blender/blenkernel/intern/pbvh_uv_islands.cc
index a2940a6c46a..7a06de4dad3 100644
--- a/source/blender/blenkernel/intern/pbvh_uv_islands.cc
+++ b/source/blender/blenkernel/intern/pbvh_uv_islands.cc
@@ -531,7 +531,6 @@ struct InnerEdge {
   }
 };
 
-// TODO: should have InnerEdges and Primitives to reduce complexity in algorithm
 struct Fan {
   /* Blades of the fan. */
   Vector<InnerEdge> inner_edges;
@@ -749,10 +748,6 @@ static void extend_at_vert(UVIsland &island, UVBorderCorner &corner, float min_u
   }
   fan.init_uv_coordinates(*uv_vertex);
   fan.mark_already_added_segments(*uv_vertex);
-
-  // tag them as being 'not fixed in uv space'. count them and determine a position in uv space.
-  // add UV primitives for them.
-  // recalc the border.
   int num_to_add = fan.count_num_to_add();
 
   if (num_to_add == 0) {
@@ -760,9 +755,12 @@ static void extend_at_vert(UVIsland &island, UVBorderCorner &corner, float min_u
     MeshPrimitive *fill_primitive_2 = corner.first->uv_primitive->primitive;
 
     MeshPrimitive *fill_primitive = find_fill_border(corner);
-    // Although the fill_primitive can fill the missing segment it could lead to a squashed
-    // triangle when the corner angle is near 180 degrees. In order to fix this we will
-    // always add two segments both using the found fill primitive.
+
+    /*
+     * Although the fill_primitive can fill the missing segment it could lead to a squashed
+     * triangle when the corner angle is near 180 degrees. In order to fix this we will
+     * always add two segments both using the same fill primitive.
+     */
     if (fill_primitive) {
       fill_primitive_1 = fill_primitive;
       fill_primitive_2 = fill_primitive;
@@ -811,13 +809,13 @@ static void extend_at_vert(UVIsland &island, UVBorderCorner &corner, float min_u
       float factor = (i + 1.0f) / (num_to_add + 1.0f);
       float2 new_uv = corner.uv(factor, min_uv_distance);
 
-      // Find an segment that contains the 'current edge'.
+      /* Find an segment that contains the 'current edge'. */
       for (InnerEdge &segment : fan.inner_edges) {
         if (segment.flags.found) {
           continue;
         }
 
-        // Find primitive that shares the current edge and the segment edge.
+        /* Find primitive that shares the current edge and the segment edge. */
         MeshPrimitive *fill_primitive = find_fill_border(
             *uv_vertex->vertex,
             *shared_edge_vertex,
@@ -921,8 +919,6 @@ static void reset_extendability_flags(UVIsland &island)
 
 void UVIsland::extend_border(const UVIslandsMask &mask, const short island_index)
 {
-  // Find sharpest corner that still inside the island mask and can be extended.
-  // exit when no corner could be found.
   reset_extendability_flags(*this);
 
   int64_t border_index = 0;
@@ -938,12 +934,12 @@ void UVIsland::extend_border(const UVIslandsMask &mask, const short island_index
 
     UVVertex *uv_vertex = extension_corner->second->get_uv_vertex(0);
 
-    /* When outside the mask, the uv should not be considered for extension. */
+    /* Found corner is outside the mask, the corner should not be considered for extension. */
     const UVIslandsMask::Tile *tile = mask.find_tile(uv_vertex->uv);
     if (tile && tile->is_masked(island_index, uv_vertex->uv)) {
       extend_at_vert(*this, *extension_corner, tile->get_pixel_size_in_uv_space() * 2.0f);
     }
-    /* Mark that the vert is extended. Unable to extend twice. */
+    /* Mark that the vert is extended. */
     uv_vertex->flags.is_extended = true;
   }
 }
diff --git a/source/blender/blenkernel/intern/pbvh_uv_islands.hh b/source/blender/blenkernel/intern/pbvh_uv_islands.hh
index 26a2e9785c9..a21afcdc562 100644
--- a/source/blender/blenkernel/intern/pbvh_uv_islands.hh
+++ b/source/blender/blenkernel/intern/pbvh_uv_islands.hh
@@ -7,7 +7,7 @@
  * Island.
  *
  * \note Similar to `uvedit_islands.cc`, but optimized for PBVH painting without using BMesh for
- * performance reasons. Does not support non-manifold meshes or edges with more than 2 faces.
+ * performance reasons. Non-manifold meshes only (i.e. edges must have less than 3 faces).
  *
  * Polygons (face with more than 3 edges) are supported as they are split up to primitives.
  *
diff --git a/source/blender/blenlib/BLI_vector_list.hh b/source/blender/blenlib/BLI_vector_list.hh
index fd454c7cfa6..dee333db39a 100644
--- a/source/blender/blenlib/BLI_vector_list.hh
+++ b/source/blender/blenlib/BLI_vector_list.hh
@@ -8,15 +8,27 @@
 
 namespace blender {
 
-template<typename T> class VectorList {
+/**
+ * A VectorList is a vector of vectors.
+ *
+ * VectorList can be used when:
+ *
+ * 1) Don't know up front the number of elements that will be added to the list. Use array or
+ * vector.reserve when known up front.
+ *
+ * 2) Number of reads/writes doesn't require sequential access
+ * of the whole list. A vector ensures memory is sequential which is fast when reading, writing can
+ * have overhead when the reserved memory is full.
+ *
+ * When a VectorList reserved memory is full it will allocate memory for the new items, breaking
+ * the sequential access. Within each allocated memory block the elements are ordered sequentially.
+ */
+template<typename T, int64_t CapacityStart = 32, int64_t CapacitySoftLimit = 4096>
+class VectorList {
  public:
   using UsedVector = Vector<T, 0>;
 
  private:
-  // TODO: Should be template variables.
-  static constexpr int64_t vector_capacity_start = 32;
-  static constexpr int64_t vector_capacity_soft_limit = 4096;
-
   /**
    * Contains the individual vectors. There must always be at least one vector
    */
@@ -99,9 +111,9 @@ template<typename T> class VectorList {
   int64_t get_next_vector_capacity()
   {
     if (vectors_.is_empty()) {
-      return vector_capacity_start;
+      return CapacityStart;
     }
-    return std::min(vectors_.last().capacity() * 2, vector_capacity_soft_limit);
+    return std::min(vectors_.last().capacity() * 2, CapacitySoftLimit);
   }
 };



More information about the Bf-blender-cvs mailing list