Skip to content

Commit c53093b

Browse files
Refix integer overflow (#14)
* Update mesher * Optimize debug build * Fix mesher offset * Update cargo fmt
1 parent e2a2d89 commit c53093b

File tree

3 files changed

+12
-9
lines changed

3 files changed

+12
-9
lines changed

Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ rand = "0.8.5"
1818
renet = "0.0.15"
1919
serde = "1.0.203"
2020

21+
[profile.dev.package."*"]
22+
opt-level = 3
23+
2124
[profile.release]
2225
opt-level = 3
2326

bin/fastcheck

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#!/bin/bash
22

33
cargo clippy --fix --allow-dirty
4-
cargo fmt --all -- --check
4+
cargo fmt --all

src/client/terrain/util/mesher.rs

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

89-
for x in 0..CHUNK_SIZE {
90-
for y in 0..CHUNK_SIZE {
91-
for z in 0..CHUNK_SIZE {
92-
let block_id = chunk.get(x, y, z);
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_unpadded(x, y, z);
9393

9494
if block_id == BlockId::Air {
9595
continue;
@@ -103,7 +103,7 @@ pub fn create_chunk_mesh(chunk: &Chunk, texture_manager: &TextureManager) -> Opt
103103
y: usize,
104104
z: usize,
105105
) {
106-
if chunk.get(x, y, z) == BlockId::Air {
106+
if chunk.get_unpadded(x, y, z) == BlockId::Air {
107107
*mask |= value;
108108
}
109109
}
@@ -120,9 +120,9 @@ pub fn create_chunk_mesh(chunk: &Chunk, texture_manager: &TextureManager) -> Opt
120120
update_mask(chunk, &mut mask, 0b100000, x, y, z + 1);
121121

122122
let cube_data = create_cube_geometry_data(
123-
x as f32,
124-
y as f32,
125-
z as f32,
123+
(x - 1) as f32,
124+
(y - 1) as f32,
125+
(z - 1) as f32,
126126
mask,
127127
block_id,
128128
texture_manager,

0 commit comments

Comments
 (0)