Make mesh attr vertex count mismatch warn more readable (#10259)

# 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>
This commit is contained in:
Torstein Grindvik 2023-10-25 21:03:05 +02:00 committed by GitHub
parent 66f72dd25b
commit f992398c79
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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));
}