mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Fix Beam orientation, remove orientation_behavior
* make old OrientationBehavior::FromOri default behaviour * use rotation formed from look_dir instead of constructing ori on the fly (which is altered after normalization).
This commit is contained in:
parent
edd37ad491
commit
8a83ecf57f
@ -14,7 +14,6 @@ BasicBeam(
|
|||||||
))),
|
))),
|
||||||
energy_regen: 0,
|
energy_regen: 0,
|
||||||
energy_drain: 0,
|
energy_drain: 0,
|
||||||
orientation_behavior: Normal,
|
|
||||||
ori_rate: 0.3,
|
ori_rate: 0.3,
|
||||||
specifier: Cultist,
|
specifier: Cultist,
|
||||||
)
|
)
|
||||||
|
@ -14,7 +14,6 @@ BasicBeam(
|
|||||||
))),
|
))),
|
||||||
energy_regen: 0,
|
energy_regen: 0,
|
||||||
energy_drain: 0,
|
energy_drain: 0,
|
||||||
orientation_behavior: Normal,
|
|
||||||
ori_rate: 0.3,
|
ori_rate: 0.3,
|
||||||
specifier: Flamethrower,
|
specifier: Flamethrower,
|
||||||
)
|
)
|
||||||
|
@ -14,7 +14,6 @@ BasicBeam(
|
|||||||
))),
|
))),
|
||||||
energy_regen: 0,
|
energy_regen: 0,
|
||||||
energy_drain: 0,
|
energy_drain: 0,
|
||||||
orientation_behavior: Normal,
|
|
||||||
ori_rate: 0.3,
|
ori_rate: 0.3,
|
||||||
specifier: Flamethrower,
|
specifier: Flamethrower,
|
||||||
)
|
)
|
||||||
|
@ -14,7 +14,6 @@ BasicBeam(
|
|||||||
))),
|
))),
|
||||||
energy_regen: 50,
|
energy_regen: 50,
|
||||||
energy_drain: 0,
|
energy_drain: 0,
|
||||||
orientation_behavior: FromOri,
|
|
||||||
ori_rate: 0.07,
|
ori_rate: 0.07,
|
||||||
specifier: ClayGolem,
|
specifier: ClayGolem,
|
||||||
)
|
)
|
||||||
|
@ -14,7 +14,6 @@ BasicBeam(
|
|||||||
))),
|
))),
|
||||||
energy_regen: 0,
|
energy_regen: 0,
|
||||||
energy_drain: 0,
|
energy_drain: 0,
|
||||||
orientation_behavior: Normal,
|
|
||||||
ori_rate: 0.2,
|
ori_rate: 0.2,
|
||||||
specifier: Flamethrower,
|
specifier: Flamethrower,
|
||||||
)
|
)
|
||||||
|
@ -14,7 +14,6 @@ BasicBeam(
|
|||||||
))),
|
))),
|
||||||
energy_regen: 0,
|
energy_regen: 0,
|
||||||
energy_drain: 0,
|
energy_drain: 0,
|
||||||
orientation_behavior: FromOri,
|
|
||||||
ori_rate: 0.2,
|
ori_rate: 0.2,
|
||||||
specifier: Cultist,
|
specifier: Cultist,
|
||||||
)
|
)
|
||||||
|
@ -9,7 +9,6 @@ BasicBeam(
|
|||||||
damage_effect: Some(Lifesteal(0.15)),
|
damage_effect: Some(Lifesteal(0.15)),
|
||||||
energy_regen: 25,
|
energy_regen: 25,
|
||||||
energy_drain: 0,
|
energy_drain: 0,
|
||||||
orientation_behavior: Normal,
|
|
||||||
ori_rate: 0.3,
|
ori_rate: 0.3,
|
||||||
specifier: LifestealBeam,
|
specifier: LifestealBeam,
|
||||||
)
|
)
|
||||||
|
@ -14,7 +14,6 @@ BasicBeam(
|
|||||||
))),
|
))),
|
||||||
energy_regen: 0,
|
energy_regen: 0,
|
||||||
energy_drain: 0,
|
energy_drain: 0,
|
||||||
orientation_behavior: Normal,
|
|
||||||
ori_rate: 0.3,
|
ori_rate: 0.3,
|
||||||
specifier: Flamethrower,
|
specifier: Flamethrower,
|
||||||
)
|
)
|
||||||
|
@ -14,7 +14,6 @@ BasicBeam(
|
|||||||
))),
|
))),
|
||||||
energy_regen: 0,
|
energy_regen: 0,
|
||||||
energy_drain: 0,
|
energy_drain: 0,
|
||||||
orientation_behavior: Normal,
|
|
||||||
ori_rate: 0.3,
|
ori_rate: 0.3,
|
||||||
specifier: Bubbles,
|
specifier: Bubbles,
|
||||||
)
|
)
|
||||||
|
@ -14,7 +14,6 @@ BasicBeam(
|
|||||||
))),
|
))),
|
||||||
energy_regen: 0,
|
energy_regen: 0,
|
||||||
energy_drain: 0,
|
energy_drain: 0,
|
||||||
orientation_behavior: Normal,
|
|
||||||
ori_rate: 0.3,
|
ori_rate: 0.3,
|
||||||
specifier: Flamethrower,
|
specifier: Flamethrower,
|
||||||
)
|
)
|
||||||
|
@ -14,7 +14,6 @@ BasicBeam(
|
|||||||
))),
|
))),
|
||||||
energy_regen: 0,
|
energy_regen: 0,
|
||||||
energy_drain: 0,
|
energy_drain: 0,
|
||||||
orientation_behavior: FromOri,
|
|
||||||
ori_rate: 0.1,
|
ori_rate: 0.1,
|
||||||
specifier: Frost,
|
specifier: Frost,
|
||||||
)
|
)
|
||||||
|
@ -9,7 +9,6 @@ BasicBeam(
|
|||||||
damage_effect: Some(Lifesteal(0.125)),
|
damage_effect: Some(Lifesteal(0.125)),
|
||||||
energy_regen: 50,
|
energy_regen: 50,
|
||||||
energy_drain: 0,
|
energy_drain: 0,
|
||||||
orientation_behavior: Normal,
|
|
||||||
ori_rate: 0.3,
|
ori_rate: 0.3,
|
||||||
specifier: LifestealBeam
|
specifier: LifestealBeam
|
||||||
)
|
)
|
||||||
|
@ -14,7 +14,6 @@ BasicBeam(
|
|||||||
))),
|
))),
|
||||||
energy_regen: 0,
|
energy_regen: 0,
|
||||||
energy_drain: 350,
|
energy_drain: 350,
|
||||||
orientation_behavior: Normal,
|
|
||||||
ori_rate: 0.3,
|
ori_rate: 0.3,
|
||||||
specifier: Flamethrower,
|
specifier: Flamethrower,
|
||||||
)
|
)
|
||||||
|
@ -14,7 +14,6 @@ BasicBeam(
|
|||||||
))),
|
))),
|
||||||
energy_regen: 0,
|
energy_regen: 0,
|
||||||
energy_drain: 350,
|
energy_drain: 350,
|
||||||
orientation_behavior: FromOri,
|
|
||||||
ori_rate: 0.3,
|
ori_rate: 0.3,
|
||||||
specifier: Flamethrower,
|
specifier: Flamethrower,
|
||||||
)
|
)
|
||||||
|
@ -251,7 +251,6 @@ pub enum CharacterAbility {
|
|||||||
damage_effect: Option<CombatEffect>,
|
damage_effect: Option<CombatEffect>,
|
||||||
energy_regen: f32,
|
energy_regen: f32,
|
||||||
energy_drain: f32,
|
energy_drain: f32,
|
||||||
orientation_behavior: basic_beam::OrientationBehavior,
|
|
||||||
ori_rate: f32,
|
ori_rate: f32,
|
||||||
specifier: beam::FrontendSpecifier,
|
specifier: beam::FrontendSpecifier,
|
||||||
},
|
},
|
||||||
@ -745,7 +744,6 @@ impl CharacterAbility {
|
|||||||
ref mut damage_effect,
|
ref mut damage_effect,
|
||||||
energy_regen: _,
|
energy_regen: _,
|
||||||
ref mut energy_drain,
|
ref mut energy_drain,
|
||||||
orientation_behavior: _,
|
|
||||||
ori_rate: _,
|
ori_rate: _,
|
||||||
specifier: _,
|
specifier: _,
|
||||||
} => {
|
} => {
|
||||||
@ -1878,7 +1876,6 @@ impl From<(&CharacterAbility, AbilityInfo, &JoinData<'_>)> for CharacterState {
|
|||||||
damage_effect,
|
damage_effect,
|
||||||
energy_regen,
|
energy_regen,
|
||||||
energy_drain,
|
energy_drain,
|
||||||
orientation_behavior,
|
|
||||||
ori_rate,
|
ori_rate,
|
||||||
specifier,
|
specifier,
|
||||||
} => CharacterState::BasicBeam(basic_beam::Data {
|
} => CharacterState::BasicBeam(basic_beam::Data {
|
||||||
@ -1894,7 +1891,6 @@ impl From<(&CharacterAbility, AbilityInfo, &JoinData<'_>)> for CharacterState {
|
|||||||
energy_regen: *energy_regen,
|
energy_regen: *energy_regen,
|
||||||
energy_drain: *energy_drain,
|
energy_drain: *energy_drain,
|
||||||
ability_info,
|
ability_info,
|
||||||
orientation_behavior: *orientation_behavior,
|
|
||||||
ori_rate: *ori_rate,
|
ori_rate: *ori_rate,
|
||||||
specifier: *specifier,
|
specifier: *specifier,
|
||||||
},
|
},
|
||||||
|
@ -10,6 +10,7 @@ use crate::{
|
|||||||
utils::*,
|
utils::*,
|
||||||
},
|
},
|
||||||
uid::Uid,
|
uid::Uid,
|
||||||
|
util::Dir,
|
||||||
};
|
};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
@ -38,8 +39,6 @@ pub struct StaticData {
|
|||||||
pub energy_regen: f32,
|
pub energy_regen: f32,
|
||||||
/// Energy drained per second
|
/// Energy drained per second
|
||||||
pub energy_drain: f32,
|
pub energy_drain: f32,
|
||||||
/// Used to dictate how orientation functions in this state
|
|
||||||
pub orientation_behavior: OrientationBehavior,
|
|
||||||
/// How fast enemy can rotate with beam
|
/// How fast enemy can rotate with beam
|
||||||
pub ori_rate: f32,
|
pub ori_rate: f32,
|
||||||
/// What key is used to press ability
|
/// What key is used to press ability
|
||||||
@ -64,9 +63,6 @@ impl CharacterBehavior for Data {
|
|||||||
let mut update = StateUpdate::from(data);
|
let mut update = StateUpdate::from(data);
|
||||||
|
|
||||||
let ori_rate = self.static_data.ori_rate;
|
let ori_rate = self.static_data.ori_rate;
|
||||||
if self.static_data.orientation_behavior == OrientationBehavior::Turret {
|
|
||||||
update.ori = Ori::from(data.inputs.look_dir);
|
|
||||||
}
|
|
||||||
|
|
||||||
handle_orientation(data, &mut update, ori_rate);
|
handle_orientation(data, &mut update, ori_rate);
|
||||||
handle_move(data, &mut update, 0.4);
|
handle_move(data, &mut update, 0.4);
|
||||||
@ -142,16 +138,25 @@ impl CharacterBehavior for Data {
|
|||||||
Body::Golem(_) => data.body.height() * 0.9 + data.inputs.look_dir.z * 3.0,
|
Body::Golem(_) => data.body.height() * 0.9 + data.inputs.look_dir.z * 3.0,
|
||||||
_ => data.body.height() * 0.5,
|
_ => data.body.height() * 0.5,
|
||||||
};
|
};
|
||||||
let (body_offsets, ori) = match self.static_data.orientation_behavior {
|
let (body_offsets, ori) = {
|
||||||
OrientationBehavior::Normal | OrientationBehavior::Turret => (
|
// We want Beam to use Ori.
|
||||||
Vec3::new(
|
// But we also want beam to use Z part of where you look.
|
||||||
body_offsets_r * data.inputs.look_dir.x,
|
// This means that we need to merge this data to one Ori.
|
||||||
body_offsets_r * data.inputs.look_dir.y,
|
//
|
||||||
body_offsets_z,
|
// This code just gets look_dir without Z part
|
||||||
),
|
// and normalizes it. This is what `xy_dir is`.
|
||||||
Ori::from(data.inputs.look_dir),
|
//
|
||||||
),
|
// Then we find rotation between xy_dir and look_dir
|
||||||
OrientationBehavior::FromOri => (
|
// which gives us quaternion how of what rotation we need
|
||||||
|
// to do to get Z part we want.
|
||||||
|
//
|
||||||
|
// Then we construct Ori without Z part
|
||||||
|
// and applying `pitch` to get needed orientation.
|
||||||
|
let look_dir = data.inputs.look_dir;
|
||||||
|
let xy_dir = Dir::from_unnormalized(Vec3::new(look_dir.x, look_dir.y, 0.0))
|
||||||
|
.unwrap_or_else(Dir::default);
|
||||||
|
let pitch = xy_dir.rotation_between(look_dir);
|
||||||
|
(
|
||||||
Vec3::new(
|
Vec3::new(
|
||||||
body_offsets_r * update.ori.look_vec().x,
|
body_offsets_r * update.ori.look_vec().x,
|
||||||
body_offsets_r * update.ori.look_vec().y,
|
body_offsets_r * update.ori.look_vec().y,
|
||||||
@ -160,9 +165,10 @@ impl CharacterBehavior for Data {
|
|||||||
Ori::from(Vec3::new(
|
Ori::from(Vec3::new(
|
||||||
update.ori.look_vec().x,
|
update.ori.look_vec().x,
|
||||||
update.ori.look_vec().y,
|
update.ori.look_vec().y,
|
||||||
data.inputs.look_dir.z,
|
0.0,
|
||||||
)),
|
))
|
||||||
),
|
.prerotated(pitch),
|
||||||
|
)
|
||||||
};
|
};
|
||||||
let pos = Pos(data.pos.0 + body_offsets);
|
let pos = Pos(data.pos.0 + body_offsets);
|
||||||
// Create beam segment
|
// Create beam segment
|
||||||
@ -218,15 +224,3 @@ impl CharacterBehavior for Data {
|
|||||||
update
|
update
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)]
|
|
||||||
pub enum OrientationBehavior {
|
|
||||||
/// Uses look_dir as direction of beam
|
|
||||||
Normal,
|
|
||||||
/// Uses look_dir as direction of beam, sets orientation to same direction
|
|
||||||
/// as look_dir
|
|
||||||
Turret,
|
|
||||||
/// Uses orientation x and y and look_dir z as direction of beam (z from
|
|
||||||
/// look_dir as orientation will only go through 2d rotations naturally)
|
|
||||||
FromOri,
|
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user