From 9136bf3bbdcc099df666c877a6c4b4d346e34ce4 Mon Sep 17 00:00:00 2001 From: -karlos- Date: Sun, 28 Jan 2024 20:58:07 +0100 Subject: [PATCH] clippy & fmt & doc --- src/big_space.rs | 4 ++-- src/big_space/world_query.rs | 1 - src/f4control.rs | 12 +++++------- src/flycontrol.rs | 4 ++-- src/geocoord.rs | 12 ++---------- src/geoview.rs | 11 +++++++---- src/player.rs | 4 ---- 7 files changed, 18 insertions(+), 30 deletions(-) diff --git a/src/big_space.rs b/src/big_space.rs index 9dcee88..fad6347 100644 --- a/src/big_space.rs +++ b/src/big_space.rs @@ -1,5 +1,5 @@ -//! Copied form: https://github.com/oli-obk/big_space/tree/world_query -//! a clone of: https://github.com/aevyrie/big_space/tree/main +//! Copied form: `` +//! a clone of: `` //! //! This [`bevy`] plugin makes it easy to build high-precision worlds that exceed the size of the //! observable universe, with no added dependencies, while remaining largely compatible with the diff --git a/src/big_space/world_query.rs b/src/big_space/world_query.rs index 76300af..93f0689 100644 --- a/src/big_space/world_query.rs +++ b/src/big_space/world_query.rs @@ -79,7 +79,6 @@ pub struct Directions { } impl GridTransformOwned

{ - /// Calculates cardinal directions at any cartesian position. pub fn directions(&self) -> Directions { let up = self.transform.translation.normalize(); diff --git a/src/f4control.rs b/src/f4control.rs index 966046d..4b44f1b 100644 --- a/src/f4control.rs +++ b/src/f4control.rs @@ -56,8 +56,8 @@ pub mod prelude { pub use crate::*; } +use crate::geocoord::{GeoDir, GeoDirTrait}; use crate::player::{ControlValues, InputState, PlayerQuery}; -use crate::geocoord::{GeoDir,GeoDirTrait}; /// Key configuration #[derive(Resource)] @@ -234,7 +234,8 @@ fn player_mouse( if mouse_input.pressed(MouseButton::Left) { moved = true; let groundmove_fact_lat = speed / 500000.0; - let groundmove_fact_lon = groundmove_fact_lat / view.geo_coord.lat.to_radians().sin(); + let groundmove_fact_lon = + groundmove_fact_lat / view.geo_coord.lat.to_radians().sin(); let groundmove_fact = Vec2::new(groundmove_fact_lon, groundmove_fact_lat); let velocity = forward * -pitch + right * yaw; @@ -264,12 +265,9 @@ pub struct Plugin; impl bevy::prelude::Plugin for Plugin { fn build(&self, app: &mut App) { - app -// .init_resource::() - .add_systems(Startup, setup) + app.add_systems(Startup, setup) .init_resource::() .add_systems(Update, player_keys) - .add_systems(Update, player_mouse) - ; + .add_systems(Update, player_mouse); } } diff --git a/src/flycontrol.rs b/src/flycontrol.rs index 496e266..2f5c825 100644 --- a/src/flycontrol.rs +++ b/src/flycontrol.rs @@ -1,8 +1,8 @@ //! This module contains everything about the fly-controls and rendering related //! to the non-VR "player". Todo: update //! -//! A Copy of "https://github.com/oli-obk/bevy_flycam", branch = "arbitrary_up", a -//! branch of "https://github.com/sburris0/bevy_flycam" +//! A Copy of ``, branch = "arbitrary_up", a +//! branch of `` use bevy::input::mouse::MouseMotion; use bevy::prelude::*; diff --git a/src/geocoord.rs b/src/geocoord.rs index b46b310..6593763 100644 --- a/src/geocoord.rs +++ b/src/geocoord.rs @@ -87,12 +87,9 @@ impl GeoCoord { pub fn add_move(&mut self, moved: GeoDir) { self.lat += moved.y; self.lon += moved.x; - } } - - pub type GeoDir = Vec2; pub trait GeoDirTrait { @@ -100,23 +97,18 @@ pub trait GeoDirTrait { fn right(dir: f32) -> Vec2; } - impl GeoDirTrait for GeoDir { - fn forward(dir: f32) -> Vec2 { let (sin, cos) = dir.sin_cos(); - Vec2{x: -sin, y: cos} + Vec2 { x: -sin, y: cos } } fn right(dir: f32) -> Vec2 { let (sin, cos) = dir.sin_cos(); - Vec2{x: cos, y: sin} + Vec2 { x: cos, y: sin } } } - - - pub const EARTH_RADIUS: f32 = 6_378_000.; pub const MOON_RADIUS: f32 = 01_737_400.; pub const MOON_ORBIT: f32 = 384_400_000.; diff --git a/src/geoview.rs b/src/geoview.rs index 222ccbd..a8a4e6b 100644 --- a/src/geoview.rs +++ b/src/geoview.rs @@ -1,6 +1,8 @@ use super::geocoord::*; use super::GalacticTransformOwned; -use crate::player::{CamControlMode, ControlValues, PlayerGalacticTransform, PlayerQuery, OSM_LAT_LIMIT}; +use crate::player::{ + CamControlMode, ControlValues, PlayerGalacticTransform, PlayerQuery, OSM_LAT_LIMIT, +}; use bevy::{ prelude::*, utils::tracing::{self, instrument}, @@ -54,7 +56,7 @@ impl GeoView { self.up_view = self.up_view.clamp(-OSM_LAT_LIMIT, OSM_LAT_LIMIT); self.elevation = self.elevation.clamp(0.4, ELEVATION_LIMIT); self.distance = self.distance.clamp(0.4, ELEVATION_LIMIT); - self.direction = self.direction % 360.0; + self.direction %= 360.0; } /** @@ -120,9 +122,10 @@ impl GeoView { let directions = p_starting_transform.directions(); - let mut starting_transform: GalacticTransformOwned = p_starting_transform.galactic_transform; + let mut starting_transform: GalacticTransformOwned = + p_starting_transform.galactic_transform; - // let directions = starting_transform.directions(); + // let directions = starting_transform.directions(); // Add camera / player height above ground starting_transform.transform.translation += directions.up * self.elevation; diff --git a/src/player.rs b/src/player.rs index 95222f9..61a82bf 100644 --- a/src/player.rs +++ b/src/player.rs @@ -158,7 +158,6 @@ impl<'w, 's> PlayerQuery<'w, 's> { *pos.cell = new_pos.cell; *pos.transform = new_pos.transform; } - } /// A marker component used in queries when you want camera-controls @@ -304,10 +303,7 @@ impl bevy::prelude::Plugin for Plugin { .init_resource::() .add_systems(Startup, setup_player_controls) .add_systems(Update, update_camera_speed); - } } pub const OSM_LAT_LIMIT: f32 = 85.0511; // degrees - -