Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify client::Sim::view #346

Merged
merged 1 commit into from
Jan 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading