summaryrefslogtreecommitdiffstats
path: root/src/tacmap/body_render.rs
diff options
context:
space:
mode:
authorJon Santmyer <jon@jonsantmyer.com>2026-05-06 12:01:42 -0400
committerJon Santmyer <jon@jonsantmyer.com>2026-05-06 12:01:42 -0400
commit9788d9037ad7199701b1710c28559cb96bce5aec (patch)
treec490b40b1f0057c98c2b4bb3c2593f915313d14f /src/tacmap/body_render.rs
parentd67fca88b17120566a93004c99dadeef0a61964b (diff)
downloadsystemic4x-9788d9037ad7199701b1710c28559cb96bce5aec.tar.gz
systemic4x-9788d9037ad7199701b1710c28559cb96bce5aec.tar.bz2
systemic4x-9788d9037ad7199701b1710c28559cb96bce5aec.zip
regenerate orbit lines based on system tick interval
Diffstat (limited to 'src/tacmap/body_render.rs')
-rw-r--r--src/tacmap/body_render.rs24
1 files changed, 18 insertions, 6 deletions
diff --git a/src/tacmap/body_render.rs b/src/tacmap/body_render.rs
index 8b32532..92ac13f 100644
--- a/src/tacmap/body_render.rs
+++ b/src/tacmap/body_render.rs
@@ -1,7 +1,7 @@
use std::error::Error;
use crate::solar_system::Kilometers;
-use crate::timeman::Second;
+use crate::timeman::{SYSTEM_TICK_INTERVAL, Second};
use crate::wgpuctx::{WgpuCtx, pipeline::RenderPipelineBuilder};
use super::*;
@@ -92,6 +92,18 @@ impl BodyRenderer
return Ok(());
}
+ //Round to the nearest tick
+ let tick_time = match self.last_time {
+ Some(last_time) => {
+ let this_tick = time / SYSTEM_TICK_INTERVAL;
+ let last_tick = last_time / SYSTEM_TICK_INTERVAL;
+
+ if this_tick == last_tick { return Ok(()) }
+ this_tick * SYSTEM_TICK_INTERVAL
+ }
+ None => 0
+ };
+
self.last_time = Some(time);
let (_, bodies_buffer) = match &self.body_instance_buffer {
@@ -101,11 +113,11 @@ impl BodyRenderer
let bodies = solar_system.bodies();
let body_instances = bodies.iter().map(|body| {
- let position = body.position();
- let origin = match body.get_orbits() {
- Some(origin_id) => {
- let origin_body = &bodies[origin_id];
- origin_body.position()
+ let position = body.relative_position();
+ let origin = match body.get_orbit() {
+ Some(orbit) => {
+ let origin_body = &bodies[orbit.parent()];
+ origin_body.relative_position()
},
None => cgmath::Vector3::new(0.0, 0.0, 0.0)
};