diff --git a/voxygen/src/hud/mod.rs b/voxygen/src/hud/mod.rs index 48d60c6bd5..7af4cad854 100644 --- a/voxygen/src/hud/mod.rs +++ b/voxygen/src/hud/mod.rs @@ -994,7 +994,7 @@ impl Hud { .font_id(self.fonts.cyri) .font_size(14) .set(self.ids.entity_count, ui_widgets); - + // Number of chunks Text::new(&format!( "Chunks: {} ({} visible)", diff --git a/voxygen/src/hud/settings_window.rs b/voxygen/src/hud/settings_window.rs index 6d08ac6969..b63678dc58 100644 --- a/voxygen/src/hud/settings_window.rs +++ b/voxygen/src/hud/settings_window.rs @@ -1351,7 +1351,9 @@ impl<'a> Widget for SettingsWindow<'a> { ]; // Get which AA mode is currently active - let selected = mode_list.iter().position(|x| *x == self.global_state.settings.graphics.aa_mode); + let selected = mode_list + .iter() + .position(|x| *x == self.global_state.settings.graphics.aa_mode); if let Some(clicked) = DropDownList::new(&mode_label_list, selected) .w_h(400.0, 22.0) diff --git a/voxygen/src/mesh/terrain.rs b/voxygen/src/mesh/terrain.rs index 5154c20617..75439e1f0a 100644 --- a/voxygen/src/mesh/terrain.rs +++ b/voxygen/src/mesh/terrain.rs @@ -238,11 +238,23 @@ impl + ReadVol + Debug> Meshable 1.0 { match body { Body::Humanoid(_) => { - self.character_states.get_mut(&entity).map(|state| state.visible = false); + self.character_states + .get_mut(&entity) + .map(|state| state.visible = false); } Body::QuadrupedSmall(_) => { - self.quadruped_small_states.get_mut(&entity).map(|state| state.visible = false); + self.quadruped_small_states + .get_mut(&entity) + .map(|state| state.visible = false); } Body::QuadrupedMedium(_) => { - self.quadruped_medium_states.get_mut(&entity).map(|state| state.visible = false); + self.quadruped_medium_states + .get_mut(&entity) + .map(|state| state.visible = false); } Body::BirdMedium(_) => { - self.bird_medium_states.get_mut(&entity).map(|state| state.visible = false); + self.bird_medium_states + .get_mut(&entity) + .map(|state| state.visible = false); } Body::FishMedium(_) => { - self.fish_medium_states.get_mut(&entity).map(|state| state.visible = false); + self.fish_medium_states + .get_mut(&entity) + .map(|state| state.visible = false); } Body::Dragon(_) => { - self.dragon_states.get_mut(&entity).map(|state| state.visible = false); + self.dragon_states + .get_mut(&entity) + .map(|state| state.visible = false); } Body::BirdSmall(_) => { - self.bird_small_states.get_mut(&entity).map(|state| state.visible = false); + self.bird_small_states + .get_mut(&entity) + .map(|state| state.visible = false); } Body::FishSmall(_) => { - self.fish_small_states.get_mut(&entity).map(|state| state.visible = false); + self.fish_small_states + .get_mut(&entity) + .map(|state| state.visible = false); } Body::BipedLarge(_) => { - self.biped_large_states.get_mut(&entity).map(|state| state.visible = false); + self.biped_large_states + .get_mut(&entity) + .map(|state| state.visible = false); } Body::Object(_) => { - self.object_states.get_mut(&entity).map(|state| state.visible = false); + self.object_states + .get_mut(&entity) + .map(|state| state.visible = false); } } continue; @@ -172,73 +192,104 @@ impl FigureMgr { // Don't process figures outside the frustum spectrum let frustum = camera.frustum(client); - let (in_frustum, lpindex) = BoundingSphere::new(pos.0.into_array(), scale.unwrap_or(&Scale(1.0)).0 * 2.0).coherent_test_against_frustum( - &frustum, - match body { - Body::Humanoid(_) => { - self.character_states.get(&entity).map(|state| state.lpindex) - } - Body::QuadrupedSmall(_) => { - self.quadruped_small_states.get(&entity).map(|state| state.lpindex) - } - Body::QuadrupedMedium(_) => { - self.quadruped_medium_states.get(&entity).map(|state| state.lpindex) - } - Body::BirdMedium(_) => { - self.bird_medium_states.get(&entity).map(|state| state.lpindex) - } - Body::FishMedium(_) => { - self.fish_medium_states.get(&entity).map(|state| state.lpindex) - } - Body::Dragon(_) => { - self.dragon_states.get(&entity).map(|state| state.lpindex) - } - Body::BirdSmall(_) => { - self.bird_small_states.get(&entity).map(|state| state.lpindex) - } - Body::FishSmall(_) => { - self.fish_small_states.get(&entity).map(|state| state.lpindex) - } - Body::BipedLarge(_) => { - self.biped_large_states.get(&entity).map(|state| state.lpindex) - } - Body::Object(_) => { - self.object_states.get(&entity).map(|state| state.lpindex) - } - }.unwrap_or(0), - ); + let (in_frustum, lpindex) = + BoundingSphere::new(pos.0.into_array(), scale.unwrap_or(&Scale(1.0)).0 * 2.0) + .coherent_test_against_frustum( + &frustum, + match body { + Body::Humanoid(_) => self + .character_states + .get(&entity) + .map(|state| state.lpindex), + Body::QuadrupedSmall(_) => self + .quadruped_small_states + .get(&entity) + .map(|state| state.lpindex), + Body::QuadrupedMedium(_) => self + .quadruped_medium_states + .get(&entity) + .map(|state| state.lpindex), + Body::BirdMedium(_) => self + .bird_medium_states + .get(&entity) + .map(|state| state.lpindex), + Body::FishMedium(_) => self + .fish_medium_states + .get(&entity) + .map(|state| state.lpindex), + Body::Dragon(_) => { + self.dragon_states.get(&entity).map(|state| state.lpindex) + } + Body::BirdSmall(_) => self + .bird_small_states + .get(&entity) + .map(|state| state.lpindex), + Body::FishSmall(_) => self + .fish_small_states + .get(&entity) + .map(|state| state.lpindex), + Body::BipedLarge(_) => self + .biped_large_states + .get(&entity) + .map(|state| state.lpindex), + Body::Object(_) => { + self.object_states.get(&entity).map(|state| state.lpindex) + } + } + .unwrap_or(0), + ); if !in_frustum { match body { Body::Humanoid(_) => { - self.character_states.get_mut(&entity).map(|state| state.visible = false); + self.character_states + .get_mut(&entity) + .map(|state| state.visible = false); } Body::QuadrupedSmall(_) => { - self.quadruped_small_states.get_mut(&entity).map(|state| state.visible = false); + self.quadruped_small_states + .get_mut(&entity) + .map(|state| state.visible = false); } Body::QuadrupedMedium(_) => { - self.quadruped_medium_states.get_mut(&entity).map(|state| state.visible = false); + self.quadruped_medium_states + .get_mut(&entity) + .map(|state| state.visible = false); } Body::BirdMedium(_) => { - self.bird_medium_states.get_mut(&entity).map(|state| state.visible = false); + self.bird_medium_states + .get_mut(&entity) + .map(|state| state.visible = false); } Body::FishMedium(_) => { - self.fish_medium_states.get_mut(&entity).map(|state| state.visible = false); + self.fish_medium_states + .get_mut(&entity) + .map(|state| state.visible = false); } Body::Dragon(_) => { - self.dragon_states.get_mut(&entity).map(|state| state.visible = false); + self.dragon_states + .get_mut(&entity) + .map(|state| state.visible = false); } Body::BirdSmall(_) => { - self.bird_small_states.get_mut(&entity).map(|state| state.visible = false); + self.bird_small_states + .get_mut(&entity) + .map(|state| state.visible = false); } Body::FishSmall(_) => { - self.fish_small_states.get_mut(&entity).map(|state| state.visible = false); + self.fish_small_states + .get_mut(&entity) + .map(|state| state.visible = false); } Body::BipedLarge(_) => { - self.biped_large_states.get_mut(&entity).map(|state| state.visible = false); + self.biped_large_states + .get_mut(&entity) + .map(|state| state.visible = false); } Body::Object(_) => { - self.object_states.get_mut(&entity).map(|state| state.visible = false); + self.object_states + .get_mut(&entity) + .map(|state| state.visible = false); } } continue; @@ -1036,29 +1087,60 @@ impl FigureMgr { pub fn figure_count(&self) -> usize { self.character_states.len() - + self.quadruped_small_states.len() - + self.character_states.len() - + self.quadruped_medium_states.len() - + self.bird_medium_states.len() - + self.fish_medium_states.len() - + self.dragon_states.len() - + self.bird_small_states.len() - + self.fish_small_states.len() - + self.biped_large_states.len() - + self.object_states.len() + + self.quadruped_small_states.len() + + self.character_states.len() + + self.quadruped_medium_states.len() + + self.bird_medium_states.len() + + self.fish_medium_states.len() + + self.dragon_states.len() + + self.bird_small_states.len() + + self.fish_small_states.len() + + self.biped_large_states.len() + + self.object_states.len() } pub fn figure_count_visible(&self) -> usize { - self.character_states.iter().filter(|(_, c)| c.visible).count() - + self.quadruped_small_states.iter().filter(|(_, c)| c.visible).count() - + self.quadruped_medium_states.iter().filter(|(_, c)| c.visible).count() - + self.bird_medium_states.iter().filter(|(_, c)| c.visible).count() - + self.fish_medium_states.iter().filter(|(_, c)| c.visible).count() - + self.dragon_states.iter().filter(|(_, c)| c.visible).count() - + self.bird_small_states.iter().filter(|(_, c)| c.visible).count() - + self.fish_small_states.iter().filter(|(_, c)| c.visible).count() - + self.biped_large_states.iter().filter(|(_, c)| c.visible).count() - + self.object_states.iter().filter(|(_, c)| c.visible).count() + self.character_states + .iter() + .filter(|(_, c)| c.visible) + .count() + + self + .quadruped_small_states + .iter() + .filter(|(_, c)| c.visible) + .count() + + self + .quadruped_medium_states + .iter() + .filter(|(_, c)| c.visible) + .count() + + self + .bird_medium_states + .iter() + .filter(|(_, c)| c.visible) + .count() + + self + .fish_medium_states + .iter() + .filter(|(_, c)| c.visible) + .count() + + self.dragon_states.iter().filter(|(_, c)| c.visible).count() + + self + .bird_small_states + .iter() + .filter(|(_, c)| c.visible) + .count() + + self + .fish_small_states + .iter() + .filter(|(_, c)| c.visible) + .count() + + self + .biped_large_states + .iter() + .filter(|(_, c)| c.visible) + .count() + + self.object_states.iter().filter(|(_, c)| c.visible).count() } } diff --git a/voxygen/src/scene/terrain.rs b/voxygen/src/scene/terrain.rs index 3f84b40318..17ec303719 100644 --- a/voxygen/src/scene/terrain.rs +++ b/voxygen/src/scene/terrain.rs @@ -16,9 +16,9 @@ use common::{ }; use crossbeam::channel; use dot_vox::DotVoxData; -use treeculler::{Frustum, AABB, BVol}; use hashbrown::{hash_map::Entry, HashMap}; use std::{f32, fmt::Debug, i32, marker::PhantomData, time::Duration}; +use treeculler::{BVol, Frustum, AABB}; use vek::*; struct TerrainChunkData { @@ -1062,7 +1062,8 @@ impl Terrain { chunk.z_bounds.1, ]; - let (in_frustum, last_plane_index) = AABB::new(chunk_min, chunk_max).coherent_test_against_frustum(&frustum, chunk.frustum_last_plane_index); + let (in_frustum, last_plane_index) = AABB::new(chunk_min, chunk_max) + .coherent_test_against_frustum(&frustum, chunk.frustum_last_plane_index); chunk.frustum_last_plane_index = last_plane_index; chunk.visible = in_frustum; @@ -1071,8 +1072,8 @@ impl Terrain { pub fn chunk_count(&self) -> usize { self.chunks.len() - } - + } + pub fn visible_chunk_count(&self) -> usize { self.chunks.iter().filter(|(_, c)| c.visible).count() }