Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

warn and min for different vertex count #9699

Merged
merged 5 commits into from
Sep 6, 2023
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions crates/bevy_render/src/mesh/mesh/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
mod conversions;
pub mod skinning;
use bevy_log::warn;
pub use wgpu::PrimitiveTopology;

use crate::{
Expand Down Expand Up @@ -330,10 +331,13 @@ impl Mesh {
for (attribute_id, attribute_data) in &self.attributes {
let attribute_len = attribute_data.values.len();
if let Some(previous_vertex_count) = vertex_count {
assert_eq!(previous_vertex_count, attribute_len,
"{attribute_id:?} has a different vertex count ({attribute_len}) than other attributes ({previous_vertex_count}) in this mesh.");
if previous_vertex_count != attribute_len {
robtfm marked this conversation as resolved.
Show resolved Hide resolved
warn!("{attribute_id:?} has a different vertex count ({attribute_len}) than other attributes ({previous_vertex_count}) in this mesh.");
vertex_count = Some(std::cmp::min(previous_vertex_count, attribute_len));
}
} else {
vertex_count = Some(attribute_len);
}
vertex_count = Some(attribute_len);
}

vertex_count.unwrap_or(0)
Expand All @@ -356,7 +360,7 @@ impl Mesh {
let mut attributes_interleaved_buffer = vec![0; vertex_count * vertex_size];
// bundle into interleaved buffers
let mut attribute_offset = 0;
for attribute_data in self.attributes.values() {
for attribute_data in self.attributes.values().take(vertex_count) {
let attribute_size = attribute_data.attribute.format.get_size() as usize;
let attributes_bytes = attribute_data.values.get_bytes();
for (vertex_index, attribute_bytes) in
Expand Down