Properly hide the player character

This commit is contained in:
Piotr Korgól 2019-07-24 16:27:13 +02:00
parent fd841cdd33
commit 4f73cc921b
3 changed files with 26 additions and 14 deletions

View File

@ -12,7 +12,7 @@ pub const MIN_ZOOM: f32 = 0.1;
// Possible TODO: Add more modes
pub enum CameraMode {
FirstPerson,
ThirdPerson
ThirdPerson,
}
pub struct Camera {
@ -180,11 +180,11 @@ impl Camera {
if self.tgt_dist == MIN_ZOOM {
self.zoom_by(5.0);
}
},
}
CameraMode::FirstPerson => {
self.set_distance(MIN_ZOOM);
self.can_zoom = false;
},
}
}
}
}

View File

@ -7,7 +7,7 @@ use crate::{
render::{
Consts, FigureBoneData, FigureLocals, FigurePipeline, Globals, Light, Mesh, Model, Renderer,
},
scene::camera::{MIN_ZOOM, Camera},
scene::camera::{Camera, MIN_ZOOM},
};
use client::Client;
use common::{
@ -293,7 +293,7 @@ impl FigureModelCache {
fn load_left_foot(foot: humanoid::Foot) -> Mesh<FigurePipeline> {
use humanoid::Foot::*;
Self::load_mesh ( //https://gitlab.com/veloren/veloren/issues/7://gitlab.com/veloren/veloren/issues/79
Self::load_mesh(
match foot {
Dark => "armor/foot/foot_dark.vox",
},
@ -590,7 +590,7 @@ impl FigureMgr {
self.model_cache.clean(tick);
}
pub fn maintain(&mut self, renderer: &mut Renderer, client: &Client, camera: &Camera) {
pub fn maintain(&mut self, renderer: &mut Renderer, client: &Client) {
let time = client.state().get_time();
let tick = client.get_tick();
let ecs = client.state().ecs();
@ -654,11 +654,6 @@ 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
@ -848,6 +843,7 @@ impl FigureMgr {
client: &mut Client,
globals: &Consts<Globals>,
lights: &Consts<Light>,
camera: &Camera,
) {
let tick = client.get_tick();
let ecs = client.state().ecs();
@ -903,6 +899,18 @@ impl FigureMgr {
.get_or_create_model(renderer, *body, tick)
.0;
// Don't render the player's body while in first person mode
if camera.tgt_dist == MIN_ZOOM
&& client
.state()
.read_storage::<comp::Body>()
.get(client.entity())
.is_some()
&& entity == client.entity()
{
continue;
}
renderer.render_figure(model, globals, locals, bone_consts, lights);
} else {
warn!("Body has no saved figure");

View File

@ -2,7 +2,11 @@ pub mod camera;
pub mod figure;
pub mod terrain;
use self::{camera::{Camera, CameraMode}, figure::FigureMgr, terrain::Terrain};
use self::{
camera::{Camera, CameraMode},
figure::FigureMgr,
terrain::Terrain,
};
use crate::{
render::{
create_pp_mesh, create_skybox_mesh, Consts, Globals, Light, Model, PostProcessLocals,
@ -203,7 +207,7 @@ impl Scene {
}
// Maintain the figures.
self.figure_mgr.maintain(renderer, client, &self.camera);
self.figure_mgr.maintain(renderer, client);
// Remove unused figures.
self.figure_mgr.clean(client.get_tick());
@ -217,7 +221,7 @@ impl Scene {
// Render terrain and figures.
self.terrain.render(renderer, &self.globals, &self.lights);
self.figure_mgr
.render(renderer, client, &self.globals, &self.lights);
.render(renderer, client, &self.globals, &self.lights, &self.camera);
renderer.render_post_process(
&self.postprocess.model,