Merge branch 'treeco/fix-spawn-damage' into 'master'

Reset rather than accumulate velocity when stuck or in unloaded chunks

See merge request veloren/veloren!1185
This commit is contained in:
Imbris 2020-07-18 19:08:40 +00:00
commit 3c954534ed

View File

@ -117,7 +117,12 @@ impl<'a> System<'a> for Sys {
} else {
0.0
});
let downward_force = if physics_state.in_fluid {
let in_loaded_chunk = terrain
.get_key(terrain.pos_key(pos.0.map(|e| e.floor() as i32)))
.is_some();
let downward_force = if !in_loaded_chunk {
0.0 // No gravity in unloaded chunks
} else if physics_state.in_fluid {
(1.0 - BOUYANCY) * GRAVITY
} else {
GRAVITY
@ -125,10 +130,7 @@ impl<'a> System<'a> for Sys {
vel.0 = integrate_forces(dt.0, vel.0, downward_force, friction);
// Don't move if we're not in a loaded chunk
let mut pos_delta = if terrain
.get_key(terrain.pos_key(pos.0.map(|e| e.floor() as i32)))
.is_some()
{
let mut pos_delta = if in_loaded_chunk {
// this is an approximation that allows most framerates to
// behave in a similar manner.
let dt_lerp = 0.2;
@ -319,6 +321,7 @@ impl<'a> System<'a> for Sys {
}
if attempts == MAX_ATTEMPTS {
vel.0 = Vec3::zero();
pos.0 = old_pos;
break;
}