mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Remove gravity rather than reset velocity in unloaded chunks
This commit is contained in:
parent
1f1d9c5625
commit
c7e8a6bfae
@ -117,7 +117,12 @@ impl<'a> System<'a> for Sys {
|
|||||||
} else {
|
} else {
|
||||||
0.0
|
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
|
(1.0 - BOUYANCY) * GRAVITY
|
||||||
} else {
|
} else {
|
||||||
GRAVITY
|
GRAVITY
|
||||||
@ -125,16 +130,12 @@ impl<'a> System<'a> for Sys {
|
|||||||
vel.0 = integrate_forces(dt.0, vel.0, downward_force, friction);
|
vel.0 = integrate_forces(dt.0, vel.0, downward_force, friction);
|
||||||
|
|
||||||
// Don't move if we're not in a loaded chunk
|
// Don't move if we're not in a loaded chunk
|
||||||
let mut pos_delta = if terrain
|
let mut pos_delta = if in_loaded_chunk {
|
||||||
.get_key(terrain.pos_key(pos.0.map(|e| e.floor() as i32)))
|
|
||||||
.is_some()
|
|
||||||
{
|
|
||||||
// this is an approximation that allows most framerates to
|
// this is an approximation that allows most framerates to
|
||||||
// behave in a similar manner.
|
// behave in a similar manner.
|
||||||
let dt_lerp = 0.2;
|
let dt_lerp = 0.2;
|
||||||
(vel.0 * dt_lerp + old_vel.0 * (1.0 - dt_lerp)) * dt.0
|
(vel.0 * dt_lerp + old_vel.0 * (1.0 - dt_lerp)) * dt.0
|
||||||
} else {
|
} else {
|
||||||
vel.0 = Vec3::zero();
|
|
||||||
Vec3::zero()
|
Vec3::zero()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user