switch to u32 indices by default (#572)
This commit is contained in:
parent
c2299c7563
commit
afc656701d
@ -5,10 +5,7 @@ use bevy_render::{
|
||||
|
||||
use anyhow::Result;
|
||||
use bevy_asset::AssetLoader;
|
||||
use gltf::{
|
||||
buffer::Source,
|
||||
mesh::{util::ReadIndices, Mode},
|
||||
};
|
||||
use gltf::{buffer::Source, mesh::Mode};
|
||||
use std::{fs, io, path::Path};
|
||||
use thiserror::Error;
|
||||
|
||||
@ -101,12 +98,8 @@ fn load_node(buffer_data: &[Vec<u8>], node: &gltf::Node, depth: i32) -> Result<M
|
||||
}
|
||||
|
||||
if let Some(indices) = reader.read_indices() {
|
||||
mesh.indices = match indices {
|
||||
ReadIndices::U8(iter) => Some(Indices::U16(iter.map(|i| i as u16).collect())),
|
||||
ReadIndices::U16(iter) => Some(Indices::U16(iter.collect())),
|
||||
ReadIndices::U32(iter) => Some(Indices::U32(iter.collect())),
|
||||
}
|
||||
};
|
||||
mesh.indices = Some(Indices::U32(indices.into_u32().collect()));
|
||||
}
|
||||
|
||||
return Ok(mesh);
|
||||
}
|
||||
|
||||
@ -237,7 +237,7 @@ pub mod shape {
|
||||
uvs.push(*uv);
|
||||
}
|
||||
|
||||
let indices = Indices::U16(vec![
|
||||
let indices = Indices::U32(vec![
|
||||
0, 1, 2, 2, 3, 0, // top
|
||||
4, 5, 6, 6, 7, 4, // bottom
|
||||
8, 9, 10, 10, 11, 8, // right
|
||||
@ -333,7 +333,7 @@ pub mod shape {
|
||||
]
|
||||
};
|
||||
|
||||
let indices = Indices::U16(vec![0, 2, 1, 0, 3, 2]);
|
||||
let indices = Indices::U32(vec![0, 2, 1, 0, 3, 2]);
|
||||
|
||||
let mut positions = Vec::new();
|
||||
let mut normals = Vec::new();
|
||||
@ -373,7 +373,7 @@ pub mod shape {
|
||||
([-extent, 0.0, -extent], [0.0, 1.0, 0.0], [0.0, 1.0]),
|
||||
];
|
||||
|
||||
let indices = Indices::U16(vec![0, 2, 1, 0, 3, 2]);
|
||||
let indices = Indices::U32(vec![0, 2, 1, 0, 3, 2]);
|
||||
|
||||
let mut positions = Vec::new();
|
||||
let mut normals = Vec::new();
|
||||
|
||||
@ -55,7 +55,7 @@ impl PipelineDescriptor {
|
||||
shader_stages,
|
||||
rasterization_state: None,
|
||||
primitive_topology: PrimitiveTopology::TriangleList,
|
||||
index_format: IndexFormat::Uint16,
|
||||
index_format: IndexFormat::Uint32,
|
||||
sample_count: 1,
|
||||
sample_mask: !0,
|
||||
alpha_to_coverage_enabled: false,
|
||||
@ -67,7 +67,7 @@ impl PipelineDescriptor {
|
||||
name: None,
|
||||
primitive_topology: PrimitiveTopology::TriangleList,
|
||||
layout: None,
|
||||
index_format: IndexFormat::Uint16,
|
||||
index_format: IndexFormat::Uint32,
|
||||
sample_count: 1,
|
||||
sample_mask: !0,
|
||||
alpha_to_coverage_enabled: false,
|
||||
|
||||
@ -27,7 +27,7 @@ impl Default for PipelineSpecialization {
|
||||
shader_specialization: Default::default(),
|
||||
primitive_topology: Default::default(),
|
||||
dynamic_bindings: Default::default(),
|
||||
index_format: IndexFormat::Uint16,
|
||||
index_format: IndexFormat::Uint32,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -88,7 +88,7 @@ pub fn draw_render_pipelines_system(
|
||||
let (index_range, index_format) = match mesh.indices.as_ref() {
|
||||
Some(Indices::U32(indices)) => (Some(0..indices.len() as u32), IndexFormat::Uint32),
|
||||
Some(Indices::U16(indices)) => (Some(0..indices.len() as u32), IndexFormat::Uint16),
|
||||
None => (None, IndexFormat::Uint16),
|
||||
None => (None, IndexFormat::Uint32),
|
||||
};
|
||||
|
||||
let render_pipelines = &mut *render_pipelines;
|
||||
|
||||
@ -190,6 +190,6 @@ pub enum IndexFormat {
|
||||
|
||||
impl Default for IndexFormat {
|
||||
fn default() -> Self {
|
||||
IndexFormat::Uint16
|
||||
IndexFormat::Uint32
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user