mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Add first person models
This commit is contained in:
parent
1f859111c4
commit
5fd4f00012
@ -164,6 +164,8 @@ impl Scene {
|
||||
Body::Humanoid(body),
|
||||
Some(equipment),
|
||||
client.get_tick(),
|
||||
false,
|
||||
false,
|
||||
)
|
||||
.0;
|
||||
|
||||
|
@ -12,7 +12,7 @@ use hashbrown::HashMap;
|
||||
#[derive(PartialEq, Eq, Hash, Clone)]
|
||||
enum FigureKey {
|
||||
Simple(Body),
|
||||
Complex(Body, Option<Equipment>),
|
||||
Complex(Body, Option<Equipment>, bool, bool),
|
||||
}
|
||||
|
||||
pub struct FigureModelCache {
|
||||
@ -34,9 +34,11 @@ impl FigureModelCache {
|
||||
body: Body,
|
||||
equipment: Option<&Equipment>,
|
||||
tick: u64,
|
||||
first_person: bool,
|
||||
gliding: bool,
|
||||
) -> &(Model<FigurePipeline>, SkeletonAttr) {
|
||||
let key = if equipment.is_some() {
|
||||
FigureKey::Complex(body, equipment.cloned())
|
||||
FigureKey::Complex(body, equipment.cloned(), first_person, gliding)
|
||||
} else {
|
||||
FigureKey::Simple(body)
|
||||
};
|
||||
@ -54,6 +56,9 @@ impl FigureModelCache {
|
||||
HumHeadSpec::load_watched(&mut self.manifest_indicator);
|
||||
let bone_meshes = match body {
|
||||
Body::Humanoid(body) => [
|
||||
|
||||
if !first_person {
|
||||
|
||||
Some(humanoid_head_spec.mesh_head(
|
||||
body.race,
|
||||
body.body_type,
|
||||
@ -64,7 +69,13 @@ impl FigureModelCache {
|
||||
body.skin,
|
||||
body.eyebrows,
|
||||
body.accessory,
|
||||
)),
|
||||
))
|
||||
|
||||
} else {
|
||||
None
|
||||
}
|
||||
|
||||
,
|
||||
Some(mesh_chest(body.chest)),
|
||||
Some(mesh_belt(body.belt)),
|
||||
Some(mesh_pants(body.pants)),
|
||||
|
@ -116,7 +116,7 @@ impl FigureMgr {
|
||||
|
||||
let skeleton_attr = &self
|
||||
.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;
|
||||
|
||||
match body {
|
||||
@ -381,22 +381,27 @@ impl FigureMgr {
|
||||
.get(&entity)
|
||||
.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
|
||||
if camera.get_mode() == CameraMode::FirstPerson
|
||||
let fp =
|
||||
camera.get_mode() == CameraMode::FirstPerson
|
||||
&& client
|
||||
.state()
|
||||
.read_storage::<Body>()
|
||||
.get(client.entity())
|
||||
.is_some()
|
||||
&& entity == client.entity()
|
||||
{
|
||||
continue;
|
||||
}
|
||||
&& entity == client.entity();
|
||||
|
||||
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);
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user