Skip to content

Commit

Permalink
Simplify client::Sim::view
Browse files Browse the repository at this point in the history
  • Loading branch information
Ralith committed Jan 22, 2024
1 parent 1153055 commit e5ae491
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
8 changes: 6 additions & 2 deletions client/src/local_character_controller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,12 @@ impl LocalCharacterController {
}
}

pub fn position(&self) -> Position {
self.position
/// Get the current position with orientation applied to it
pub fn oriented_position(&self) -> Position {
Position {
node: self.position.node,
local: self.position.local * self.orientation.to_homogeneous(),
}
}

pub fn orientation(&self) -> na::UnitQuaternion<f32> {
Expand Down
7 changes: 2 additions & 5 deletions client/src/sim.rs
Original file line number Diff line number Diff line change
Expand Up @@ -437,14 +437,11 @@ impl Sim {
}

pub fn view(&self) -> Position {
let mut pos = self.local_character_controller.position();
let mut pos = self.local_character_controller.oriented_position();
let up = self.graph.get_relative_up(&pos).unwrap();
pos.local *= common::math::translate_along(
&(up.as_ref() * (self.cfg.character.character_radius - 1e-3)),
) * self
.local_character_controller
.orientation()
.to_homogeneous();
);
pos
}

Expand Down

0 comments on commit e5ae491

Please sign in to comment.