Skip to content

Commit

Permalink
Make mesh attr vertex count mismatch warn more readable (#10259)
Browse files Browse the repository at this point in the history
# Objective

When a mesh vertex attribute has a vertex count mismatch, a warning
message is printed with the index of the attribute which did not match.

Change to name the attribute, or fall back to the old behaviour if it
was not a known attribute.

Before:

```
MeshVertexAttributeId(2) has a different vertex count (32) than other attributes (64) in this mesh, all attributes will be truncated to match the smallest.
```

After:

```
Vertex_Uv has a different vertex count (32) than other attributes (64) in this mesh, all attributes will be truncated to match the smallest.
```

## Solution

Name the mesh attribute which had a count mismatch.


## Changelog

- If a mesh vertex attribute has a different count than other vertex
attributes, name the offending attribute using a human readable name

Signed-off-by: Torstein Grindvik <[email protected]>
Co-authored-by: Torstein Grindvik <[email protected]>
  • Loading branch information
torsteingrindvik and Torstein Grindvik authored Oct 25, 2023
1 parent 66f72dd commit f992398
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion crates/bevy_render/src/mesh/mesh/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,13 @@ impl Mesh {
let attribute_len = attribute_data.values.len();
if let Some(previous_vertex_count) = vertex_count {
if previous_vertex_count != attribute_len {
warn!("{attribute_id:?} has a different vertex count ({attribute_len}) than other attributes ({previous_vertex_count}) in this mesh, \
let name = self
.attributes
.get(attribute_id)
.map(|data| data.attribute.name.to_string())
.unwrap_or_else(|| format!("{attribute_id:?}"));

warn!("{name} has a different vertex count ({attribute_len}) than other attributes ({previous_vertex_count}) in this mesh, \
all attributes will be truncated to match the smallest.");
vertex_count = Some(std::cmp::min(previous_vertex_count, attribute_len));
}
Expand Down

0 comments on commit f992398

Please sign in to comment.