From 1b6093a38a6ccf6d067740ee39476b6184fa8236 Mon Sep 17 00:00:00 2001 From: eug-vs Date: Mon, 20 May 2024 01:17:13 +0200 Subject: feat: adjust camera speed for better FPS And other controls --- src/camera.rs | 4 ++-- src/main.rs | 16 ++++++++-------- src/sdf.rs | 4 ++-- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/camera.rs b/src/camera.rs index 7682553..7768b2b 100644 --- a/src/camera.rs +++ b/src/camera.rs @@ -35,8 +35,8 @@ impl Camera { up: Vector::unit_z(), distance, screen: Screen { width, height }, - speed: 0.5, - turn_rate: 60.0, + speed: 0.15, + turn_rate: 90.0, } } pub fn get_screen_iterator(self) -> ScreenIterator { diff --git a/src/main.rs b/src/main.rs index 5675fac..6b485d7 100644 --- a/src/main.rs +++ b/src/main.rs @@ -86,25 +86,25 @@ fn main() { } else if char == 106 { // j to move backward renderer.camera.position -= renderer.camera.direction * renderer.camera.speed; - } else if char == 72 { - // H to move left + } else if char == 104 { + // h to move left renderer.camera.position += Matrix3::from_axis_angle(renderer.camera.up, Rad::turn_div_4()) * renderer.camera.direction * renderer.camera.speed; - } else if char == 76 { - // L to move right + } else if char == 108 { + // l to move right renderer.camera.position -= Matrix3::from_axis_angle(renderer.camera.up, Rad::turn_div_4()) * renderer.camera.direction * renderer.camera.speed; - } else if char == 104 { - // h to rotate left + } else if char == 72 { + // H to rotate left let rotation = Matrix3::from_angle_z(Rad::full_turn() / renderer.camera.turn_rate); renderer.camera.direction = rotation * renderer.camera.direction; renderer.camera.up = rotation * renderer.camera.up; - } else if char == 108 { - // l to rotate right + } else if char == 76 { + // L to rotate right let rotation = Matrix3::from_angle_z(-Rad::full_turn() / renderer.camera.turn_rate); renderer.camera.direction = rotation * renderer.camera.direction; renderer.camera.up = rotation * renderer.camera.up; diff --git a/src/sdf.rs b/src/sdf.rs index 3204305..f3b9ac1 100644 --- a/src/sdf.rs +++ b/src/sdf.rs @@ -14,8 +14,8 @@ pub struct Sphere { } impl Object for Sphere { - fn sdf(&self, point: Vector, time: f32) -> f32 { - (point - self.center).magnitude() - self.radius + (time % 5.0) / 50.0 + fn sdf(&self, point: Vector, _time: f32) -> f32 { + (point - self.center).magnitude() - self.radius } } -- cgit v1.2.3