fixed collision solving causing an inability to escape a surface

This commit is contained in:
Sara 2023-10-24 23:57:38 +02:00
parent d3612873ff
commit 07f534f796

View file

@ -80,7 +80,9 @@ void physics_entity_solve_contacts(PhysicsEntity self, List* contacts) {
}
Vector dir = vnormalizedf(vsubf(rigidbody_get_transform(body)->position, pre_solve.position));
Vector vel = rigidbody_get_velocity(body);
vel = vsubf(vel, vprojectf(dir, vel));
float dot = vdotf(dir, vel);
if(dot < 0)
vel = vsubf(vel, vmulff(dir, dot));
rigidbody_set_velocity(body, vel);
}