diff --git a/Cargo.toml b/Cargo.toml index 4c5e90c..20a81de 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,6 +16,7 @@ glam = { version = "0.22", features = ["debug-glam-assert", "mint", "fast-math"] hashbrown = "0.13" noise = "0.8" rayon = "1.6" +#ordered-float = "3.4" [features] default = [] diff --git a/src/game/physics.rs b/src/game/physics.rs index a05cfc7..a0e0d2c 100644 --- a/src/game/physics.rs +++ b/src/game/physics.rs @@ -23,9 +23,17 @@ impl BasicPhysicsActor { self.position += self.velocity; loop { let block_pos = self.position.floor().as_ivec3(); + let block_pos_f = block_pos.as_vec3a(); if let Some(block) = world.try_get(block_pos) { match block.descriptor().collision { Some(super::blocks::CollisionType::Solid) => { + let position_delta = self.position - block_pos_f; + let distance_to_zero = position_delta.abs(); + let distance_to_one = (vec3a(1., 1., 1.) - position_delta).abs(); + + // let mut max_distance = 0; + // let mut max_distance_normal = 0; + // distance_to_one.x //todo compute restitution here } _ => break