diff --git a/voxygen/src/scene/mod.rs b/voxygen/src/scene/mod.rs index 365c5a0490..116ca9f5d8 100644 --- a/voxygen/src/scene/mod.rs +++ b/voxygen/src/scene/mod.rs @@ -1181,4 +1181,43 @@ impl Scene { keep }); } + + pub fn maintain_debug_relative_wind( + &mut self, + client: &Client, + settings: &Settings, + debug_shape_id: &mut Option, + ) { + if settings.interface.toggle_hitboxes { + let ecs = client.state().ecs(); + let entity = client.entity(); + + let rel_flow = ecs + .read_storage::() + .get(entity) + .and_then(|physics| physics.in_fluid) + .and_then(|fluid| { + ecs.read_storage::() + .get(entity) + .map(|vel| fluid.relative_flow(vel)) + }); + + if let (Some(pos), Some(rel_flow)) = ( + ecs.read_storage::().get(entity).copied(), + rel_flow, + ) { + if let Some(shape_id) = debug_shape_id { + self.debug.remove_shape(*shape_id); + } + let shape_id = self + .debug + .add_shape(DebugShape::Line([Vec3::zero(), rel_flow.0 * 0.2])); + debug_shape_id.insert(shape_id); + + let hb_pos = [pos.0.x, pos.0.y, pos.0.z + 2.0, 0.0]; + let color = [0.0, 1.0, 1.0, 0.5]; + self.debug.set_pos_and_color(shape_id, hb_pos, color); + } + } + } } diff --git a/voxygen/src/session/mod.rs b/voxygen/src/session/mod.rs index 5792cb46e4..779a051d50 100644 --- a/voxygen/src/session/mod.rs +++ b/voxygen/src/session/mod.rs @@ -75,6 +75,7 @@ pub struct SessionState { interactable: Option, saved_zoom_dist: Option, hitboxes: HashMap, + debug_wind: Option, } /// Represents an active game session (i.e., the one being played). @@ -123,6 +124,7 @@ impl SessionState { interactable: None, saved_zoom_dist: None, hitboxes: HashMap::new(), + debug_wind: None, } } @@ -144,6 +146,8 @@ impl SessionState { let mut client = self.client.borrow_mut(); self.scene .maintain_debug_hitboxes(&client, &global_state.settings, &mut self.hitboxes); + self.scene + .maintain_debug_relative_wind(&client, &global_state.settings, &mut self.debug_wind); for event in client.tick(self.inputs.clone(), dt, crate::ecs::sys::add_local_systems)? { match event { client::Event::Chat(m) => { @@ -1372,6 +1376,12 @@ impl PlayState for SessionState { &scene_data, &client, ); + self.scene.maintain( + global_state.window.renderer_mut(), + &mut global_state.audio, + &scene_data, + &client, + ); // Process outcomes from client for outcome in outcomes {