KMU4E426CB2NDRJEK7B4GSL22P62CJPPZRK45X3JV5WP5NIBIGRQC }/// Syncs the physics system's results back into the world////// alpha is a % of the fixed timestep used by update that is unused in the frame,/// so this must be [0.0, 1.0)pub fn physics_sync(&mut self, delta: f32) {// sync the state that is lerped between the previous state and the current state by alphalet actual_state = self.current_state.lerp(&self.previous_state, delta);_ = actual_state;
/// The angle the physics system assumes the orthogonal view is looking at./// This is *not* used by the physics system for anything except/// converting its internal position to a 2d position understandable by other systems.// Valid angles are [0.0, pi/2).// 0.0 means the viewer is looking straight at the ground, so z position has no effect.// pi/2 means the view is looking *parallel* to the ground, which is not a valid angle for looking at objects// (the orthogonal approximation only works when approximating an infinitely distant viewer, so looking at angle pi/2// from the ground means that to see an object, its z must be at *least* infinity, which isn't possible)pub const VIEW_ANGLE: f32 = std::f32::consts::FRAC_PI_4;
fn lerp(&self, to: &PhysicsObject, alpha: f32) -> PhysicsObject {Self {}
fn lerp(&self, from: &Self, delta: f32) -> Self {let position = self.position * delta + from.position * (1.0 - delta);Self { position }}/// Get the position// Maps our internal 3d position into a 2d displayable positionfn position(&self) -> glam::Vec2 {// Physics is a 3d system.// to get the display (x, y), use// (x, y - z * VIEW_ANGLE.tan())glam::Vec2::new(self.position.x,self.position.y - VIEW_ANGLE.tan() * self.position.z,)
#[cfg(test)]mod tests;