diff --git a/crates/bevy_gltf/src/loader.rs b/crates/bevy_gltf/src/loader.rs index fe5d92d692fed..7fb690ce39811 100644 --- a/crates/bevy_gltf/src/loader.rs +++ b/crates/bevy_gltf/src/loader.rs @@ -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], node: &gltf::Node, depth: i32) -> Result 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); } diff --git a/crates/bevy_render/src/mesh/mesh.rs b/crates/bevy_render/src/mesh/mesh.rs index b717e4e30efc6..5f631f202f23e 100644 --- a/crates/bevy_render/src/mesh/mesh.rs +++ b/crates/bevy_render/src/mesh/mesh.rs @@ -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(); diff --git a/crates/bevy_render/src/pipeline/pipeline.rs b/crates/bevy_render/src/pipeline/pipeline.rs index c1e5e5f73cd7d..9f59ca82280dc 100644 --- a/crates/bevy_render/src/pipeline/pipeline.rs +++ b/crates/bevy_render/src/pipeline/pipeline.rs @@ -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, diff --git a/crates/bevy_render/src/pipeline/pipeline_compiler.rs b/crates/bevy_render/src/pipeline/pipeline_compiler.rs index d611b62ea7c61..b696aa3182a32 100644 --- a/crates/bevy_render/src/pipeline/pipeline_compiler.rs +++ b/crates/bevy_render/src/pipeline/pipeline_compiler.rs @@ -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, } } } diff --git a/crates/bevy_render/src/pipeline/render_pipelines.rs b/crates/bevy_render/src/pipeline/render_pipelines.rs index 7d97165ea846c..bc477a7bf6846 100644 --- a/crates/bevy_render/src/pipeline/render_pipelines.rs +++ b/crates/bevy_render/src/pipeline/render_pipelines.rs @@ -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; diff --git a/crates/bevy_render/src/pipeline/state_descriptors.rs b/crates/bevy_render/src/pipeline/state_descriptors.rs index 8e75f95050012..1d04ab33af4f3 100644 --- a/crates/bevy_render/src/pipeline/state_descriptors.rs +++ b/crates/bevy_render/src/pipeline/state_descriptors.rs @@ -190,6 +190,6 @@ pub enum IndexFormat { impl Default for IndexFormat { fn default() -> Self { - IndexFormat::Uint16 + IndexFormat::Uint32 } }