From cff920ddcdc8b03722e42a0d32cee4a17a0a6734 Mon Sep 17 00:00:00 2001 From: Quaternions Date: Wed, 8 Nov 2023 20:23:52 -0800 Subject: [PATCH] tweak elasticity calc --- src/physics.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/physics.rs b/src/physics.rs index 90be5dd..d9b433a 100644 --- a/src/physics.rs +++ b/src/physics.rs @@ -1353,8 +1353,9 @@ impl crate::instruction::InstructionConsumer for PhysicsStat Some(crate::model::ContactingBehaviour::Cling)=>println!("Unimplemented!"), &Some(crate::model::ContactingBehaviour::Elastic(elasticity))=>{ let n=self.models.mesh(contact.model_id).face_nd(contact.face_id).0; - let d=n.dot(v)*Planar64::raw(-1-elasticity as i64); - v-=n*(d/n.dot(n)); + //velocity and normal are facing opposite directions so this is inherently negative. + let d=n.dot(v)*(Planar64::ONE+Planar64::raw(elasticity as i64+1)); + v+=n*(d/n.dot(n)); }, Some(crate::model::ContactingBehaviour::Ladder(contacting_ladder))=>{ if contacting_ladder.sticky{