An attempt at hiding the player in first person mode

This commit is contained in:
Piotr Korgól 2019-07-24 16:09:16 +02:00
parent e33deac740
commit fd841cdd33
3 changed files with 13 additions and 6 deletions

View File

@ -7,6 +7,7 @@ const NEAR_PLANE: f32 = 0.01;
const FAR_PLANE: f32 = 10000.0;
const INTERP_TIME: f32 = 0.1;
pub const MIN_ZOOM: f32 = 0.1;
// Possible TODO: Add more modes
pub enum CameraMode {
@ -18,7 +19,7 @@ pub struct Camera {
tgt_focus: Vec3<f32>,
focus: Vec3<f32>,
ori: Vec3<f32>,
tgt_dist: f32,
pub tgt_dist: f32,
dist: f32,
fov: f32,
aspect: f32,
@ -176,12 +177,12 @@ impl Camera {
match self.mode {
CameraMode::ThirdPerson => {
self.can_zoom = true;
if self.tgt_dist == 0.1 {
if self.tgt_dist == MIN_ZOOM {
self.zoom_by(5.0);
}
},
CameraMode::FirstPerson => {
self.set_distance(0.1);
self.set_distance(MIN_ZOOM);
self.can_zoom = false;
},
}

View File

@ -7,6 +7,7 @@ use crate::{
render::{
Consts, FigureBoneData, FigureLocals, FigurePipeline, Globals, Light, Mesh, Model, Renderer,
},
scene::camera::{MIN_ZOOM, Camera},
};
use client::Client;
use common::{
@ -292,7 +293,7 @@ impl FigureModelCache {
fn load_left_foot(foot: humanoid::Foot) -> Mesh<FigurePipeline> {
use humanoid::Foot::*;
Self::load_mesh(
Self::load_mesh ( //https://gitlab.com/veloren/veloren/issues/7://gitlab.com/veloren/veloren/issues/79
match foot {
Dark => "armor/foot/foot_dark.vox",
},
@ -589,7 +590,7 @@ impl FigureMgr {
self.model_cache.clean(tick);
}
pub fn maintain(&mut self, renderer: &mut Renderer, client: &Client) {
pub fn maintain(&mut self, renderer: &mut Renderer, client: &Client, camera: &Camera) {
let time = client.state().get_time();
let tick = client.get_tick();
let ecs = client.state().ecs();
@ -653,6 +654,11 @@ impl FigureMgr {
.get_or_create_model(renderer, *body, tick)
.1;
// Don't render the player's body while in first person mode
if camera.tgt_dist == MIN_ZOOM && client.state().read_storage::<comp::CanBuild>().get(client.entity()).is_some() {
continue;
}
match body {
Body::Humanoid(_) => {
let state = self

View File

@ -203,7 +203,7 @@ impl Scene {
}
// Maintain the figures.
self.figure_mgr.maintain(renderer, client);
self.figure_mgr.maintain(renderer, client, &self.camera);
// Remove unused figures.
self.figure_mgr.clean(client.get_tick());