This commit is contained in:
yuni 2024-03-29 01:19:37 +01:00
parent 33bb26b8e1
commit 57d651ad04

View file

@ -22,8 +22,6 @@ pub struct CameraController {
pub enabled: bool,
pub initialized: bool,
pub sensitivity: f32,
pub move_speed: f32,
pub friction: f32,
pub pitch: f32,
pub yaw: f32,
}
@ -34,8 +32,6 @@ impl Default for CameraController {
enabled: true,
initialized: false,
sensitivity: 0.5,
move_speed: 30.0,
friction: 0.05,
pitch: 1.0, // pitch=0/yaw=0 -> face sun
yaw: 0.3,
}
@ -105,7 +101,6 @@ fn run_camera_controller(
}
if key_input.pressed(settings.key_stop) {
actor.v = actor.v * (1.0 - controller.friction);
if actor.v.length_squared() < 1e-6 {
actor.v = Vec3::ZERO;
}
@ -116,7 +111,7 @@ fn run_camera_controller(
// Apply movement update
let acceleration: Vec3;
if axis_input != Vec3::ZERO {
acceleration = axis_input.normalize() * controller.move_speed;
acceleration = axis_input.normalize();
engine.current_warmup = (engine.current_warmup + dt / engine.warmup_seconds).clamp(0.0, 1.0);
play_thruster_sound = !settings.mute_sfx;
} else {
@ -131,9 +126,12 @@ fn run_camera_controller(
});
let right = *transform.right() * engine.thrust_sideways * engine.current_warmup;
let up = *transform.up() * engine.thrust_sideways * engine.current_warmup;
actor.v += acceleration.x * dt * right
+ acceleration.y * dt * up
+ acceleration.z * dt * forward;
let speed_multiplier = 30.0;
actor.v += speed_multiplier * dt *
( acceleration.x * right
+ acceleration.y * up
+ acceleration.z * forward);
// Handle mouse input
let mut mouse_delta = Vec2::ZERO;