From 3450bfabfda6a92dbd2d7a5b2e0e3f44e838858b Mon Sep 17 00:00:00 2001 From: Imbris Date: Fri, 24 Apr 2020 20:30:20 -0400 Subject: [PATCH] Add orientation to debug text --- voxygen/src/hud/mod.rs | 18 +++++++++++++++++- voxygen/src/session.rs | 8 ++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/voxygen/src/hud/mod.rs b/voxygen/src/hud/mod.rs index 4b8f951c89..9268d31170 100644 --- a/voxygen/src/hud/mod.rs +++ b/voxygen/src/hud/mod.rs @@ -143,6 +143,7 @@ widget_ids! { ping, coordinates, velocity, + orientation, loaded_distance, time, entity_count, @@ -196,6 +197,7 @@ pub struct DebugInfo { pub ping_ms: f64, pub coordinates: Option, pub velocity: Option, + pub ori: Option, pub num_chunks: u32, pub num_visible_chunks: u32, pub num_figures: u32, @@ -1449,6 +1451,20 @@ impl Hud { .font_id(self.fonts.cyri.conrod_id) .font_size(self.fonts.cyri.scale(14)) .set(self.ids.velocity, ui_widgets); + // Player's orientation vector + let orientation_text = match debug_info.ori { + Some(ori) => format!( + "Orientation: ({:.1}, {:.1}, {:.1})", + ori.0.x, ori.0.y, ori.0.z, + ), + None => "Player has no Ori component".to_owned(), + }; + Text::new(&orientation_text) + .color(TEXT_COLOR) + .down_from(self.ids.velocity, 5.0) + .font_id(self.fonts.cyri.conrod_id) + .font_size(self.fonts.cyri.scale(14)) + .set(self.ids.orientation, ui_widgets); // Loaded distance Text::new(&format!( "View distance: {:.2} blocks ({:.2} chunks)", @@ -1456,7 +1472,7 @@ impl Hud { client.loaded_distance() / TerrainChunk::RECT_SIZE.x as f32, )) .color(TEXT_COLOR) - .down_from(self.ids.velocity, 5.0) + .down_from(self.ids.orientation, 5.0) .font_id(self.fonts.cyri.conrod_id) .font_size(self.fonts.cyri.scale(14)) .set(self.ids.loaded_distance, ui_widgets); diff --git a/voxygen/src/session.rs b/voxygen/src/session.rs index b8ab4cd0bc..49029e0e1b 100644 --- a/voxygen/src/session.rs +++ b/voxygen/src/session.rs @@ -497,6 +497,14 @@ impl PlayState for SessionState { .read_storage::() .get(self.client.borrow().entity()) .cloned(), + ori: self + .client + .borrow() + .state() + .ecs() + .read_storage::() + .get(self.client.borrow().entity()) + .cloned(), num_chunks: self.scene.terrain().chunk_count() as u32, num_visible_chunks: self.scene.terrain().visible_chunk_count() as u32, num_figures: self.scene.figure_mgr().figure_count() as u32,