chore(client): add reasons to expect attributes
This commit is contained in:
parent
f7e986cb24
commit
8a5c662e10
|
|
@ -59,7 +59,10 @@ impl Camera {
|
|||
/// Advances the camera by a single frame, applying `input` accumulated over `dt` seconds.
|
||||
pub fn update(&mut self, input: &InputState, dt: f32) {
|
||||
// Apply accumulated mouse motion to the orientation. A downward mouse delta (positive y) lowers the pitch, so the vertical term is subtracted.
|
||||
#[expect(clippy::cast_possible_truncation)]
|
||||
#[expect(
|
||||
clippy::cast_possible_truncation,
|
||||
reason = "mouse deltas are small; f32 precision is sufficient for camera input"
|
||||
)]
|
||||
{
|
||||
self.yaw += input.mouse_delta.0 as f32 * self.sensitivity;
|
||||
self.pitch -= input.mouse_delta.1 as f32 * self.sensitivity;
|
||||
|
|
|
|||
|
|
@ -22,8 +22,10 @@ use winit::window::{CursorGrabMode, Window, WindowId};
|
|||
/// Transient per-frame input state sampled from window and device events.
|
||||
///
|
||||
/// Keyboard fields hold whether a movement key is currently pressed. `mouse_delta` accumulates raw pointer motion between frames and is consumed (reset to zero) once applied to the camera.
|
||||
// The bools are independent per-key held states, for which a flat struct is the clearest form.
|
||||
#[expect(clippy::struct_excessive_bools)]
|
||||
#[expect(
|
||||
clippy::struct_excessive_bools,
|
||||
reason = "per-key held states are independent; a flat bool struct is the clearest representation"
|
||||
)]
|
||||
#[derive(Default)]
|
||||
struct InputState {
|
||||
/// Whether the "move forward" key (W) is held.
|
||||
|
|
@ -141,10 +143,16 @@ impl ApplicationHandler for App {
|
|||
self.window = Some(window);
|
||||
self.renderer = Some(renderer);
|
||||
|
||||
#[expect(clippy::expect_used)]
|
||||
#[expect(
|
||||
clippy::expect_used,
|
||||
reason = "startup asset load; a missing worldgen config is unrecoverable at launch"
|
||||
)]
|
||||
let config_str = std::fs::read_to_string("assets/data/worldgen/default.json")
|
||||
.expect("Failed to read worldgen config");
|
||||
#[expect(clippy::expect_used)]
|
||||
#[expect(
|
||||
clippy::expect_used,
|
||||
reason = "startup config parse; a malformed worldgen config is unrecoverable at launch"
|
||||
)]
|
||||
let worldgen_config: shared::generator::WorldGenConfig =
|
||||
serde_json::from_str(&config_str).expect("Failed to parse worldgen config");
|
||||
|
||||
|
|
@ -160,7 +168,10 @@ impl ApplicationHandler for App {
|
|||
indices.len()
|
||||
);
|
||||
|
||||
#[expect(clippy::expect_used)]
|
||||
#[expect(
|
||||
clippy::expect_used,
|
||||
reason = "the renderer is assigned earlier in this function"
|
||||
)]
|
||||
self.renderer
|
||||
.as_mut()
|
||||
.expect("Renderer initialized")
|
||||
|
|
|
|||
|
|
@ -6,7 +6,8 @@ use shared::world::{BlockId, CHUNK_SIZE, Chunk};
|
|||
#[expect(
|
||||
clippy::cast_precision_loss,
|
||||
clippy::cast_possible_truncation,
|
||||
clippy::too_many_lines
|
||||
clippy::too_many_lines,
|
||||
reason = "voxel coordinates and vertex counts are small and lossless as f32/u32; the per-face unrolling is intentionally long"
|
||||
)]
|
||||
pub fn generate_mesh(chunk: &Chunk) -> (Vec<Vertex>, Vec<u32>) {
|
||||
let mut vertices = Vec::new();
|
||||
|
|
|
|||
Loading…
Reference in a new issue