cleanup
This commit is contained in:
parent
73d96aa69c
commit
33bb26b8e1
|
@ -26,7 +26,6 @@ pub struct CameraController {
|
|||
pub friction: f32,
|
||||
pub pitch: f32,
|
||||
pub yaw: f32,
|
||||
pub velocity: Vec3,
|
||||
}
|
||||
|
||||
impl Default for CameraController {
|
||||
|
@ -39,7 +38,6 @@ impl Default for CameraController {
|
|||
friction: 0.05,
|
||||
pitch: 1.0, // pitch=0/yaw=0 -> face sun
|
||||
yaw: 0.3,
|
||||
velocity: Vec3::ZERO,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -112,26 +110,18 @@ fn run_camera_controller(
|
|||
actor.v = Vec3::ZERO;
|
||||
}
|
||||
}
|
||||
let friction = if key_input.pressed(settings.key_stop) {
|
||||
controller.friction.clamp(0.0, 1.0)
|
||||
} else {
|
||||
0.0
|
||||
};
|
||||
|
||||
let mut engine = if let Ok(engine) = q_engine.get_single_mut() { engine } else { player_engine };
|
||||
|
||||
// Apply movement update
|
||||
let acceleration: Vec3;
|
||||
if axis_input != Vec3::ZERO {
|
||||
let new_velocity = controller.velocity + axis_input.normalize() * controller.move_speed;
|
||||
controller.velocity = new_velocity;
|
||||
acceleration = axis_input.normalize() * controller.move_speed;
|
||||
engine.current_warmup = (engine.current_warmup + dt / engine.warmup_seconds).clamp(0.0, 1.0);
|
||||
play_thruster_sound = !settings.mute_sfx;
|
||||
} else {
|
||||
controller.velocity *= 1.0 - friction;
|
||||
acceleration = Vec3::ZERO;
|
||||
engine.current_warmup = (engine.current_warmup - dt / engine.warmup_seconds).clamp(0.0, 1.0);
|
||||
if controller.velocity.length_squared() < 1e-6 {
|
||||
controller.velocity = Vec3::ZERO;
|
||||
}
|
||||
}
|
||||
|
||||
let forward = *transform.forward() * engine.current_warmup * (if axis_input.z > 0.0 {
|
||||
|
@ -141,11 +131,9 @@ 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 += controller.velocity.x * dt * right
|
||||
+ controller.velocity.y * dt * up
|
||||
+ controller.velocity.z * dt * forward;
|
||||
|
||||
controller.velocity = Vec3::ZERO;
|
||||
actor.v += acceleration.x * dt * right
|
||||
+ acceleration.y * dt * up
|
||||
+ acceleration.z * dt * forward;
|
||||
|
||||
// Handle mouse input
|
||||
let mut mouse_delta = Vec2::ZERO;
|
||||
|
|
Loading…
Reference in a new issue