Remove unused index_indices
This commit is contained in:
parent
54549b8e16
commit
72969e392b
4 changed files with 6 additions and 30 deletions
22
src/chunk.rs
22
src/chunk.rs
|
@ -213,39 +213,23 @@ impl Chunk {
|
|||
|
||||
fn quads_to_geometry(
|
||||
quads: Vec<(BlockType, i32, Vector3<i32>, Quad)>,
|
||||
) -> (Vec<Vertex>, Vec<u16>, Vec<Vec<(usize, usize, usize)>>) {
|
||||
) -> (Vec<Vertex>, Vec<u16>) {
|
||||
let mut vertices = Vec::new();
|
||||
let mut indices = Vec::new();
|
||||
let mut index_indices: Vec<Vec<(usize, usize, usize)>> = Vec::new();
|
||||
for (quad_index, (block_type, y, offset, quad)) in quads.iter().enumerate() {
|
||||
#[rustfmt::skip]
|
||||
let v = cube::vertices(quad, *y, *offset, block_type.texture_indices());
|
||||
vertices.extend(&v);
|
||||
|
||||
let o = indices.len();
|
||||
#[rustfmt::skip]
|
||||
index_indices.push(match block_type {
|
||||
BlockType::Cobblestone => vec![(o + 0, o + 36, 0)],
|
||||
BlockType::Dirt => vec![(o + 0, o + 36, 1)],
|
||||
BlockType::Stone => vec![(o + 0, o + 36, 2)],
|
||||
BlockType::Grass => vec![(o + 0, o + 24, 4), (24, 30, 1), (30, 36, 3)],
|
||||
BlockType::Bedrock => vec![(o + 0, o + 36, 5)],
|
||||
BlockType::Sand => vec![(o + 0, o + 36, 5)],
|
||||
BlockType::Gravel => vec![(o + 0, o + 36, 6)],
|
||||
});
|
||||
|
||||
for index in cube::INDICES {
|
||||
indices.push(index + quad_index as u16 * 24);
|
||||
}
|
||||
}
|
||||
|
||||
(vertices, indices, index_indices)
|
||||
(vertices, indices)
|
||||
}
|
||||
|
||||
pub fn to_geometry(
|
||||
&self,
|
||||
offset: Vector3<i32>,
|
||||
) -> (Vec<Vertex>, Vec<u16>, Vec<Vec<(usize, usize, usize)>>) {
|
||||
pub fn to_geometry(&self, offset: Vector3<i32>) -> (Vec<Vertex>, Vec<u16>) {
|
||||
let mut quads: Vec<(BlockType, i32, Vector3<i32>, Quad)> = Vec::new();
|
||||
|
||||
for y in 0..CHUNK_SIZE {
|
||||
|
|
|
@ -3,8 +3,6 @@ use std::num::NonZeroU32;
|
|||
use image::EncodableLayout;
|
||||
use wgpu::Origin3d;
|
||||
|
||||
use crate::texture;
|
||||
|
||||
pub struct Texture {
|
||||
pub texture: wgpu::Texture,
|
||||
pub sampler: Option<wgpu::Sampler>,
|
||||
|
|
|
@ -26,7 +26,7 @@ impl World {
|
|||
Self { chunks }
|
||||
}
|
||||
|
||||
pub fn to_geometry(&self) -> Vec<(Vec<Vertex>, Vec<u16>, Vec<Vec<(usize, usize, usize)>>)> {
|
||||
pub fn to_geometry(&self) -> Vec<(Vec<Vertex>, Vec<u16>)> {
|
||||
let instant = std::time::Instant::now();
|
||||
let mut geometry = Vec::new();
|
||||
|
||||
|
|
|
@ -25,12 +25,7 @@ pub struct WorldState {
|
|||
pub light_bind_group: wgpu::BindGroup,
|
||||
pub world: World,
|
||||
|
||||
pub chunk_buffers: Vec<(
|
||||
wgpu::Buffer,
|
||||
wgpu::Buffer,
|
||||
Vec<Vec<(usize, usize, usize)>>,
|
||||
usize,
|
||||
)>,
|
||||
pub chunk_buffers: Vec<(wgpu::Buffer, wgpu::Buffer, usize)>,
|
||||
}
|
||||
|
||||
impl WorldState {
|
||||
|
@ -224,7 +219,7 @@ impl WorldState {
|
|||
|
||||
let world_geometry = self.world.to_geometry();
|
||||
self.chunk_buffers.clear();
|
||||
for (chunk_vertices, chunk_indices, index_textures) in world_geometry {
|
||||
for (chunk_vertices, chunk_indices) in world_geometry {
|
||||
self.chunk_buffers.push((
|
||||
render_device.create_buffer_init(&BufferInitDescriptor {
|
||||
label: None,
|
||||
|
@ -236,7 +231,6 @@ impl WorldState {
|
|||
contents: &bytemuck::cast_slice(&chunk_indices),
|
||||
usage: wgpu::BufferUsage::INDEX,
|
||||
}),
|
||||
index_textures,
|
||||
chunk_indices.len(),
|
||||
));
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue