fixed collision solving causing an inability to escape a surface
This commit is contained in:
parent
d3612873ff
commit
07f534f796
|
@ -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 dir = vnormalizedf(vsubf(rigidbody_get_transform(body)->position, pre_solve.position));
|
||||||
Vector vel = rigidbody_get_velocity(body);
|
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);
|
rigidbody_set_velocity(body, vel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue