Add first person models

This commit is contained in:
scott-c 2019-08-17 23:23:03 +08:00
parent 1f859111c4
commit 5fd4f00012
3 changed files with 32 additions and 14 deletions

View File

@ -164,6 +164,8 @@ impl Scene {
Body::Humanoid(body), Body::Humanoid(body),
Some(equipment), Some(equipment),
client.get_tick(), client.get_tick(),
false,
false,
) )
.0; .0;

View File

@ -12,7 +12,7 @@ use hashbrown::HashMap;
#[derive(PartialEq, Eq, Hash, Clone)] #[derive(PartialEq, Eq, Hash, Clone)]
enum FigureKey { enum FigureKey {
Simple(Body), Simple(Body),
Complex(Body, Option<Equipment>), Complex(Body, Option<Equipment>, bool, bool),
} }
pub struct FigureModelCache { pub struct FigureModelCache {
@ -34,9 +34,11 @@ impl FigureModelCache {
body: Body, body: Body,
equipment: Option<&Equipment>, equipment: Option<&Equipment>,
tick: u64, tick: u64,
first_person: bool,
gliding: bool,
) -> &(Model<FigurePipeline>, SkeletonAttr) { ) -> &(Model<FigurePipeline>, SkeletonAttr) {
let key = if equipment.is_some() { let key = if equipment.is_some() {
FigureKey::Complex(body, equipment.cloned()) FigureKey::Complex(body, equipment.cloned(), first_person, gliding)
} else { } else {
FigureKey::Simple(body) FigureKey::Simple(body)
}; };
@ -54,6 +56,9 @@ impl FigureModelCache {
HumHeadSpec::load_watched(&mut self.manifest_indicator); HumHeadSpec::load_watched(&mut self.manifest_indicator);
let bone_meshes = match body { let bone_meshes = match body {
Body::Humanoid(body) => [ Body::Humanoid(body) => [
if !first_person {
Some(humanoid_head_spec.mesh_head( Some(humanoid_head_spec.mesh_head(
body.race, body.race,
body.body_type, body.body_type,
@ -64,7 +69,13 @@ impl FigureModelCache {
body.skin, body.skin,
body.eyebrows, body.eyebrows,
body.accessory, body.accessory,
)), ))
} else {
None
}
,
Some(mesh_chest(body.chest)), Some(mesh_chest(body.chest)),
Some(mesh_belt(body.belt)), Some(mesh_belt(body.belt)),
Some(mesh_pants(body.pants)), Some(mesh_pants(body.pants)),

View File

@ -116,7 +116,7 @@ impl FigureMgr {
let skeleton_attr = &self let skeleton_attr = &self
.model_cache .model_cache
.get_or_create_model(renderer, *body, stats.map(|s| &s.equipment), tick) .get_or_create_model(renderer, *body, stats.map(|s| &s.equipment), tick, false, false)
.1; .1;
match body { match body {
@ -381,22 +381,27 @@ impl FigureMgr {
.get(&entity) .get(&entity)
.map(|state| (state.locals(), state.bone_consts())), .map(|state| (state.locals(), state.bone_consts())),
} { } {
let model = &self
.model_cache
.get_or_create_model(renderer, *body, stats.map(|s| &s.equipment), tick)
.0;
// Don't render the player's body while in first person mode // Don't render the player's body while in first person mode
if camera.get_mode() == CameraMode::FirstPerson let fp =
camera.get_mode() == CameraMode::FirstPerson
&& client && client
.state() .state()
.read_storage::<Body>() .read_storage::<Body>()
.get(client.entity()) .get(client.entity())
.is_some() .is_some()
&& entity == client.entity() && entity == client.entity();
{
continue; let gliding = client
} .state()
.read_storage::<common::comp::CharacterState>()
.get(client.entity())
.unwrap_or(&common::comp::CharacterState::default())
.movement == common::comp::MovementState::Glide;
let model = &self
.model_cache
.get_or_create_model(renderer, *body, stats.map(|s| &s.equipment), tick, fp, gliding)
.0;
renderer.render_figure(model, globals, locals, bone_consts, lights); renderer.render_figure(model, globals, locals, bone_consts, lights);
} else { } else {