From 1ae054ea210599394d3c94654793fe98309c552c Mon Sep 17 00:00:00 2001 From: Kristian <57712777+NMC-TBone@users.noreply.github.com> Date: Sun, 1 Dec 2024 09:29:03 -0700 Subject: [PATCH] fix(shape): warn once per mesh for zero-weighted vertices (#216) Instead of logging for each vertex, it now warn once per mesh instead. Should make the log a lot cleaner. fixes: #96 --- addon/i3dio/node_classes/shape.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/addon/i3dio/node_classes/shape.py b/addon/i3dio/node_classes/shape.py index 325e5de..61ba163 100644 --- a/addon/i3dio/node_classes/shape.py +++ b/addon/i3dio/node_classes/shape.py @@ -194,6 +194,8 @@ def process_subsets(self, mesh) -> None: def process_subset(self, mesh: bpy.types.Mesh, subset: SubSet, triangle_offset: int = 0) -> tuple[int, int]: self.logger.debug(f"Processing subset: {subset}") + + zero_weight_vertices = set() for triangle in subset.triangles[triangle_offset:]: # Add a new empty container for the vertex indexes of the triangle @@ -249,9 +251,7 @@ def process_subset(self, mesh: bpy.types.Mesh, subset: SubSet, triangle_offset: break if len(blend_ids) == 0: - self.logger.warning("Has a vertex with 0.0 weight to all bones. " - "This will confuse GE and results in the mesh showing up as just a " - "wireframe. Please correct by assigning some weight to all vertices") + zero_weight_vertices.add(blender_vertex.index) if len(blend_ids) < 4: padding = [0]*(4-len(blend_ids)) @@ -275,6 +275,12 @@ def process_subset(self, mesh: bpy.types.Mesh, subset: SubSet, triangle_offset: self.triangles[-1].append(vertex_index) subset.number_of_indices += 3 + + if zero_weight_vertices: + self.logger.warning(f"Has {len(zero_weight_vertices)} vertices with 0.0 weight to all bones. " + "This will confuse GE and result in the mesh showing up as just a wireframe. " + "Please correct by assigning some weight to all vertices.") + self.logger.debug(f"Subset {triangle.material_index} with '{len(subset.triangles)}' triangles and {subset}") return subset.first_vertex + subset.number_of_vertices, subset.first_index + subset.number_of_indices