diff options
| author | Jon Santmyer <jon@jonsantmyer.com> | 2026-05-24 13:04:10 -0400 |
|---|---|---|
| committer | Jon Santmyer <jon@jonsantmyer.com> | 2026-05-24 13:04:10 -0400 |
| commit | 0b428d94e751dc4a5fbe19418bfb5994cebfa54c (patch) | |
| tree | be9c338ec6b5e40ddb96d2d8ecb498b362851a2f /src/tacmap.rs | |
| parent | 14ca7b5fc15eb2618b46bde0cac85e37ebc9ebd9 (diff) | |
| download | systemic4x-0b428d94e751dc4a5fbe19418bfb5994cebfa54c.tar.gz systemic4x-0b428d94e751dc4a5fbe19418bfb5994cebfa54c.tar.bz2 systemic4x-0b428d94e751dc4a5fbe19418bfb5994cebfa54c.zip | |
Diffstat (limited to 'src/tacmap.rs')
| -rw-r--r-- | src/tacmap.rs | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/src/tacmap.rs b/src/tacmap.rs index e04db9d..d06c720 100644 --- a/src/tacmap.rs +++ b/src/tacmap.rs @@ -162,14 +162,13 @@ impl TacticalMap pub fn update( &mut self, - solar_system: &SolarSystem, + star_system: &SolarSystem, + fleets_man: &FleetsManager, ui_state: &mut ui::State, - time: Second, - dt: Duration) + _time: Second, + _dt: Duration) { self.camera.set_target(ui_state.camera_target); - - self.camera_controller.update(&mut self.camera, solar_system, ui_state, time, dt); } pub fn keyboard_input( @@ -187,6 +186,7 @@ impl TacticalMap fleets_man: &FleetsManager, solar_system: &SolarSystem, timeman: &TimeMan, + dt: Duration, ) -> Result<(), ()> { //Prepare canvas @@ -211,6 +211,13 @@ impl TacticalMap )); } + self.camera_controller.update( + &mut self.camera, + solar_system, + fleets_man, + timeman.seconds(), + dt); + self.camera.update_buffer(wgpuctx, &self.pmatrix); if self.system_for_render.is_none() @@ -298,7 +305,7 @@ impl TacticalMap &self, solar_system: &SolarSystem, time: Second, - screen_size: egui::Vec2, + panel_rect: &egui::Rect, ui: &mut egui::Ui) { let view_matrix = self.camera.view_matrix(); @@ -308,9 +315,9 @@ impl TacticalMap //Paint body labels let bodies = solar_system.bodies(); bodies.iter().for_each(|body| { - let scaled_radius = (screen_size.y * body.radius() * self.camera.get_scale()).max(16.0); + let scaled_radius = (panel_rect.height() * body.radius() * self.camera.get_scale()).max(16.0); - let offset_pos = body.relative_position(time); + let offset_pos = body.offset_position(time); let origin_pos = match body.get_orbit() { Some(orbit) => { solar_system.body_position(&bodies[orbit.parent()], time) @@ -336,8 +343,9 @@ impl TacticalMap } let screen_pos = egui::pos2( - ((ndc_pos.x + 1.0) * 0.5) * screen_size.x, - (((-ndc_pos.y + 1.0) * 0.5) * screen_size.y) + (scaled_radius / clip_pos.w).max(16.0)); + ((ndc_pos.x + 1.0) * 0.5) * panel_rect.width() + panel_rect.min.x, + (((-ndc_pos.y + 1.0) * 0.5) * panel_rect.height() + panel_rect.min.y) + + (scaled_radius / clip_pos.w).max(16.0)); if clip_pos.z < 0.0 { return; } ui.put( |
