Body specific beam offsets

This commit is contained in:
Snowram 2021-04-24 02:03:07 +02:00
parent 8f54a0bf31
commit c16ec43938
6 changed files with 19 additions and 29 deletions

View File

@ -45,6 +45,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Drag is now calculated based on physical properties - Drag is now calculated based on physical properties
- Terrain chunks are now deflate-compressed when sent over the network. - Terrain chunks are now deflate-compressed when sent over the network.
- Missing translations can be displayed in English. - Missing translations can be displayed in English.
- New large birds npcs
- Day period dependant wildlife spawns
### Changed ### Changed

View File

@ -282,7 +282,7 @@ impl Body {
}, },
Body::BipedSmall(_) => Vec3::new(1.0, 0.75, 1.4), Body::BipedSmall(_) => Vec3::new(1.0, 0.75, 1.4),
Body::BirdMedium(_) => Vec3::new(2.0, 1.0, 1.1), Body::BirdMedium(_) => Vec3::new(2.0, 1.0, 1.1),
Body::BirdLarge(_) => Vec3::new(2.0, 5.5, 3.8), Body::BirdLarge(_) => Vec3::new(2.0, 5.0, 2.4),
Body::Dragon(_) => Vec3::new(16.0, 10.0, 16.0), Body::Dragon(_) => Vec3::new(16.0, 10.0, 16.0),
Body::FishMedium(_) => Vec3::new(0.5, 2.0, 0.8), Body::FishMedium(_) => Vec3::new(0.5, 2.0, 0.8),
Body::FishSmall(_) => Vec3::new(0.3, 1.2, 0.6), Body::FishSmall(_) => Vec3::new(0.3, 1.2, 0.6),

View File

@ -3,7 +3,7 @@ use crate::{
Attack, AttackDamage, AttackEffect, CombatEffect, CombatRequirement, Damage, DamageSource, Attack, AttackDamage, AttackEffect, CombatEffect, CombatRequirement, Damage, DamageSource,
GroupTarget, GroupTarget,
}, },
comp::{beam, CharacterState, EnergyChange, EnergySource, Ori, Pos, StateUpdate}, comp::{beam, Body, CharacterState, EnergyChange, EnergySource, Ori, Pos, StateUpdate},
event::ServerEvent, event::ServerEvent,
states::{ states::{
behavior::{CharacterBehavior, JoinData}, behavior::{CharacterBehavior, JoinData},
@ -136,11 +136,15 @@ impl CharacterBehavior for Data {
owner: Some(*data.uid), owner: Some(*data.uid),
specifier: self.static_data.specifier, specifier: self.static_data.specifier,
}; };
let body_offsets_z = match data.body {
Body::BirdLarge(_) => data.body.height() * 0.9,
_ => data.body.height() * 0.5,
};
// Gets offsets // Gets offsets
let body_offsets = Vec3::new( let body_offsets = Vec3::new(
(data.body.radius() + 0.2) * data.inputs.look_dir.x, (data.body.radius() + 1.0) * data.inputs.look_dir.x,
(data.body.radius() + 0.2) * data.inputs.look_dir.y, (data.body.radius() + 1.0) * data.inputs.look_dir.y,
data.body.eye_height() * 0.6, body_offsets_z,
); );
let pos = Pos(data.pos.0 + body_offsets); let pos = Pos(data.pos.0 + body_offsets);
// Create beam segment // Create beam segment

View File

@ -6,16 +6,7 @@ use common::{states::utils::StageSection, util::Dir};
pub struct ShootAnimation; pub struct ShootAnimation;
type ShootAnimationDependency = ( type ShootAnimationDependency = (f32, Option<StageSection>, f32, Dir, bool);
f32,
f32,
Vec3<f32>,
Vec3<f32>,
Option<StageSection>,
f32,
Dir,
bool,
);
impl Animation for ShootAnimation { impl Animation for ShootAnimation {
type Dependency = ShootAnimationDependency; type Dependency = ShootAnimationDependency;
@ -27,16 +18,7 @@ impl Animation for ShootAnimation {
#[cfg_attr(feature = "be-dyn-lib", export_name = "bird_large_shoot")] #[cfg_attr(feature = "be-dyn-lib", export_name = "bird_large_shoot")]
fn update_skeleton_inner( fn update_skeleton_inner(
skeleton: &Self::Skeleton, skeleton: &Self::Skeleton,
( (global_time, stage_section, timer, look_dir, on_ground): Self::Dependency,
_velocity,
global_time,
_orientation,
_last_ori,
stage_section,
timer,
look_dir,
on_ground,
): Self::Dependency,
anim_time: f32, anim_time: f32,
_rate: &mut f32, _rate: &mut f32,
s_a: &SkeletonAttr, s_a: &SkeletonAttr,

View File

@ -27,7 +27,12 @@ pub fn criterion_benchmark(c: &mut Criterion) {
(0..GEN_SIZE) (0..GEN_SIZE)
.flat_map(|x| (0..GEN_SIZE).map(move |y| Vec2::new(x, y))) .flat_map(|x| (0..GEN_SIZE).map(move |y| Vec2::new(x, y)))
.map(|offset| offset + CENTER) .map(|offset| offset + CENTER)
.map(|pos| (pos, world.generate_chunk(index, pos, || false).unwrap())) .map(|pos| {
(
pos,
world.generate_chunk(index, pos, || false, None).unwrap(),
)
})
.for_each(|(key, chunk)| { .for_each(|(key, chunk)| {
terrain.insert(key, Arc::new(chunk.0)); terrain.insert(key, Arc::new(chunk.0));
}); });

View File

@ -3441,10 +3441,7 @@ impl FigureMgr {
anim::bird_large::ShootAnimation::update_skeleton( anim::bird_large::ShootAnimation::update_skeleton(
&target_base, &target_base,
( (
rel_vel.magnitude(),
time, time,
ori * anim::vek::Vec3::<f32>::unit_y(),
state.last_ori * anim::vek::Vec3::<f32>::unit_y(),
Some(s.stage_section), Some(s.stage_section),
state.state_time, state.state_time,
look_dir, look_dir,