fix constrain

This commit is contained in:
Quaternions 2023-11-06 16:35:42 -08:00
parent 432a38718c
commit 535ae1a5f0

View File

@ -748,17 +748,21 @@ impl TouchingState{
for contact in &self.contacts{ for contact in &self.contacts{
let (n,_)=models.mesh(contact.model_id).face_nd(contact.face_id); let (n,_)=models.mesh(contact.model_id).face_nd(contact.face_id);
let d=n.dot(*velocity); let d=n.dot(*velocity);
if d<Planar64::ZERO{
*velocity-=n*(d/n.dot(n)); *velocity-=n*(d/n.dot(n));
} }
} }
}
fn constrain_acceleration(&self,models:&PhysicsModels,acceleration:&mut Planar64Vec3){ fn constrain_acceleration(&self,models:&PhysicsModels,acceleration:&mut Planar64Vec3){
//TODO: trey push solve //TODO: trey push solve
for contact in &self.contacts{ for contact in &self.contacts{
let n=models.mesh(contact.model_id).face_nd(contact.face_id).0; let n=models.mesh(contact.model_id).face_nd(contact.face_id).0;
let d=n.dot(*acceleration); let d=n.dot(*acceleration);
if d<Planar64::ZERO{
*acceleration-=n*(d/n.dot(n)); *acceleration-=n*(d/n.dot(n));
} }
} }
}
fn get_move_state(&self,mut a:Planar64Vec3)->(MoveState,Planar64Vec3){ fn get_move_state(&self,mut a:Planar64Vec3)->(MoveState,Planar64Vec3){
//check current move conditions and use heuristics to determine //check current move conditions and use heuristics to determine
//which ladder to climb on, which ground to walk on, etc //which ladder to climb on, which ground to walk on, etc