mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Merge branch 'master' into 'master'
Better camera positioning, smooth acceleration See merge request veloren/veloren!35 Former-commit-id: ca38f861d1cc102fd9f2cb3f490871ea753f748f
This commit is contained in:
commit
a80ddb807f
@ -149,17 +149,15 @@ impl Client {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Step 1
|
// Step 1
|
||||||
if
|
if let (Some(_), Some(vel), Some(_)) = (
|
||||||
self.state.read_storage::<comp::phys::Pos>().get(self.player).is_some() &&
|
self.state.read_component_cloned::<comp::phys::Pos>(self.player),
|
||||||
self.state.read_storage::<comp::phys::Vel>().get(self.player).is_some() &&
|
self.state.read_component_cloned::<comp::phys::Vel>(self.player),
|
||||||
self.state.read_storage::<comp::phys::Dir>().get(self.player).is_some()
|
self.state.read_component_cloned::<comp::phys::Dir>(self.player),
|
||||||
{
|
) {
|
||||||
// TODO: remove this
|
self.state.write_component(self.player, comp::phys::Vel(vel.0 + input.move_dir * 2.0 - vel.0.map(|e| e * e.abs() + e) * 0.03));
|
||||||
const PLAYER_VELOCITY: f32 = 100.0;
|
|
||||||
// TODO: Set acceleration instead
|
|
||||||
self.state.write_component(self.player, comp::phys::Vel(Vec3::from(input.move_dir * PLAYER_VELOCITY) * 0.1));
|
|
||||||
if input.move_dir.magnitude() > 0.01 {
|
if input.move_dir.magnitude() > 0.01 {
|
||||||
self.state.write_component(self.player, comp::phys::Dir(input.move_dir.normalized().into()));
|
self.state.write_component(self.player, comp::phys::Dir(vel.0.normalized() * Vec3::new(1.0, 1.0, 0.0)));
|
||||||
self.state.write_component(self.player, comp::Animation::Run);
|
self.state.write_component(self.player, comp::Animation::Run);
|
||||||
} else {
|
} else {
|
||||||
self.state.write_component(self.player, comp::Animation::Idle);
|
self.state.write_component(self.player, comp::Animation::Idle);
|
||||||
|
@ -21,7 +21,7 @@ impl Camera {
|
|||||||
Self {
|
Self {
|
||||||
focus: Vec3::unit_z() * 10.0,
|
focus: Vec3::unit_z() * 10.0,
|
||||||
ori: Vec3::zero(),
|
ori: Vec3::zero(),
|
||||||
dist: 150.0,
|
dist: 10.0,
|
||||||
fov: 1.3,
|
fov: 1.3,
|
||||||
aspect,
|
aspect,
|
||||||
}
|
}
|
||||||
|
@ -97,7 +97,7 @@ impl Scene {
|
|||||||
},
|
},
|
||||||
// Zoom the camera when a zoom event occurs
|
// Zoom the camera when a zoom event occurs
|
||||||
Event::Zoom(delta) => {
|
Event::Zoom(delta) => {
|
||||||
self.camera.zoom_by(-delta);
|
self.camera.zoom_by(delta * 0.3);
|
||||||
true
|
true
|
||||||
},
|
},
|
||||||
// All other events are unhandled
|
// All other events are unhandled
|
||||||
@ -118,7 +118,7 @@ impl Scene {
|
|||||||
.unwrap_or(Vec3::zero());
|
.unwrap_or(Vec3::zero());
|
||||||
|
|
||||||
// Alter camera position to match player
|
// Alter camera position to match player
|
||||||
self.camera.set_focus_pos(player_pos);
|
self.camera.set_focus_pos(player_pos + Vec3::unit_z() * 1.5);
|
||||||
|
|
||||||
// Compute camera matrices
|
// Compute camera matrices
|
||||||
let (view_mat, proj_mat, cam_pos) = self.camera.compute_dependents();
|
let (view_mat, proj_mat, cam_pos) = self.camera.compute_dependents();
|
||||||
|
Loading…
Reference in New Issue
Block a user