mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Added 'perfect' collisions
This commit is contained in:
parent
6bb48760d7
commit
0f0f28284c
@ -219,7 +219,7 @@ impl<'a> System<'a> for Sys {
|
||||
pos.0 += pos_delta / increments;
|
||||
|
||||
// While the player is colliding with the terrain...
|
||||
while collision_with(pos.0, near_iter.clone()) && attempts < 32 {
|
||||
while collision_with(pos.0, near_iter.clone()) && attempts < 12 {
|
||||
// Calculate the player's AABB
|
||||
let player_aabb = Aabb {
|
||||
min: pos.0 + Vec3::new(-player_rad, -player_rad, 0.0),
|
||||
@ -283,7 +283,7 @@ impl<'a> System<'a> for Sys {
|
||||
// ...and we're being pushed out horizontally...
|
||||
&& resolve_dir.z == 0.0
|
||||
// ...and the vertical resolution direction is sufficiently great...
|
||||
&& -dir.z > 0.5
|
||||
&& -dir.z > 0.1
|
||||
// ...and we're falling/standing OR there is a block *directly* beneath our current origin (note: not hitbox)...
|
||||
&& (vel.0.z <= 0.0 || terrain
|
||||
.get((pos.0 - Vec3::unit_z()).map(|e| e.floor() as i32))
|
||||
@ -302,9 +302,10 @@ impl<'a> System<'a> for Sys {
|
||||
} else {
|
||||
// Resolve the collision normally
|
||||
pos.0 += resolve_dir;
|
||||
vel.0 = vel
|
||||
.0
|
||||
.map2(resolve_dir, |e, d| if d == 0.0 { e } else { 0.0 });
|
||||
vel.0 = vel.0.map2(
|
||||
resolve_dir,
|
||||
|e, d| if d * e.signum() < 0.0 { 0.0 } else { e },
|
||||
);
|
||||
}
|
||||
|
||||
attempts += 1;
|
||||
|
Loading…
Reference in New Issue
Block a user