mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Merge branch 'sam/remove-angle-between' into 'master'
Removed angle between with dot product in handle_orientation. See merge request veloren/veloren!2933
This commit is contained in:
commit
2c9736268d
@ -208,6 +208,8 @@ impl Ori {
|
||||
if angle < PI { angle } else { TAU - angle }
|
||||
}
|
||||
|
||||
pub fn dot(self, other: Self) -> f32 { self.look_vec().dot(other.look_vec()) }
|
||||
|
||||
pub fn pitched_up(self, angle_radians: f32) -> Self {
|
||||
self.rotated(Quaternion::rotation_x(angle_radians))
|
||||
}
|
||||
|
@ -404,8 +404,10 @@ pub fn handle_orientation(
|
||||
.map_or_else(|| data.ori.to_horizontal(), |dir| dir.into())
|
||||
};
|
||||
let rate = {
|
||||
let angle = update.ori.angle_between(target_ori);
|
||||
data.body.base_ori_rate() * efficiency * std::f32::consts::PI / angle
|
||||
// Angle factor used to keep turning rate approximately constant by
|
||||
// counteracting slerp turning more with a larger angle
|
||||
let angle_factor = 2.0 / (1.0 - update.ori.dot(target_ori)).sqrt();
|
||||
data.body.base_ori_rate() * efficiency * angle_factor
|
||||
};
|
||||
update.ori = update
|
||||
.ori
|
||||
|
Loading…
Reference in New Issue
Block a user