Merge branch 'zesterer/small-fixes' into 'master'

Better physics comments, removed camera snapping

See merge request veloren/veloren!1034
This commit is contained in:
Joshua Barretto 2020-06-01 20:50:24 +00:00
commit 475f62b57f
2 changed files with 7 additions and 11 deletions

View File

@ -126,13 +126,14 @@ 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 pos_delta = if terrain
let mut pos_delta = if terrain
.get_key(terrain.pos_key(pos.0.map(|e| e.floor() as i32)))
.is_some()
{
// this is an approximation that allows most framerates to
// behave in a similar manner.
(vel.0 + old_vel.0 * 4.0) * dt.0 * 0.2
let dt_lerp = 0.2;
(vel.0 * dt_lerp + old_vel.0 * (1.0 - dt_lerp)) * dt.0
} else {
Vec3::zero()
};
@ -294,7 +295,7 @@ impl<'a> System<'a> for Sys {
.unwrap_or(false))
// ...and there is a collision with a block beneath our current hitbox...
&& collision_with(
old_pos + resolve_dir - Vec3::unit_z() * 1.05,
pos.0 + resolve_dir - Vec3::unit_z() * 1.05,
&|block| block.is_solid(),
near_iter.clone(),
)
@ -309,6 +310,7 @@ impl<'a> System<'a> for Sys {
vel.0 = vel.0.map2(resolve_dir, |e, d| {
if d * e.signum() < 0.0 { 0.0 } else { e }
});
pos_delta *= resolve_dir.map(|e| if e != 0.0 { 0.0 } else { 1.0 });
}
// Resolve the collision normally

View File

@ -214,14 +214,8 @@ impl Camera {
},
);
// Snap when close enough in x/y, but lerp otherwise
if (self.focus.xy() - self.tgt_focus.xy()).magnitude_squared() > 2.0f32.powf(2.0) {
self.focus.x = lerped_focus.x;
self.focus.y = lerped_focus.y;
} else {
self.focus.x = self.tgt_focus.x;
self.focus.y = self.tgt_focus.y;
}
self.focus.x = lerped_focus.x;
self.focus.y = lerped_focus.y;
// Always lerp in z
self.focus.z = lerped_focus.z;