[Bf-blender-cvs] [1e34ee0a7e5] temp-T97352-3d-texturing-seam-bleeding-b2: Fixed SVG_DEBUG.

Jeroen Bakker noreply at git.blender.org
Mon Jul 11 15:36:23 CEST 2022


Commit: 1e34ee0a7e5854ddbf42032dfb9ab2274841ef98
Author: Jeroen Bakker
Date:   Mon Jul 11 15:36:37 2022 +0200
Branches: temp-T97352-3d-texturing-seam-bleeding-b2
https://developer.blender.org/rB1e34ee0a7e5854ddbf42032dfb9ab2274841ef98

Fixed SVG_DEBUG.

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

M	source/blender/blenkernel/BKE_uv_islands.hh
M	source/blender/blenkernel/intern/uv_islands.cc
M	source/blender/blenlib/BLI_vector_list.hh

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

diff --git a/source/blender/blenkernel/BKE_uv_islands.hh b/source/blender/blenkernel/BKE_uv_islands.hh
index 38e2f0523fa..85f3c78bdcc 100644
--- a/source/blender/blenkernel/BKE_uv_islands.hh
+++ b/source/blender/blenkernel/BKE_uv_islands.hh
@@ -825,7 +825,7 @@ struct UVIsland {
 #ifdef DEBUG_SVG
 /* Debug functions to export to a SVG file. */
 void svg_header(std::ostream &ss);
-void svg(std::ostream &ss, const UVIsland &islands, int step, int64_t first_new_prim_index);
+void svg(std::ostream &ss, const UVIsland &islands, int step);
 void svg(std::ostream &ss, const UVIslands &islands, int step);
 void svg(std::ostream &ss, const UVPrimitive &primitive);
 void svg(std::ostream &ss, const UVPrimitive &primitive, int step);
diff --git a/source/blender/blenkernel/intern/uv_islands.cc b/source/blender/blenkernel/intern/uv_islands.cc
index 7881487cd81..91819a81c4c 100644
--- a/source/blender/blenkernel/intern/uv_islands.cc
+++ b/source/blender/blenkernel/intern/uv_islands.cc
@@ -530,8 +530,7 @@ void UVIsland::extend_border(const UVIslandsMask &mask, const short island_index
   std::ofstream of;
   of.open(filename.str());
   svg_header(of);
-  uint64_t first_new_prim_index = uv_primitives.size();
-  svg(of, *this, step++, first_new_prim_index);
+  svg(of, *this, step++);
 #endif
 
   int64_t border_index = 0;
@@ -560,8 +559,7 @@ void UVIsland::extend_border(const UVIslandsMask &mask, const short island_index
 #endif
 
 #ifdef DEBUG_SVG
-    svg(of, *this, step++, first_new_prim_index);
-    first_new_prim_index = uv_primitives.size();
+    svg(of, *this, step++);
 #endif
   }
 #ifdef DEBUG_SVG
@@ -847,36 +845,31 @@ static void svg(std::ostream &ss, const UVEdge &edge)
      << "\"/>\n";
 }
 
-void svg(std::ostream &ss, const UVIsland &island, int step, int64_t first_new_prim_index)
+void svg(std::ostream &ss, const UVIsland &island, int step)
 {
   ss << "<g transform=\"translate(" << step * 1024 << " 0)\">\n";
   ss << "  <g fill=\"none\">\n";
 
   /* Inner edges */
   ss << "    <g stroke=\"grey\" stroke-width=\"1\">\n";
-  for (const UVPrimitive &primitive :
-       Span<const UVPrimitive>(island.uv_primitives.begin(), first_new_prim_index)) {
-    svg(ss, primitive);
-  }
-  ss << "     </g>\n";
-
-  ss << "    <g stroke=\"grey\" fill=\"green\" stroke-width=\"1\">\n";
-  for (const UVPrimitive &primitive :
-       Span<const UVPrimitive>(&island.uv_primitives[first_new_prim_index],
-                               island.uv_primitives.size() - first_new_prim_index)) {
-    svg(ss, primitive);
+  for (const VectorList<UVPrimitive>::UsedVector &uv_primitives : island.uv_primitives) {
+    for (const UVPrimitive &primitive : uv_primitives) {
+      svg(ss, primitive);
+    }
   }
   ss << "     </g>\n";
 
   /* Border */
   ss << "    <g stroke=\"black\" stroke-width=\"2\">\n";
-  for (const UVPrimitive &primitive : island.uv_primitives) {
-    for (int i = 0; i < 3; i++) {
-      const UVEdge &edge = *primitive.edges[i];
-      if (!edge.is_border_edge()) {
-        continue;
+  for (const VectorList<UVPrimitive>::UsedVector &uv_primitives : island.uv_primitives) {
+    for (const UVPrimitive &primitive : uv_primitives) {
+      for (int i = 0; i < 3; i++) {
+        const UVEdge &edge = *primitive.edges[i];
+        if (!edge.is_border_edge()) {
+          continue;
+        }
+        svg(ss, edge);
       }
-      svg(ss, edge);
     }
   }
   ss << "     </g>\n";
@@ -909,26 +902,30 @@ void svg(std::ostream &ss, const UVIslands &islands, int step)
 
     /* Inner edges */
     ss << "    <g stroke=\"grey\" stroke-dasharray=\"5 5\">\n";
-    for (const UVPrimitive &primitive : island.uv_primitives) {
-      for (int i = 0; i < 3; i++) {
-        const UVEdge &edge = *primitive.edges[i];
-        if (edge.is_border_edge()) {
-          continue;
+    for (const VectorList<UVPrimitive>::UsedVector &uv_primitives : island.uv_primitives) {
+      for (const UVPrimitive &primitive : uv_primitives) {
+        for (int i = 0; i < 3; i++) {
+          const UVEdge &edge = *primitive.edges[i];
+          if (edge.is_border_edge()) {
+            continue;
+          }
+          svg(ss, edge);
         }
-        svg(ss, edge);
       }
     }
     ss << "     </g>\n";
 
     /* Border */
     ss << "    <g stroke=\"black\" stroke-width=\"2\">\n";
-    for (const UVPrimitive &primitive : island.uv_primitives) {
-      for (int i = 0; i < 3; i++) {
-        const UVEdge &edge = *primitive.edges[i];
-        if (!edge.is_border_edge()) {
-          continue;
+    for (const VectorList<UVPrimitive>::UsedVector &uv_primitives : island.uv_primitives) {
+      for (const UVPrimitive &primitive : uv_primitives) {
+        for (int i = 0; i < 3; i++) {
+          const UVEdge &edge = *primitive.edges[i];
+          if (!edge.is_border_edge()) {
+            continue;
+          }
+          svg(ss, edge);
         }
-        svg(ss, edge);
       }
     }
     ss << "     </g>\n";
@@ -944,43 +941,46 @@ void svg(std::ostream &ss, const UVIslandsMask &mask, int step)
 {
   ss << "<g transform=\"translate(" << step * 1024 << " 0)\">\n";
   ss << " <g fill=\"none\" stroke=\"black\">\n";
+  for (const UVIslandsMask::Tile&tile: mask.tiles)
+    {
 
-  float2 resolution = float2(mask.resolution.x, mask.resolution.y);
-  for (int x = 0; x < mask.resolution.x; x++) {
-    for (int y = 0; y < mask.resolution.y; y++) {
-      int offset = y * mask.resolution.x + x;
-      int offset2 = offset - 1;
-      if (y == 0 && mask.mask[offset] == 0xffff) {
-        continue;
-      }
-      if (x > 0 && mask.mask[offset] == mask.mask[offset2]) {
-        continue;
+      float2 resolution = float2(tile.resolution.x, tile.resolution.y);
+      for (int x = 0; x < tile.resolution.x; x++) {
+        for (int y = 0; y < tile.resolution.y; y++) {
+          int offset = y * tile.resolution.x + x;
+          int offset2 = offset - 1;
+          if (y == 0 && tile.mask[offset] == 0xffff) {
+            continue;
+          }
+          if (x > 0 && tile.mask[offset] == tile.mask[offset2]) {
+            continue;
+          }
+          float2 start = float2(float(x), float(y)) / resolution;
+          float2 end = float2(float(x), float(y + 1)) / resolution;
+          ss << "       <line x1=\"" << svg_x(start) << "\" y1=\"" << svg_y(start) << "\" x2=\""
+             << svg_x(end) << "\" y2=\"" << svg_y(end) << "\"/>\n";
+        }
       }
-      float2 start = float2(float(x), float(y)) / resolution;
-      float2 end = float2(float(x), float(y + 1)) / resolution;
-      ss << "       <line x1=\"" << svg_x(start) << "\" y1=\"" << svg_y(start) << "\" x2=\""
-         << svg_x(end) << "\" y2=\"" << svg_y(end) << "\"/>\n";
-    }
-  }
 
-  for (int x = 0; x < mask.resolution.x; x++) {
-    for (int y = 0; y < mask.resolution.y; y++) {
-      int offset = y * mask.resolution.x + x;
-      int offset2 = offset - mask.resolution.x;
-      if (x == 0 && mask.mask[offset] == 0xffff) {
-        continue;
-      }
-      if (y > 0 && mask.mask[offset] == mask.mask[offset2]) {
-        continue;
+      for (int x = 0; x < tile.resolution.x; x++) {
+        for (int y = 0; y < tile.resolution.y; y++) {
+          int offset = y * tile.resolution.x + x;
+          int offset2 = offset - tile.resolution.x;
+          if (x == 0 && tile.mask[offset] == 0xffff) {
+            continue;
+          }
+          if (y > 0 && tile.mask[offset] == tile.mask[offset2]) {
+            continue;
+          }
+          float2 start = float2(float(x), float(y)) / resolution;
+          float2 end = float2(float(x + 1), float(y)) / resolution;
+          ss << "       <line x1=\"" << svg_x(start) << "\" y1=\"" << svg_y(start) << "\" x2=\""
+             << svg_x(end) << "\" y2=\"" << svg_y(end) << "\"/>\n";
+        }
       }
-      float2 start = float2(float(x), float(y)) / resolution;
-      float2 end = float2(float(x + 1), float(y)) / resolution;
-      ss << "       <line x1=\"" << svg_x(start) << "\" y1=\"" << svg_y(start) << "\" x2=\""
-         << svg_x(end) << "\" y2=\"" << svg_y(end) << "\"/>\n";
+      ss << " </g>\n";
+      ss << "</g>\n";
     }
-  }
-  ss << " </g>\n";
-  ss << "</g>\n";
 }
 
 static void svg_coords(std::ostream &ss, const float2 &coords)
diff --git a/source/blender/blenlib/BLI_vector_list.hh b/source/blender/blenlib/BLI_vector_list.hh
index f3a7dd2bb3a..d9226d40874 100644
--- a/source/blender/blenlib/BLI_vector_list.hh
+++ b/source/blender/blenlib/BLI_vector_list.hh
@@ -83,6 +83,15 @@ template<typename T> class VectorList {
     return vectors_.last().last();
   }
 
+  int64_t size() const
+  {
+    int64_t result = 0;
+    for (const UsedVector &vector : *this) {
+      result += vector.size();
+    }
+    return result;
+  }
+
  private:
   UsedVector &ensure_space_for_one()
   {



More information about the Bf-blender-cvs mailing list