mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Merge branch 'telastrus/first-person' into 'master'
added first person switch See merge request veloren/veloren!425
This commit is contained in:
commit
f4aa053b53
@ -123,6 +123,25 @@ impl Camera {
|
||||
};
|
||||
}
|
||||
|
||||
/// Zoom with the ability to switch between first and third-person mode.
|
||||
pub fn zoom_switch(&mut self, delta: f32) {
|
||||
if delta > 0_f32 || self.mode != CameraMode::FirstPerson {
|
||||
let t = self.tgt_dist + delta;
|
||||
match self.mode {
|
||||
CameraMode::ThirdPerson => {
|
||||
if t < 2_f32 {
|
||||
self.set_mode(CameraMode::FirstPerson);
|
||||
} else {
|
||||
self.tgt_dist = t;
|
||||
}
|
||||
}
|
||||
CameraMode::FirstPerson => {
|
||||
self.set_mode(CameraMode::ThirdPerson);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Get the distance of the camera from the target
|
||||
pub fn get_distance(&self) -> f32 {
|
||||
self.tgt_dist
|
||||
|
@ -106,7 +106,7 @@ impl Scene {
|
||||
}
|
||||
// Zoom the camera when a zoom event occurs
|
||||
Event::Zoom(delta) => {
|
||||
self.camera.zoom_by(delta * 0.3);
|
||||
self.camera.zoom_switch(delta * 0.3);
|
||||
true
|
||||
}
|
||||
// All other events are unhandled
|
||||
@ -127,12 +127,7 @@ impl Scene {
|
||||
// Alter camera position to match player.
|
||||
let tilt = self.camera.get_orientation().y;
|
||||
let dist = self.camera.get_distance();
|
||||
let up = if client
|
||||
.state()
|
||||
.read_storage::<comp::CanBuild>()
|
||||
.get(client.entity())
|
||||
.is_some()
|
||||
{
|
||||
let up = if self.camera.get_mode() == CameraMode::FirstPerson {
|
||||
1.5
|
||||
} else {
|
||||
1.2
|
||||
@ -213,17 +208,6 @@ impl Scene {
|
||||
proj_mat,
|
||||
);
|
||||
|
||||
if client
|
||||
.state()
|
||||
.read_storage::<comp::CanBuild>()
|
||||
.get(client.entity())
|
||||
.is_some()
|
||||
{
|
||||
self.camera.set_mode(CameraMode::FirstPerson);
|
||||
} else {
|
||||
self.camera.set_mode(CameraMode::ThirdPerson);
|
||||
}
|
||||
|
||||
// Maintain the figures.
|
||||
self.figure_mgr.maintain(renderer, client);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user