Skip to content

Commit

Permalink
fix(shape): warn once per mesh for zero-weighted vertices (#216)
Browse files Browse the repository at this point in the history
Instead of logging for each vertex, it now warn once per mesh instead. Should make the log a lot cleaner.

fixes: #96
  • Loading branch information
NMC-TBone authored Dec 1, 2024
1 parent 808ddad commit 1ae054e
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions addon/i3dio/node_classes/shape.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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))
Expand All @@ -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

Expand Down

0 comments on commit 1ae054e

Please sign in to comment.