mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Finishing touches
This commit is contained in:
parent
d23dd6c9e9
commit
b558331b32
@ -517,7 +517,7 @@
|
||||
],
|
||||
threshold: 0.5,
|
||||
),
|
||||
Attack(BasicMelee, Dagger): (
|
||||
Attack(BasicMelee(Action), Dagger): (
|
||||
files: [
|
||||
"voxygen.audio.sfx.abilities.swing_sword",
|
||||
],
|
||||
@ -551,7 +551,7 @@
|
||||
],
|
||||
threshold: 0.5,
|
||||
),
|
||||
Attack(BasicMelee, Shield): (
|
||||
Attack(BasicMelee(Action), Shield): (
|
||||
files: [
|
||||
"voxygen.audio.sfx.abilities.swing",
|
||||
],
|
||||
|
@ -9,5 +9,5 @@ layout(location = 0) out vec3 f_pos;
|
||||
void main() {
|
||||
f_pos = v_pos;
|
||||
|
||||
gl_Position = all_mat * vec4(f_pos, 1);
|
||||
gl_Position = all_mat * vec4(f_pos - focus_off.xyz, 1);
|
||||
}
|
||||
|
@ -345,8 +345,12 @@ impl From<AuxiliaryAbility> for Ability {
|
||||
}
|
||||
|
||||
#[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 {
|
||||
BasicMelee,
|
||||
BasicMelee(StageSection),
|
||||
BasicRanged,
|
||||
Boost,
|
||||
ChargedMelee(StageSection),
|
||||
@ -361,12 +365,13 @@ pub enum CharacterAbilityType {
|
||||
RepeaterRanged,
|
||||
BasicAura,
|
||||
SelfBuff,
|
||||
Other,
|
||||
}
|
||||
|
||||
impl From<&CharacterState> for CharacterAbilityType {
|
||||
fn from(state: &CharacterState) -> Self {
|
||||
match state {
|
||||
CharacterState::BasicMelee(_) => Self::BasicMelee,
|
||||
CharacterState::BasicMelee(data) => Self::BasicMelee(data.stage_section),
|
||||
CharacterState::BasicRanged(_) => Self::BasicRanged,
|
||||
CharacterState::Boost(_) => Self::Boost,
|
||||
CharacterState::DashMelee(data) => Self::DashMelee(data.stage_section),
|
||||
@ -381,7 +386,23 @@ impl From<&CharacterState> for CharacterAbilityType {
|
||||
CharacterState::RepeaterRanged(_) => Self::RepeaterRanged,
|
||||
CharacterState::BasicAura(_) => Self::BasicAura,
|
||||
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,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -113,7 +113,7 @@ impl Skeleton for ArthropodSkeleton {
|
||||
orientation: mount_orientation,
|
||||
scale: Vec3::one(),
|
||||
},
|
||||
relative_trail_points: None,
|
||||
weapon_trail_mat: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -137,7 +137,7 @@ impl Skeleton for BipedLargeSkeleton {
|
||||
.into(),
|
||||
..Default::default()
|
||||
},
|
||||
relative_trail_points: None,
|
||||
weapon_trail_mat: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -83,7 +83,7 @@ impl Skeleton for BipedSmallSkeleton {
|
||||
.into(),
|
||||
..Default::default()
|
||||
},
|
||||
relative_trail_points: None,
|
||||
weapon_trail_mat: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -106,7 +106,7 @@ impl Skeleton for BirdLargeSkeleton {
|
||||
.into(),
|
||||
..Default::default()
|
||||
},
|
||||
relative_trail_points: None,
|
||||
weapon_trail_mat: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -60,7 +60,7 @@ impl Skeleton for BirdMediumSkeleton {
|
||||
.into(),
|
||||
..Default::default()
|
||||
},
|
||||
relative_trail_points: None,
|
||||
weapon_trail_mat: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -156,10 +156,7 @@ impl Skeleton for CharacterSkeleton {
|
||||
.into(),
|
||||
..Default::default()
|
||||
},
|
||||
relative_trail_points: Some((
|
||||
(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(),
|
||||
)),
|
||||
weapon_trail_mat: Some(main_mat),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -81,7 +81,7 @@ impl Skeleton for DragonSkeleton {
|
||||
.into(),
|
||||
..Default::default()
|
||||
},
|
||||
relative_trail_points: None,
|
||||
weapon_trail_mat: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -60,7 +60,7 @@ impl Skeleton for FishMediumSkeleton {
|
||||
.into(),
|
||||
..Default::default()
|
||||
},
|
||||
relative_trail_points: None,
|
||||
weapon_trail_mat: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ impl Skeleton for FishSmallSkeleton {
|
||||
.into(),
|
||||
..Default::default()
|
||||
},
|
||||
relative_trail_points: None,
|
||||
weapon_trail_mat: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ impl Skeleton for FixtureSkeleton {
|
||||
Offsets {
|
||||
lantern: None,
|
||||
mount_bone: Transform::default(),
|
||||
relative_trail_points: None,
|
||||
weapon_trail_mat: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -83,7 +83,7 @@ impl Skeleton for GolemSkeleton {
|
||||
.into(),
|
||||
..Default::default()
|
||||
},
|
||||
relative_trail_points: None,
|
||||
weapon_trail_mat: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -43,6 +43,7 @@ impl Skeleton for ItemDropSkeleton {
|
||||
.into(),
|
||||
..Default::default()
|
||||
},
|
||||
weapon_trail_mat: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -103,7 +103,7 @@ pub fn init() { lazy_static::initialize(&LIB); }
|
||||
pub struct Offsets {
|
||||
pub lantern: Option<Vec3<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 {
|
||||
|
@ -49,7 +49,7 @@ impl Skeleton for ObjectSkeleton {
|
||||
.into(),
|
||||
..Default::default()
|
||||
},
|
||||
relative_trail_points: None,
|
||||
weapon_trail_mat: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -97,7 +97,7 @@ impl Skeleton for QuadrupedLowSkeleton {
|
||||
orientation: mount_orientation,
|
||||
scale: Vec3::one(),
|
||||
},
|
||||
relative_trail_points: None,
|
||||
weapon_trail_mat: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -109,7 +109,7 @@ impl Skeleton for QuadrupedMediumSkeleton {
|
||||
orientation: mount_orientation,
|
||||
scale: Vec3::one(),
|
||||
},
|
||||
relative_trail_points: None,
|
||||
weapon_trail_mat: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -74,7 +74,7 @@ impl Skeleton for QuadrupedSmallSkeleton {
|
||||
orientation: mount_orientation,
|
||||
scale: Vec3::one(),
|
||||
},
|
||||
relative_trail_points: None,
|
||||
weapon_trail_mat: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ impl Skeleton for ShipSkeleton {
|
||||
),
|
||||
..Default::default()
|
||||
},
|
||||
relative_trail_points: None,
|
||||
weapon_trail_mat: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -84,7 +84,7 @@ impl Skeleton for TheropodSkeleton {
|
||||
.into(),
|
||||
..Default::default()
|
||||
},
|
||||
relative_trail_points: None,
|
||||
weapon_trail_mat: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -33,8 +33,9 @@ use common::{
|
||||
comp::{
|
||||
inventory::slot::EquipSlot,
|
||||
item::{Hands, ItemKind, ToolKind},
|
||||
Body, CharacterState, Collider, Controller, Health, Inventory, Item, ItemKey, Last,
|
||||
LightAnimation, LightEmitter, Ori, PhysicsState, PoiseState, Pos, Scale, Vel,
|
||||
Body, CharacterAbilityType, CharacterState, Collider, Controller, Health, Inventory, Item,
|
||||
ItemKey, Last, LightAnimation, LightEmitter, Ori, PhysicsState, PoiseState, Pos, Scale,
|
||||
Vel,
|
||||
},
|
||||
link::Is,
|
||||
mounting::Rider,
|
||||
@ -862,6 +863,8 @@ impl FigureMgr {
|
||||
scale,
|
||||
mount_transform_pos,
|
||||
body: Some(body),
|
||||
tools: (active_tool_kind, second_tool_kind),
|
||||
char_ability: character.map(|c| c.into()),
|
||||
col,
|
||||
dt,
|
||||
_lpindex: lpindex,
|
||||
@ -5368,6 +5371,7 @@ impl FigureMgr {
|
||||
state.skeleton = anim::vek::Lerp::lerp(&state.skeleton, &target_bones, dt_lerp);
|
||||
state.update(
|
||||
renderer,
|
||||
Some(trail_mgr),
|
||||
&mut update_buf,
|
||||
&common_params,
|
||||
state_animation_rate,
|
||||
@ -6244,6 +6248,8 @@ pub struct FigureUpdateCommonParameters<'a> {
|
||||
pub scale: f32,
|
||||
pub mount_transform_pos: Option<(anim::vek::Transform<f32, f32, f32>, anim::vek::Vec3<f32>)>,
|
||||
pub body: Option<Body>,
|
||||
pub tools: (Option<ToolKind>, Option<ToolKind>),
|
||||
pub char_ability: Option<CharacterAbilityType>,
|
||||
pub col: vek::Rgba<f32>,
|
||||
pub dt: f32,
|
||||
// TODO: evaluate unused variable
|
||||
@ -6266,9 +6272,7 @@ impl<S: Skeleton> FigureState<S> {
|
||||
Self {
|
||||
meta: FigureStateMeta {
|
||||
lantern_offset: offsets.lantern,
|
||||
abs_trail_points: offsets.relative_trail_points, /* No position to add and make
|
||||
* absolute, also doesn't matter
|
||||
* here */
|
||||
abs_trail_points: None,
|
||||
mount_transform: offsets.mount_bone,
|
||||
mount_world_pos: anim::vek::Vec3::zero(),
|
||||
state_time: 0.0,
|
||||
@ -6299,6 +6303,8 @@ impl<S: Skeleton> FigureState<S> {
|
||||
scale,
|
||||
mount_transform_pos,
|
||||
body,
|
||||
tools,
|
||||
char_ability,
|
||||
col,
|
||||
dt,
|
||||
_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]);
|
||||
self.lantern_offset = offsets.lantern;
|
||||
// Handle weapon trails
|
||||
let offsets_abs_trail_points = offsets
|
||||
.relative_trail_points
|
||||
.map(|(a, b)| (a + pos, b + pos));
|
||||
let weapon_offsets = offsets.weapon_trail_mat.map(|mat| {
|
||||
let (trail_start, trail_end) = match tools.0 {
|
||||
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(dynamic_model) = entity
|
||||
.as_ref()
|
||||
.and_then(|e| trail_mgr.dynamic_models.get(e))
|
||||
{
|
||||
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)
|
||||
{
|
||||
let vertex = |p: anim::vek::Vec3<f32>| trail::Vertex {
|
||||
pos: p.into_array(),
|
||||
};
|
||||
quad_mesh.push_quad(Quad::new(vertex(p1), vertex(p2), vertex(p3), vertex(p4)));
|
||||
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 {
|
||||
pos: p.into_array(),
|
||||
};
|
||||
Quad::new(vertex(p1), vertex(p2), vertex(p3), vertex(p4))
|
||||
} else {
|
||||
let zero = trail::Vertex { pos: [0.0; 3] };
|
||||
Quad::new(zero, zero, zero, zero)
|
||||
}
|
||||
} else {
|
||||
let zero = trail::Vertex { pos: [0.0; 3] };
|
||||
quad_mesh.push_quad(Quad::new(zero, zero, zero, zero));
|
||||
}
|
||||
Quad::new(zero, zero, zero, zero)
|
||||
};
|
||||
quad_mesh.push_quad(quad);
|
||||
renderer.update_model(dynamic_model, &quad_mesh, trail_mgr.offset * 4);
|
||||
}
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ impl anim::Skeleton for VolumeKey {
|
||||
anim::Offsets {
|
||||
lantern: None,
|
||||
mount_bone: anim::vek::Transform::default(),
|
||||
relative_trail_points: None,
|
||||
weapon_trail_mat: None,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -157,6 +157,8 @@ impl Scene {
|
||||
scale: 1.0,
|
||||
mount_transform_pos: None,
|
||||
body: None,
|
||||
tools: (None, None),
|
||||
char_ability: None,
|
||||
col: Rgba::broadcast(1.0),
|
||||
dt: 15.0, // Want to get there immediately.
|
||||
_lpindex: 0,
|
||||
@ -348,6 +350,8 @@ impl Scene {
|
||||
scale: 1.0,
|
||||
mount_transform_pos: None,
|
||||
body: None,
|
||||
tools: (None, None),
|
||||
char_ability: None,
|
||||
col: Rgba::broadcast(1.0),
|
||||
dt: scene_data.delta_time,
|
||||
_lpindex: 0,
|
||||
|
@ -19,7 +19,7 @@ pub struct TrailMgr {
|
||||
pub offset: usize,
|
||||
}
|
||||
|
||||
const TRAIL_DYNAMIC_MODEL_SIZE: usize = 60;
|
||||
const TRAIL_DYNAMIC_MODEL_SIZE: usize = 30;
|
||||
|
||||
impl TrailMgr {
|
||||
pub fn new(_renderer: &mut Renderer) -> Self {
|
||||
|
Loading…
Reference in New Issue
Block a user