Finishing touches

This commit is contained in:
Sam 2022-01-26 22:03:52 -05:00
parent d23dd6c9e9
commit b558331b32
26 changed files with 100 additions and 44 deletions

View File

@ -517,7 +517,7 @@
], ],
threshold: 0.5, threshold: 0.5,
), ),
Attack(BasicMelee, Dagger): ( Attack(BasicMelee(Action), Dagger): (
files: [ files: [
"voxygen.audio.sfx.abilities.swing_sword", "voxygen.audio.sfx.abilities.swing_sword",
], ],
@ -551,7 +551,7 @@
], ],
threshold: 0.5, threshold: 0.5,
), ),
Attack(BasicMelee, Shield): ( Attack(BasicMelee(Action), Shield): (
files: [ files: [
"voxygen.audio.sfx.abilities.swing", "voxygen.audio.sfx.abilities.swing",
], ],

View File

@ -9,5 +9,5 @@ layout(location = 0) out vec3 f_pos;
void main() { void main() {
f_pos = v_pos; f_pos = v_pos;
gl_Position = all_mat * vec4(f_pos, 1); gl_Position = all_mat * vec4(f_pos - focus_off.xyz, 1);
} }

View File

@ -345,8 +345,12 @@ impl From<AuxiliaryAbility> for Ability {
} }
#[derive(Copy, Clone, Hash, Eq, PartialEq, Debug, Serialize, Deserialize)] #[derive(Copy, Clone, Hash, Eq, PartialEq, Debug, Serialize, Deserialize)]
/// A lighter form of character state to pass around as needed for frontend
/// purposes
// Only add to this enum as needed for frontends, not necessary to immediately
// add a variant here when adding a new character state
pub enum CharacterAbilityType { pub enum CharacterAbilityType {
BasicMelee, BasicMelee(StageSection),
BasicRanged, BasicRanged,
Boost, Boost,
ChargedMelee(StageSection), ChargedMelee(StageSection),
@ -361,12 +365,13 @@ pub enum CharacterAbilityType {
RepeaterRanged, RepeaterRanged,
BasicAura, BasicAura,
SelfBuff, SelfBuff,
Other,
} }
impl From<&CharacterState> for CharacterAbilityType { impl From<&CharacterState> for CharacterAbilityType {
fn from(state: &CharacterState) -> Self { fn from(state: &CharacterState) -> Self {
match state { match state {
CharacterState::BasicMelee(_) => Self::BasicMelee, CharacterState::BasicMelee(data) => Self::BasicMelee(data.stage_section),
CharacterState::BasicRanged(_) => Self::BasicRanged, CharacterState::BasicRanged(_) => Self::BasicRanged,
CharacterState::Boost(_) => Self::Boost, CharacterState::Boost(_) => Self::Boost,
CharacterState::DashMelee(data) => Self::DashMelee(data.stage_section), CharacterState::DashMelee(data) => Self::DashMelee(data.stage_section),
@ -381,7 +386,23 @@ impl From<&CharacterState> for CharacterAbilityType {
CharacterState::RepeaterRanged(_) => Self::RepeaterRanged, CharacterState::RepeaterRanged(_) => Self::RepeaterRanged,
CharacterState::BasicAura(_) => Self::BasicAura, CharacterState::BasicAura(_) => Self::BasicAura,
CharacterState::SelfBuff(_) => Self::SelfBuff, CharacterState::SelfBuff(_) => Self::SelfBuff,
_ => Self::BasicMelee, CharacterState::Idle(_)
| CharacterState::Climb(_)
| CharacterState::Sit
| CharacterState::Dance
| CharacterState::Talk
| CharacterState::Glide(_)
| CharacterState::GlideWield(_)
| CharacterState::Stunned(_)
| CharacterState::Equipping(_)
| CharacterState::Wielding(_)
| CharacterState::Roll(_)
| CharacterState::Blink(_)
| CharacterState::BasicSummon(_)
| CharacterState::SpriteSummon(_)
| CharacterState::UseItem(_)
| CharacterState::SpriteInteract(_)
| CharacterState::Wallrun(_) => Self::Other,
} }
} }
} }

View File

@ -113,7 +113,7 @@ impl Skeleton for ArthropodSkeleton {
orientation: mount_orientation, orientation: mount_orientation,
scale: Vec3::one(), scale: Vec3::one(),
}, },
relative_trail_points: None, weapon_trail_mat: None,
} }
} }
} }

View File

@ -137,7 +137,7 @@ impl Skeleton for BipedLargeSkeleton {
.into(), .into(),
..Default::default() ..Default::default()
}, },
relative_trail_points: None, weapon_trail_mat: None,
} }
} }
} }

View File

@ -83,7 +83,7 @@ impl Skeleton for BipedSmallSkeleton {
.into(), .into(),
..Default::default() ..Default::default()
}, },
relative_trail_points: None, weapon_trail_mat: None,
} }
} }
} }

View File

@ -106,7 +106,7 @@ impl Skeleton for BirdLargeSkeleton {
.into(), .into(),
..Default::default() ..Default::default()
}, },
relative_trail_points: None, weapon_trail_mat: None,
} }
} }
} }

View File

@ -60,7 +60,7 @@ impl Skeleton for BirdMediumSkeleton {
.into(), .into(),
..Default::default() ..Default::default()
}, },
relative_trail_points: None, weapon_trail_mat: None,
} }
} }
} }

View File

@ -156,10 +156,7 @@ impl Skeleton for CharacterSkeleton {
.into(), .into(),
..Default::default() ..Default::default()
}, },
relative_trail_points: Some(( weapon_trail_mat: Some(main_mat),
(main_mat * Vec4::new(0.0, 0.5, -6.0, 1.0)).xyz(),
(main_mat * Vec4::new(0.0, 0.5, -6.0, 1.0)).xyz() + Vec3::unit_z(),
)),
} }
} }
} }

View File

@ -81,7 +81,7 @@ impl Skeleton for DragonSkeleton {
.into(), .into(),
..Default::default() ..Default::default()
}, },
relative_trail_points: None, weapon_trail_mat: None,
} }
} }
} }

View File

@ -60,7 +60,7 @@ impl Skeleton for FishMediumSkeleton {
.into(), .into(),
..Default::default() ..Default::default()
}, },
relative_trail_points: None, weapon_trail_mat: None,
} }
} }
} }

View File

@ -51,7 +51,7 @@ impl Skeleton for FishSmallSkeleton {
.into(), .into(),
..Default::default() ..Default::default()
}, },
relative_trail_points: None, weapon_trail_mat: None,
} }
} }
} }

View File

@ -37,7 +37,7 @@ impl Skeleton for FixtureSkeleton {
Offsets { Offsets {
lantern: None, lantern: None,
mount_bone: Transform::default(), mount_bone: Transform::default(),
relative_trail_points: None, weapon_trail_mat: None,
} }
} }
} }

View File

@ -83,7 +83,7 @@ impl Skeleton for GolemSkeleton {
.into(), .into(),
..Default::default() ..Default::default()
}, },
relative_trail_points: None, weapon_trail_mat: None,
} }
} }
} }

View File

@ -43,6 +43,7 @@ impl Skeleton for ItemDropSkeleton {
.into(), .into(),
..Default::default() ..Default::default()
}, },
weapon_trail_mat: None,
} }
} }
} }

View File

@ -103,7 +103,7 @@ pub fn init() { lazy_static::initialize(&LIB); }
pub struct Offsets { pub struct Offsets {
pub lantern: Option<Vec3<f32>>, pub lantern: Option<Vec3<f32>>,
pub mount_bone: Transform<f32, f32, f32>, pub mount_bone: Transform<f32, f32, f32>,
pub relative_trail_points: Option<(Vec3<f32>, Vec3<f32>)>, pub weapon_trail_mat: Option<Mat4<f32>>,
} }
pub trait Skeleton: Send + Sync + 'static { pub trait Skeleton: Send + Sync + 'static {

View File

@ -49,7 +49,7 @@ impl Skeleton for ObjectSkeleton {
.into(), .into(),
..Default::default() ..Default::default()
}, },
relative_trail_points: None, weapon_trail_mat: None,
} }
} }
} }

View File

@ -97,7 +97,7 @@ impl Skeleton for QuadrupedLowSkeleton {
orientation: mount_orientation, orientation: mount_orientation,
scale: Vec3::one(), scale: Vec3::one(),
}, },
relative_trail_points: None, weapon_trail_mat: None,
} }
} }
} }

View File

@ -109,7 +109,7 @@ impl Skeleton for QuadrupedMediumSkeleton {
orientation: mount_orientation, orientation: mount_orientation,
scale: Vec3::one(), scale: Vec3::one(),
}, },
relative_trail_points: None, weapon_trail_mat: None,
} }
} }
} }

View File

@ -74,7 +74,7 @@ impl Skeleton for QuadrupedSmallSkeleton {
orientation: mount_orientation, orientation: mount_orientation,
scale: Vec3::one(), scale: Vec3::one(),
}, },
relative_trail_points: None, weapon_trail_mat: None,
} }
} }
} }

View File

@ -53,7 +53,7 @@ impl Skeleton for ShipSkeleton {
), ),
..Default::default() ..Default::default()
}, },
relative_trail_points: None, weapon_trail_mat: None,
} }
} }
} }

View File

@ -84,7 +84,7 @@ impl Skeleton for TheropodSkeleton {
.into(), .into(),
..Default::default() ..Default::default()
}, },
relative_trail_points: None, weapon_trail_mat: None,
} }
} }
} }

View File

@ -33,8 +33,9 @@ use common::{
comp::{ comp::{
inventory::slot::EquipSlot, inventory::slot::EquipSlot,
item::{Hands, ItemKind, ToolKind}, item::{Hands, ItemKind, ToolKind},
Body, CharacterState, Collider, Controller, Health, Inventory, Item, ItemKey, Last, Body, CharacterAbilityType, CharacterState, Collider, Controller, Health, Inventory, Item,
LightAnimation, LightEmitter, Ori, PhysicsState, PoiseState, Pos, Scale, Vel, ItemKey, Last, LightAnimation, LightEmitter, Ori, PhysicsState, PoiseState, Pos, Scale,
Vel,
}, },
link::Is, link::Is,
mounting::Rider, mounting::Rider,
@ -862,6 +863,8 @@ impl FigureMgr {
scale, scale,
mount_transform_pos, mount_transform_pos,
body: Some(body), body: Some(body),
tools: (active_tool_kind, second_tool_kind),
char_ability: character.map(|c| c.into()),
col, col,
dt, dt,
_lpindex: lpindex, _lpindex: lpindex,
@ -5368,6 +5371,7 @@ impl FigureMgr {
state.skeleton = anim::vek::Lerp::lerp(&state.skeleton, &target_bones, dt_lerp); state.skeleton = anim::vek::Lerp::lerp(&state.skeleton, &target_bones, dt_lerp);
state.update( state.update(
renderer, renderer,
Some(trail_mgr),
&mut update_buf, &mut update_buf,
&common_params, &common_params,
state_animation_rate, state_animation_rate,
@ -6244,6 +6248,8 @@ pub struct FigureUpdateCommonParameters<'a> {
pub scale: f32, pub scale: f32,
pub mount_transform_pos: Option<(anim::vek::Transform<f32, f32, f32>, anim::vek::Vec3<f32>)>, pub mount_transform_pos: Option<(anim::vek::Transform<f32, f32, f32>, anim::vek::Vec3<f32>)>,
pub body: Option<Body>, pub body: Option<Body>,
pub tools: (Option<ToolKind>, Option<ToolKind>),
pub char_ability: Option<CharacterAbilityType>,
pub col: vek::Rgba<f32>, pub col: vek::Rgba<f32>,
pub dt: f32, pub dt: f32,
// TODO: evaluate unused variable // TODO: evaluate unused variable
@ -6266,9 +6272,7 @@ impl<S: Skeleton> FigureState<S> {
Self { Self {
meta: FigureStateMeta { meta: FigureStateMeta {
lantern_offset: offsets.lantern, lantern_offset: offsets.lantern,
abs_trail_points: offsets.relative_trail_points, /* No position to add and make abs_trail_points: None,
* absolute, also doesn't matter
* here */
mount_transform: offsets.mount_bone, mount_transform: offsets.mount_bone,
mount_world_pos: anim::vek::Vec3::zero(), mount_world_pos: anim::vek::Vec3::zero(),
state_time: 0.0, state_time: 0.0,
@ -6299,6 +6303,8 @@ impl<S: Skeleton> FigureState<S> {
scale, scale,
mount_transform_pos, mount_transform_pos,
body, body,
tools,
char_ability,
col, col,
dt, dt,
_lpindex, _lpindex,
@ -6437,26 +6443,53 @@ impl<S: Skeleton> FigureState<S> {
renderer.update_consts(&mut self.meta.bound.1, &new_bone_consts[0..S::BONE_COUNT]); renderer.update_consts(&mut self.meta.bound.1, &new_bone_consts[0..S::BONE_COUNT]);
self.lantern_offset = offsets.lantern; self.lantern_offset = offsets.lantern;
// Handle weapon trails // Handle weapon trails
let offsets_abs_trail_points = offsets let weapon_offsets = offsets.weapon_trail_mat.map(|mat| {
.relative_trail_points let (trail_start, trail_end) = match tools.0 {
.map(|(a, b)| (a + pos, b + pos)); Some(ToolKind::Sword) => (29.0, 30.0),
Some(ToolKind::Axe) => (19.0, 20.0),
Some(ToolKind::Hammer) => (19.0, 20.0),
_ => (0.0, 0.0),
};
(
(mat * anim::vek::Vec4::new(0.0, 0.0, trail_start, 1.0)).xyz(),
(mat * anim::vek::Vec4::new(0.0, 0.0, trail_end, 1.0)).xyz(),
)
});
let offsets_abs_trail_points = weapon_offsets.map(|(a, b)| (a + pos, b + pos));
if let Some(trail_mgr) = trail_mgr { if let Some(trail_mgr) = trail_mgr {
if let Some(dynamic_model) = entity if let Some(dynamic_model) = entity
.as_ref() .as_ref()
.and_then(|e| trail_mgr.dynamic_models.get(e)) .and_then(|e| trail_mgr.dynamic_models.get(e))
{ {
let mut quad_mesh = Mesh::new(); let mut quad_mesh = Mesh::new();
if let (Some((p1, p2)), Some((p4, p3))) = let quad = if let (Some((p1, p2)), Some((p4, p3))) =
(self.abs_trail_points, offsets_abs_trail_points) (self.abs_trail_points, offsets_abs_trail_points)
{ {
use StageSection::{Action, Charge, Movement, Recover};
if matches!(
char_ability,
Some(
CharacterAbilityType::BasicMelee(Action)
| CharacterAbilityType::ChargedMelee(Action)
| CharacterAbilityType::DashMelee(Charge | Action)
| CharacterAbilityType::ComboMelee(Action | Recover, _)
| CharacterAbilityType::LeapMelee(Movement | Action)
| CharacterAbilityType::SpinMelee(Action)
)
) {
let vertex = |p: anim::vek::Vec3<f32>| trail::Vertex { let vertex = |p: anim::vek::Vec3<f32>| trail::Vertex {
pos: p.into_array(), pos: p.into_array(),
}; };
quad_mesh.push_quad(Quad::new(vertex(p1), vertex(p2), vertex(p3), vertex(p4))); Quad::new(vertex(p1), vertex(p2), vertex(p3), vertex(p4))
} else { } else {
let zero = trail::Vertex { pos: [0.0; 3] }; let zero = trail::Vertex { pos: [0.0; 3] };
quad_mesh.push_quad(Quad::new(zero, zero, zero, zero)); Quad::new(zero, zero, zero, zero)
} }
} else {
let zero = trail::Vertex { pos: [0.0; 3] };
Quad::new(zero, zero, zero, zero)
};
quad_mesh.push_quad(quad);
renderer.update_model(dynamic_model, &quad_mesh, trail_mgr.offset * 4); renderer.update_model(dynamic_model, &quad_mesh, trail_mgr.offset * 4);
} }
} }

View File

@ -49,7 +49,7 @@ impl anim::Skeleton for VolumeKey {
anim::Offsets { anim::Offsets {
lantern: None, lantern: None,
mount_bone: anim::vek::Transform::default(), mount_bone: anim::vek::Transform::default(),
relative_trail_points: None, weapon_trail_mat: None,
} }
} }

View File

@ -157,6 +157,8 @@ impl Scene {
scale: 1.0, scale: 1.0,
mount_transform_pos: None, mount_transform_pos: None,
body: None, body: None,
tools: (None, None),
char_ability: None,
col: Rgba::broadcast(1.0), col: Rgba::broadcast(1.0),
dt: 15.0, // Want to get there immediately. dt: 15.0, // Want to get there immediately.
_lpindex: 0, _lpindex: 0,
@ -348,6 +350,8 @@ impl Scene {
scale: 1.0, scale: 1.0,
mount_transform_pos: None, mount_transform_pos: None,
body: None, body: None,
tools: (None, None),
char_ability: None,
col: Rgba::broadcast(1.0), col: Rgba::broadcast(1.0),
dt: scene_data.delta_time, dt: scene_data.delta_time,
_lpindex: 0, _lpindex: 0,

View File

@ -19,7 +19,7 @@ pub struct TrailMgr {
pub offset: usize, pub offset: usize,
} }
const TRAIL_DYNAMIC_MODEL_SIZE: usize = 60; const TRAIL_DYNAMIC_MODEL_SIZE: usize = 30;
impl TrailMgr { impl TrailMgr {
pub fn new(_renderer: &mut Renderer) -> Self { pub fn new(_renderer: &mut Renderer) -> Self {