Skip to content

Commit f992398

Browse files
torsteingrindvikTorstein Grindvik
andauthored
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>
1 parent 66f72dd commit f992398

File tree

1 file changed

+7
-1
lines changed
  • crates/bevy_render/src/mesh/mesh

1 file changed

+7
-1
lines changed

crates/bevy_render/src/mesh/mesh/mod.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,13 @@ impl Mesh {
385385
let attribute_len = attribute_data.values.len();
386386
if let Some(previous_vertex_count) = vertex_count {
387387
if previous_vertex_count != attribute_len {
388-
warn!("{attribute_id:?} has a different vertex count ({attribute_len}) than other attributes ({previous_vertex_count}) in this mesh, \
388+
let name = self
389+
.attributes
390+
.get(attribute_id)
391+
.map(|data| data.attribute.name.to_string())
392+
.unwrap_or_else(|| format!("{attribute_id:?}"));
393+
394+
warn!("{name} has a different vertex count ({attribute_len}) than other attributes ({previous_vertex_count}) in this mesh, \
389395
all attributes will be truncated to match the smallest.");
390396
vertex_count = Some(std::cmp::min(previous_vertex_count, attribute_len));
391397
}

0 commit comments

Comments
 (0)