mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Cargo fmt
This commit is contained in:
parent
71db9d6350
commit
4a0a2d5229
@ -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)",
|
||||
|
@ -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)
|
||||
|
@ -238,11 +238,23 @@ impl<V: RectRasterableVol<Vox = Block> + ReadVol + Debug> Meshable<TerrainPipeli
|
||||
|pos, norm, col, ao, light| {
|
||||
let light = (light.min(ao) * 255.0) as u32;
|
||||
let norm = if norm.x != 0.0 {
|
||||
if norm.x < 0.0 { 0 } else { 1 }
|
||||
if norm.x < 0.0 {
|
||||
0
|
||||
} else {
|
||||
1
|
||||
}
|
||||
} else if norm.y != 0.0 {
|
||||
if norm.y < 0.0 { 2 } else { 3 }
|
||||
if norm.y < 0.0 {
|
||||
2
|
||||
} else {
|
||||
3
|
||||
}
|
||||
} else {
|
||||
if norm.z < 0.0 { 4 } else { 5 }
|
||||
if norm.z < 0.0 {
|
||||
4
|
||||
} else {
|
||||
5
|
||||
}
|
||||
};
|
||||
TerrainVertex::new(norm, light, pos, col)
|
||||
},
|
||||
|
@ -1,7 +1,7 @@
|
||||
use client::Client;
|
||||
use common::vol::{ReadVol, Vox};
|
||||
use treeculler::Frustum;
|
||||
use std::f32::consts::PI;
|
||||
use treeculler::Frustum;
|
||||
use vek::*;
|
||||
|
||||
const NEAR_PLANE: f32 = 0.5;
|
||||
|
@ -27,7 +27,7 @@ use common::{
|
||||
use hashbrown::HashMap;
|
||||
use log::trace;
|
||||
use specs::{Entity as EcsEntity, Join, WorldExt};
|
||||
use treeculler::{BoundingSphere, BVol};
|
||||
use treeculler::{BVol, BoundingSphere};
|
||||
use vek::*;
|
||||
|
||||
const DAMAGE_FADE_COEFFICIENT: f64 = 5.0;
|
||||
@ -136,34 +136,54 @@ impl FigureMgr {
|
||||
} else if vd_frac > 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()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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<V: RectRasterableVol> Terrain<V> {
|
||||
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<V: RectRasterableVol> Terrain<V> {
|
||||
|
||||
pub fn chunk_count(&self) -> usize {
|
||||
self.chunks.len()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
pub fn visible_chunk_count(&self) -> usize {
|
||||
self.chunks.iter().filter(|(_, c)| c.visible).count()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user