Skip to content

Commit

Permalink
Record view and dir in get_camera_view
Browse files Browse the repository at this point in the history
  • Loading branch information
oli-obk committed Dec 15, 2023
1 parent 31b2967 commit 537df16
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions src/geoview.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
use super::geopos::*;
use crate::player::Player;
use bevy::prelude::*;
use bevy::{
prelude::*,
utils::tracing::{self, instrument},
};
use big_space::FloatingOriginSettings;
use std::{collections::HashMap, f32::consts::FRAC_PI_2};

Expand Down Expand Up @@ -116,19 +119,25 @@ impl GeoView {
player.set_pos(starting_position);
}

#[instrument(level = "debug", skip(space, player), ret)]
pub fn get_camera_view(space: &FloatingOriginSettings, player: &Player) -> Self {
let position = player.pos();

let geo_pos = position.to_planetary_position().to_geopos();
info!(?geo_pos); // wrong!: lat: 31.906904, lon: 93.580765
let height = position.position_double(space).length() as f32 - crate::geopos::EARTH_RADIUS;
info!(?height);
let forward = position.pos.transform.forward();
let directions = position.directions();
let view = forward.angle_between(-directions.up).to_degrees();
let dir = forward
.cross(directions.up)
.cross(position.pos.transform.right())
.angle_between(directions.north);

Self {
geo_pos,
height,
dir: 0.,
view: 0.,
dir,
view,
radius: 6.,
fov: 7.,
}
Expand Down

0 comments on commit 537df16

Please sign in to comment.