mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Added attempts counter to prevent infinite collision loops
This commit is contained in:
parent
44f4031e58
commit
6258035a4d
@ -198,7 +198,8 @@ impl<'a> System<'a> for Sys {
|
|||||||
pos.0.z -= 0.0001; // To force collision with the floor
|
pos.0.z -= 0.0001; // To force collision with the floor
|
||||||
|
|
||||||
let mut on_ground = false;
|
let mut on_ground = false;
|
||||||
while collision_with(pos.0, near_iter.clone()) {
|
let mut attempts = 0;
|
||||||
|
while collision_with(pos.0, near_iter.clone()) && attempts < 32 {
|
||||||
let player_aabb = Aabb {
|
let player_aabb = Aabb {
|
||||||
min: pos.0 + Vec3::new(-player_rad, -player_rad, 0.0),
|
min: pos.0 + Vec3::new(-player_rad, -player_rad, 0.0),
|
||||||
max: pos.0 + Vec3::new(player_rad, player_rad, player_height),
|
max: pos.0 + Vec3::new(player_rad, player_rad, player_height),
|
||||||
@ -245,6 +246,8 @@ impl<'a> System<'a> for Sys {
|
|||||||
.0
|
.0
|
||||||
.map2(resolve_dir, |e, d| if d == 0.0 { e } else { 0.0 });
|
.map2(resolve_dir, |e, d| if d == 0.0 { e } else { 0.0 });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
attempts += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if on_ground {
|
if on_ground {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user