From e5ae4918a42352b6bca31c84b98dc9424cccf060 Mon Sep 17 00:00:00 2001 From: Benjamin Saunders Date: Sun, 21 Jan 2024 18:58:57 -0800 Subject: [PATCH] Simplify client::Sim::view --- client/src/local_character_controller.rs | 8 ++++++-- client/src/sim.rs | 7 ++----- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/client/src/local_character_controller.rs b/client/src/local_character_controller.rs index ef55dd41..a4197d7a 100644 --- a/client/src/local_character_controller.rs +++ b/client/src/local_character_controller.rs @@ -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 { diff --git a/client/src/sim.rs b/client/src/sim.rs index b3139346..78b9dff7 100644 --- a/client/src/sim.rs +++ b/client/src/sim.rs @@ -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 }