From 3a446b675b5fb7b899a660f1d1373432a913dd04 Mon Sep 17 00:00:00 2001 From: griffi-gh Date: Wed, 18 Jan 2023 19:10:58 +0100 Subject: [PATCH] khkhyvctyctcggc --- Cargo.toml | 1 + src/game/physics.rs | 8 ++++++++ 2 files changed, 9 insertions(+) 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