Skip to content

Commit

Permalink
clippy & fmt & doc
Browse files Browse the repository at this point in the history
  • Loading branch information
-karlos- committed Jan 28, 2024
1 parent 20824c3 commit 9136bf3
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 30 deletions.
4 changes: 2 additions & 2 deletions src/big_space.rs
Original file line number Diff line number Diff line change
@@ -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: `<https://github.com/oli-obk/big_space/tree/world_query>`
//! a clone of: `<https://github.com/aevyrie/big_space/tree/main>`
//!
//! 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
Expand Down
1 change: 0 additions & 1 deletion src/big_space/world_query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ pub struct Directions {
}

impl<P: GridPrecision> GridTransformOwned<P> {

/// Calculates cardinal directions at any cartesian position.
pub fn directions(&self) -> Directions {
let up = self.transform.translation.normalize();
Expand Down
12 changes: 5 additions & 7 deletions src/f4control.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -264,12 +265,9 @@ pub struct Plugin;

impl bevy::prelude::Plugin for Plugin {
fn build(&self, app: &mut App) {
app
// .init_resource::<MovementValues>()
.add_systems(Startup, setup)
app.add_systems(Startup, setup)
.init_resource::<KeyBindings>()
.add_systems(Update, player_keys)
.add_systems(Update, player_mouse)
;
.add_systems(Update, player_mouse);
}
}
4 changes: 2 additions & 2 deletions src/flycontrol.rs
Original file line number Diff line number Diff line change
@@ -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 `<https://github.com/oli-obk/bevy_flycam>`, branch = "arbitrary_up", a
//! branch of `<https://github.com/sburris0/bevy_flycam>`
use bevy::input::mouse::MouseMotion;
use bevy::prelude::*;
Expand Down
12 changes: 2 additions & 10 deletions src/geocoord.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,36 +87,28 @@ 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 {
fn forward(dir: f32) -> Vec2;
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.;
11 changes: 7 additions & 4 deletions src/geoview.rs
Original file line number Diff line number Diff line change
@@ -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},
Expand Down Expand Up @@ -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;
}

/**
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 0 additions & 4 deletions src/player.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -304,10 +303,7 @@ impl bevy::prelude::Plugin for Plugin {
.init_resource::<InputState>()
.add_systems(Startup, setup_player_controls)
.add_systems(Update, update_camera_speed);

}
}

pub const OSM_LAT_LIMIT: f32 = 85.0511; // degrees


0 comments on commit 9136bf3

Please sign in to comment.