[Bf-blender-cvs] [fe53eeea790] temp-T97352-3d-texturing-seam-bleeding-b2: Remove debug code.

Jeroen Bakker noreply at git.blender.org
Tue Sep 20 10:32:17 CEST 2022


Commit: fe53eeea790efb135f8538e38005a79e13f71578
Author: Jeroen Bakker
Date:   Tue Sep 20 10:26:43 2022 +0200
Branches: temp-T97352-3d-texturing-seam-bleeding-b2
https://developer.blender.org/rBfe53eeea790efb135f8538e38005a79e13f71578

Remove debug code.

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

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

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

diff --git a/source/blender/blenkernel/BKE_uv_islands.hh b/source/blender/blenkernel/BKE_uv_islands.hh
index bb9ad1dcd77..741e9ae5714 100644
--- a/source/blender/blenkernel/BKE_uv_islands.hh
+++ b/source/blender/blenkernel/BKE_uv_islands.hh
@@ -25,8 +25,6 @@ namespace blender::bke::uv_islands {
  *
  * TODO: These will be removed before this patch will land in master.
  */
-//#define DEBUG_SVG
-//#define VALIDATE
 
 struct MeshEdge;
 struct MeshPrimitive;
@@ -130,22 +128,6 @@ struct MeshData {
     init_primitives();
     init_edges();
     init_primitive_uv_island_ids();
-
-#ifdef VALIDATE
-    for (const MeshVertex &v : vertices) {
-      printf("Vert {v%lld}\n", v.v);
-      for (const MeshEdge *e : v.edges) {
-        printf("-Edge {v%lld v%lld}\n", e->vert1->v, e->vert2->v);
-        for (const MeshPrimitive *p : e->primitives) {
-          printf(" -Prim {p%lld, v%lld v%lld v%lld}\n",
-                 p->index,
-                 p->vertices[0].vertex->v,
-                 p->vertices[1].vertex->v,
-                 p->vertices[2].vertex->v);
-        }
-      }
-    }
-#endif
   }
 
   void init_vertices()
@@ -576,10 +558,6 @@ struct UVBorder {
 
   static std::optional<UVBorder> extract_from_edges(Vector<UVBorderEdge> &edges);
 
-#ifdef VALIDATE
-  void validate() const;
-#endif
-
   /** Remove edge from the border. updates the indexes. */
   void remove(int64_t index)
   {
@@ -718,67 +696,8 @@ struct UVIsland {
       }
     }
   }
-
-#ifdef VALIDATE
-  void validate_primitives() const
-  {
-    /* Each UVPrimitive that points to the same mesh primitive should contain the same mesh
-     * vertices (and can be retrieved in the same order). */
-    for (const UVPrimitive &prim_a : uv_primitives) {
-      validate_primitive(prim_a);
-    }
-  }
-  void validate_primitive(const UVPrimitive &prim_a) const
-  {
-    /* Each UVPrimitive that points to the same mesh primitive should contain the same mesh
-     * vertices (and can be retrieved in the same order). */
-    for (const UVPrimitive &prim_b : uv_primitives) {
-      if (prim_a.primitive != prim_b.primitive) {
-        continue;
-      }
-      for (int i = 0; i < 3; i++) {
-        const UVVertex *v1 = prim_a.get_uv_vertex(i);
-        const UVVertex *v2 = prim_b.get_uv_vertex(i);
-        BLI_assert(v1->vertex->v == v2->vertex->v);
-      }
-    }
-  }
-
-  void validate_border() const
-  {
-    /* Each UVPrimitive that points to the same mesh primitive should contain the same mesh
-     * vertices (and can be retrieved in the same order). */
-    for (const UVPrimitive &prim_a : uv_primitives) {
-      for (const UVPrimitive &prim_b : uv_primitives) {
-        if (prim_a.primitive != prim_b.primitive) {
-          continue;
-        }
-        for (int i = 0; i < 3; i++) {
-          const UVVertex *v1 = prim_a.get_uv_vertex(i);
-          const UVVertex *v2 = prim_b.get_uv_vertex(i);
-          BLI_assert(v1->vertex->v == v2->vertex->v);
-        }
-      }
-    }
-    for (const UVBorder &border : borders) {
-      border.validate();
-    }
-  }
-#endif
 };
 
-#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);
-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);
-void svg(std::ostream &ss, const UVIslandsMask &mask, int step);
-void svg(std::ostream &ss, const UVBorder &border, int step);
-void svg_footer(std::ostream &ss);
-#endif
-
 struct UVIslands {
   Vector<UVIsland> islands;
 
@@ -786,25 +705,6 @@ struct UVIslands {
 
   void extract_borders();
   void extend_borders(const UVIslandsMask &islands_mask);
-
-#ifdef VALIDATE
- private:
-  bool validate() const
-  {
-    /* After operations it is not allowed that islands share any edges. In that case it should
-     * already be merged. */
-    for (int i = 0; i < islands.size() - 1; i++) {
-      for (int j = i + 1; j < islands.size(); j++) {
-        for (const UVPrimitive &prim : islands[j].uv_primitives) {
-          if (islands[i].has_shared_edge(prim)) {
-            return false;
-          }
-        }
-      }
-    }
-    return true;
-  }
-#endif
 };
 
 /** Mask to find the index of the UVIsland for a given UV coordinate. */
diff --git a/source/blender/blenkernel/intern/uv_islands.cc b/source/blender/blenkernel/intern/uv_islands.cc
index 2654a5a55d2..43cc274f886 100644
--- a/source/blender/blenkernel/intern/uv_islands.cc
+++ b/source/blender/blenkernel/intern/uv_islands.cc
@@ -204,9 +204,6 @@ struct Fan {
         }
       }
       if (stop == false) {
-#ifdef VALIDATE
-        printf("unknown how to create the fan for vert %lld\n", vertex.v);
-#endif
         flags.full = false;
         break;
       }
@@ -270,22 +267,6 @@ struct Fan {
   }
 };
 
-#ifdef VALIDATE
-static void print(const Fan &fan)
-{
-  for (const InnerEdge &fan_edge : fan.inner_edges) {
-    for (int i = 0; i < 3; i++) {
-      int vert_index = fan_edge.vert_order[i];
-      printf("%lld(%f,%f) ",
-             fan_edge.primitive->vertices[vert_index].vertex->v,
-             fan_edge.uvs[i].x,
-             fan_edge.uvs[i].y);
-    }
-    printf(" %d\n", fan_edge.flags.found);
-  }
-}
-#endif
-
 static void add_uv_primitive_shared_uv_edge(UVIsland &island,
                                             UVVertex *connected_vert_1,
                                             UVVertex *connected_vert_2,
@@ -324,38 +305,19 @@ static void add_uv_primitive_shared_uv_edge(UVIsland &island,
   prim1.append_to_uv_edges();
   prim1.append_to_uv_vertices();
   island.uv_primitives.append(prim1);
-#ifdef VALIDATE
-  island.validate_primitive(island.uv_primitives.last());
-#endif
 }
 
 static MeshPrimitive *find_fill_border(const MeshVertex &v1,
                                        const MeshVertex &v2,
                                        const MeshVertex &v3)
 {
-#ifdef VALIDATE
-  printf("find primitive containing (%lld,%lld,%lld)\n", v1.v, v2.v, v3.v);
-#endif
   for (MeshEdge *edge : v1.edges) {
     for (MeshPrimitive *primitive : edge->primitives) {
-#ifdef VALIDATE
-      printf("- try primitive %lld containing (%lld,%lld,%lld)\n",
-             primitive->index,
-             primitive->vertices[0].vertex->v,
-             primitive->vertices[1].vertex->v,
-             primitive->vertices[2].vertex->v);
-#endif
       if (has_vertex(*primitive, v1) && has_vertex(*primitive, v2) && has_vertex(*primitive, v3)) {
-#ifdef VALIDATE
-        printf("- found primitive\n");
-#endif
         return primitive;
       }
     }
   }
-#ifdef VALIDATE
-  printf("- No primitive found\n");
-#endif
   return nullptr;
 }
 /**
@@ -418,9 +380,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);
-#ifdef VALIDATE
-  print(fan);
-#endif
 
   // tag them as being 'not fixed in uv space'. count them and determine a position in uv space.
   // add UV primitives for them.
@@ -593,16 +552,6 @@ 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.
-#ifdef DEBUG_SVG
-  int step = 0;
-  std::stringstream filename;
-  filename << "/tmp/extend." << island_index << ".svg";
-  std::ofstream of;
-  of.open(filename.str());
-  svg_header(of);
-  svg(of, *this, step++);
-#endif
-
   reset_extendability_flags(*this);
 
   int64_t border_index = 0;
@@ -611,9 +560,6 @@ void UVIsland::extend_border(const UVIslandsMask &mask, const short island_index
   }
 
   while (true) {
-#ifdef VALIDATE
-    validate_border();
-#endif
     std::optional<UVBorderCorner> extension_corner = sharpest_border_corner(*this);
     if (!extension_corner.has_value()) {
       break;
@@ -628,19 +574,7 @@ void UVIsland::extend_border(const UVIslandsMask &mask, const short island_index
     }
     /* Mark that the vert is extended. Unable to extend twice. */
     uv_vertex->flags.is_extended = true;
-
-#ifdef VALIDATE
-    validate_border();
-#endif
-
-#ifdef DEBUG_SVG
-    svg(of, *this, step++);
-#endif
   }
-#ifdef DEBUG_SVG
-  svg_footer(of);
-  of.close();
-#endif
 }
 
 /** \} */
@@ -736,24 +670,6 @@ void UVBorder::update_indexes(uint64_t border_index)
   }
 }
 
-#ifdef VALIDATE
-void UVBorder::validate() const
-{
-  for (const UVBorderEdge &edge : edges) {
-    float2 uv1 = edge.get_uv_vertex(0)->uv;
-    float2 uv2 = edge.get_uv_vertex(1)->uv;
-    std::cout << uv1;
-    std::cout << "->";
-    std::cout << uv2;
-    std::cout << "\n";
-  }
-  for (const UVBorderEdge &edge : edges) {
-    BLI_assert(edges[edge.prev_index].get_uv_vertex(1)->uv == edge.get_uv_vertex(0)->uv);
-    BLI_assert(edge.get_uv_vertex(1)->uv == edges[edge.next_index].get_uv_vertex(0)->uv);
-  }
-}
-#endif
-
 /** \} */
 
 /* -------------------------------------------------------------------- */
@@ -810,15 +726,6 @@ UVIslands::UVIslands(MeshData &mesh_data)
       }
     }
   }
-
-#ifdef DEBUG_SVG
-  std::ofstream of;
-  of.open("/tmp/islands.svg");
-  svg_header(of);
-  svg(of, *this, 0);
-  svg_footer(of);
-  of.close();
-#endif
 }
 
 void UVIslands::extract_borders()
@@ -826,51 +733,14 @@ void UVIslands::extract_borders()
   for (UVIsland &island : islands) {
     island.extract_borders();
   }
-
-#ifdef DEBUG_SVG
-  std::ofstream of;
-  of.open("/tmp/borders.svg");
-  svg_header(of);
-  for (UVIsland &island : islands) {
-    int index = 0;
-    for (UVBorder &border : island.borders) {
-      border.update_indexes(index);
-      index++;
-      svg(of, border, 0);
-    }
-  }
-  svg_footer(of);
-  of.close();
-#endif
 }
 
 void UVIslands::extend_borders(const UVIslandsMask &islands_mask)
 {
-#ifdef VALIDATE
-  printf("Extending borders\n");
-  printf("=================\n");
-#endif
   ushort index = 0;
   for (UVIsland &island : islands) {
-#ifdef VALIDATE
-    printf("Island %d\n", index);
-    printf("---------\n");
-#endif
     island.extend_border(islands_mask, index++);
   }
-
-#ifdef DEBUG_SVG
-  s

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list