Skip to content

Commit 6e3bf55

Browse files
committed
remove unused feature
1 parent 2864036 commit 6e3bf55

File tree

8 files changed

+32
-41
lines changed

8 files changed

+32
-41
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/target
22
.idea
33
.vscode
4+
.vs
45
data.txt
56
chunks
67
data

src/chunk.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -331,9 +331,12 @@ impl Chunk {
331331
if z < 0 {
332332
z = NOISE_SIZE as i32 + (z % (NOISE_CHUNK_PER_ROW * CHUNK_SIZE) as i32);
333333
}
334-
335-
let y_top = (noise_data[((z * (NOISE_SIZE - 1) as i32) + x) as usize] + 1.0) * 0.5;
336-
return (f32::powf(100.0, y_top) - 1.0) as u32;
334+
if let Some(v) = noise_data.get((z * (NOISE_SIZE as i32) + x) as usize) {
335+
let y_top = (v + 1.0) * 0.5;
336+
return (f32::powf(100.0, y_top) - 1.0) as u32;
337+
} else {
338+
return 0;
339+
}
337340
}
338341

339342
pub fn create_blocks_data(chunk_x: i32, chunk_y: i32, noise_data: Arc<NoiseData>) -> BlockVec {

src/pipelines/highlight_selected.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,6 @@ impl Pipeline for HighlightSelectedPipeline {
158158
})],
159159
}),
160160
primitive: wgpu::PrimitiveState {
161-
polygon_mode: state.config.polygon_mode,
162161
cull_mode: Some(wgpu::Face::Front),
163162
..Default::default()
164163
},

src/pipelines/main.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,6 @@ impl Pipeline for MainPipeline {
265265
}),
266266

267267
primitive: wgpu::PrimitiveState {
268-
polygon_mode: state.config.polygon_mode,
269268
cull_mode: Some(Face::Front),
270269
..Default::default()
271270
},

src/pipelines/translucent.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@ impl Pipeline for TranslucentPipeline {
9696
})],
9797
}),
9898
primitive: wgpu::PrimitiveState {
99-
polygon_mode: state.config.polygon_mode,
10099
cull_mode: Some(wgpu::Face::Front),
101100
..Default::default()
102101
},

src/pipelines/ui.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,6 @@ impl Pipeline for UIPipeline {
124124
}),
125125

126126
primitive: wgpu::PrimitiveState {
127-
polygon_mode: state.config.polygon_mode,
128127
cull_mode: None,
129128
..Default::default()
130129
},

src/player.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,19 @@ impl Player {
7272
0.8,
7373
)
7474
}
75+
pub fn next_placing_block(&mut self, offset: i32) {
76+
// Delta is {1, -1}
77+
let placing_block_id = self.placing_block.to_id();
78+
let mut next_block_id = (((placing_block_id as i32 + offset as i32)
79+
+ (BlockType::MAX_ID + 1) as i32)
80+
% (BlockType::MAX_ID + 1) as i32) as i32;
81+
82+
if next_block_id == BlockType::Water.to_id() as i32 {
83+
next_block_id += 1 * offset as i32;
84+
}
85+
86+
self.placing_block = BlockType::from_id(next_block_id as u32);
87+
}
7588
// Gets the block that the player is facing
7689
pub fn get_facing_block<'a>(
7790
&mut self,

src/state.rs

Lines changed: 12 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ pub struct State {
3333
pub pipeline_manager: PipelineManager,
3434
pub player: Arc<RwLock<Player>>,
3535
pub world: World,
36-
pub config: Config,
3736
pub camera_controller: CameraController,
3837
}
3938

@@ -57,7 +56,7 @@ impl State {
5756
.request_device(
5857
&wgpu::DeviceDescriptor {
5958
label: None,
60-
features: wgpu::Features::POLYGON_MODE_LINE,
59+
features: wgpu::Features::empty(),
6160
limits: wgpu::Limits::default(),
6261
},
6362
None,
@@ -101,15 +100,11 @@ impl State {
101100
}));
102101

103102
surface.configure(&device, &surface_config);
104-
let config = Config {
105-
polygon_mode: wgpu::PolygonMode::Fill,
106-
};
107103

108104
let mut world = World::init_world(device.clone(), queue.clone());
109105
world.init_chunks(Arc::clone(&player));
110106

111107
let mut state = Self {
112-
config,
113108
player,
114109
surface_config,
115110
instance,
@@ -188,13 +183,14 @@ impl State {
188183
} => self.camera_controller.movement_vector.y = -1.0 * is_pressed,
189184
KeyEvent {
190185
physical_key: PhysicalKey::Code(KeyCode::KeyK),
186+
state: winit::event::ElementState::Pressed,
191187
..
192-
} => self
193-
.window
194-
.lock()
195-
.unwrap()
196-
.set_cursor_grab(CursorGrabMode::Confined)
197-
.unwrap(),
188+
} => player.next_placing_block(-1),
189+
KeyEvent {
190+
physical_key: PhysicalKey::Code(KeyCode::KeyJ),
191+
state: winit::event::ElementState::Pressed,
192+
..
193+
} => player.next_placing_block(1),
198194
KeyEvent {
199195
physical_key: PhysicalKey::Code(KeyCode::Space),
200196
state: winit::event::ElementState::Pressed,
@@ -212,17 +208,6 @@ impl State {
212208
} => {
213209
player.is_ghost = !player.is_ghost;
214210
}
215-
KeyEvent {
216-
physical_key: PhysicalKey::Code(KeyCode::KeyF),
217-
state: winit::event::ElementState::Pressed,
218-
..
219-
} => {
220-
if self.config.polygon_mode == wgpu::PolygonMode::Line {
221-
self.config.polygon_mode = wgpu::PolygonMode::Fill
222-
} else {
223-
self.config.polygon_mode = wgpu::PolygonMode::Line
224-
}
225-
}
226211
_ => {}
227212
}
228213
}
@@ -258,17 +243,10 @@ impl State {
258243
}
259244
}
260245
pub fn handle_wheel(&mut self, delta: f32) {
261-
// Delta is {1.0, -1.0}
262-
let palcing_block_id = self.player.read().unwrap().placing_block.to_id();
263-
let mut next_block_id = (((palcing_block_id as i32 + delta as i32)
264-
+ (BlockType::MAX_ID + 1) as i32)
265-
% (BlockType::MAX_ID + 1) as i32) as i32;
266-
267-
if next_block_id == BlockType::Water.to_id() as i32 {
268-
next_block_id += 1 * delta as i32;
269-
}
270-
271-
self.player.write().unwrap().placing_block = BlockType::from_id(next_block_id as u32);
246+
self.player
247+
.write()
248+
.unwrap()
249+
.next_placing_block(delta as i32);
272250
}
273251
pub fn handle_mouse(&mut self, delta: &glam::Vec2) {
274252
self.player.write().unwrap().camera.move_target(delta)

0 commit comments

Comments
 (0)