Skip to content

Commit d8697ea

Browse files
Fix linter
1 parent a6f4f73 commit d8697ea

File tree

3 files changed

+17
-11
lines changed

3 files changed

+17
-11
lines changed

src/client/terrain/util/chunk.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ use crate::prelude::*;
22

33
pub const CHUNK_SIZE: usize = 32;
44
pub const PADDED_CHUNK_SIZE: usize = CHUNK_SIZE + 2;
5-
pub const PADDED_CHUNK_USIZE: usize = PADDED_CHUNK_SIZE as usize;
5+
pub const PADDED_CHUNK_USIZE: usize = PADDED_CHUNK_SIZE;
66
pub const CHUNK_LENGTH: usize =
7-
(PADDED_CHUNK_SIZE * PADDED_CHUNK_SIZE * PADDED_CHUNK_SIZE) as usize;
7+
PADDED_CHUNK_SIZE * PADDED_CHUNK_SIZE * PADDED_CHUNK_SIZE;
88

99
pub struct Chunk {
1010
pub data: [BlockId; CHUNK_LENGTH],
@@ -23,7 +23,6 @@ impl Chunk {
2323
self.get_unpadded(x + 1, y + 1, z + 1)
2424
}
2525

26-
2726
pub fn get_unpadded(&self, x: usize, y: usize, z: usize) -> BlockId {
2827
self.data[Self::index(x, y, z)]
2928
}
@@ -39,7 +38,7 @@ impl Chunk {
3938

4039
#[rustfmt::skip]
4140
pub fn index(x: usize, y: usize, z: usize) -> usize {
42-
if (x >= PADDED_CHUNK_SIZE as usize) || (y >= PADDED_CHUNK_SIZE as usize) || (z >= PADDED_CHUNK_SIZE as usize) {
41+
if (x >= PADDED_CHUNK_SIZE) || (y >= PADDED_CHUNK_SIZE) || (z >= PADDED_CHUNK_SIZE) {
4342
panic!("Index out of bounds: ({}, {}, {})", x, y, z);
4443
}
4544
x + PADDED_CHUNK_USIZE * (y + PADDED_CHUNK_USIZE * z)

src/client/terrain/util/generator.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ impl Generator {
2525
let local_position = Vec3::new(x as f32, y as f32, z as f32);
2626
let block_position = chunk_origin + local_position;
2727
let block = self.generate_block(block_position);
28-
chunk.set_unpadded(x as usize, y as usize, z as usize, block);
28+
chunk.set_unpadded(x, y, z, block);
2929
}
3030
}
3131
}

src/client/terrain/util/mesher.rs

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,17 +86,24 @@ pub fn create_chunk_mesh(chunk: &Chunk, texture_manager: &TextureManager) -> Opt
8686
indices: Vec::new(),
8787
};
8888

89-
for x in 1..CHUNK_SIZE - 1 {
90-
for y in 1..CHUNK_SIZE - 1 {
91-
for z in 1..CHUNK_SIZE - 1 {
92-
let block_id = chunk.get(x as usize, y as usize, z as usize);
89+
for x in 1..CHUNK_SIZE - 1 {
90+
for y in 1..CHUNK_SIZE - 1 {
91+
for z in 1..CHUNK_SIZE - 1 {
92+
let block_id = chunk.get(x, y, z);
9393

9494
if block_id == BlockId::Air {
9595
continue;
9696
}
9797

98-
fn update_mask(chunk: &Chunk, mask: &mut u8, value: u8, x: usize, y: usize, z: usize) {
99-
if chunk.get(x as usize, y as usize, z as usize) == BlockId::Air {
98+
fn update_mask(
99+
chunk: &Chunk,
100+
mask: &mut u8,
101+
value: u8,
102+
x: usize,
103+
y: usize,
104+
z: usize,
105+
) {
106+
if chunk.get(x, y, z) == BlockId::Air {
100107
*mask |= value;
101108
}
102109
}

0 commit comments

Comments
 (0)