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); 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 pos_delta = if terrain let mut pos_delta = if terrain
.get_key(terrain.pos_key(pos.0.map(|e| e.floor() as i32))) .get_key(terrain.pos_key(pos.0.map(|e| e.floor() as i32)))
.is_some() .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.
(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 { } else {
Vec3::zero() Vec3::zero()
}; };
@ -294,7 +295,7 @@ impl<'a> System<'a> for Sys {
.unwrap_or(false)) .unwrap_or(false))
// ...and there is a collision with a block beneath our current hitbox... // ...and there is a collision with a block beneath our current hitbox...
&& collision_with( && collision_with(
old_pos + resolve_dir - Vec3::unit_z() * 1.05, pos.0 + resolve_dir - Vec3::unit_z() * 1.05,
&|block| block.is_solid(), &|block| block.is_solid(),
near_iter.clone(), near_iter.clone(),
) )
@ -309,6 +310,7 @@ impl<'a> System<'a> for Sys {
vel.0 = vel.0.map2(resolve_dir, |e, d| { vel.0 = vel.0.map2(resolve_dir, |e, d| {
if d * e.signum() < 0.0 { 0.0 } else { e } 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 // Resolve the collision normally

View File

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