diff options
Diffstat (limited to 'src/tacmap/body_render.rs')
| -rw-r--r-- | src/tacmap/body_render.rs | 24 |
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) }; |
