Skip to content

Commit

Permalink
Make mesh attr vertex count mismatch warn more readable (bevyengine#1…
Browse files Browse the repository at this point in the history
…0259)

# 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 <torstein.grindvik@muybridge.com>
Co-authored-by: Torstein Grindvik <torstein.grindvik@muybridge.com>
  • Loading branch information
2 people authored and Ray Redondo committed Jan 9, 2024
1 parent a2cb78b commit 671ab31
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 671ab31

Please sign in to comment.