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_id(self.fonts.cyri)
|
||||||
.font_size(14)
|
.font_size(14)
|
||||||
.set(self.ids.entity_count, ui_widgets);
|
.set(self.ids.entity_count, ui_widgets);
|
||||||
|
|
||||||
// Number of chunks
|
// Number of chunks
|
||||||
Text::new(&format!(
|
Text::new(&format!(
|
||||||
"Chunks: {} ({} visible)",
|
"Chunks: {} ({} visible)",
|
||||||
|
@ -1351,7 +1351,9 @@ impl<'a> Widget for SettingsWindow<'a> {
|
|||||||
];
|
];
|
||||||
|
|
||||||
// Get which AA mode is currently active
|
// 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)
|
if let Some(clicked) = DropDownList::new(&mode_label_list, selected)
|
||||||
.w_h(400.0, 22.0)
|
.w_h(400.0, 22.0)
|
||||||
|
@ -238,11 +238,23 @@ impl<V: RectRasterableVol<Vox = Block> + ReadVol + Debug> Meshable<TerrainPipeli
|
|||||||
|pos, norm, col, ao, light| {
|
|pos, norm, col, ao, light| {
|
||||||
let light = (light.min(ao) * 255.0) as u32;
|
let light = (light.min(ao) * 255.0) as u32;
|
||||||
let norm = if norm.x != 0.0 {
|
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 {
|
} else if norm.y != 0.0 {
|
||||||
if norm.y < 0.0 { 2 } else { 3 }
|
if norm.y < 0.0 {
|
||||||
|
2
|
||||||
|
} else {
|
||||||
|
3
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if norm.z < 0.0 { 4 } else { 5 }
|
if norm.z < 0.0 {
|
||||||
|
4
|
||||||
|
} else {
|
||||||
|
5
|
||||||
|
}
|
||||||
};
|
};
|
||||||
TerrainVertex::new(norm, light, pos, col)
|
TerrainVertex::new(norm, light, pos, col)
|
||||||
},
|
},
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use client::Client;
|
use client::Client;
|
||||||
use common::vol::{ReadVol, Vox};
|
use common::vol::{ReadVol, Vox};
|
||||||
use treeculler::Frustum;
|
|
||||||
use std::f32::consts::PI;
|
use std::f32::consts::PI;
|
||||||
|
use treeculler::Frustum;
|
||||||
use vek::*;
|
use vek::*;
|
||||||
|
|
||||||
const NEAR_PLANE: f32 = 0.5;
|
const NEAR_PLANE: f32 = 0.5;
|
||||||
|
@ -27,7 +27,7 @@ use common::{
|
|||||||
use hashbrown::HashMap;
|
use hashbrown::HashMap;
|
||||||
use log::trace;
|
use log::trace;
|
||||||
use specs::{Entity as EcsEntity, Join, WorldExt};
|
use specs::{Entity as EcsEntity, Join, WorldExt};
|
||||||
use treeculler::{BoundingSphere, BVol};
|
use treeculler::{BVol, BoundingSphere};
|
||||||
use vek::*;
|
use vek::*;
|
||||||
|
|
||||||
const DAMAGE_FADE_COEFFICIENT: f64 = 5.0;
|
const DAMAGE_FADE_COEFFICIENT: f64 = 5.0;
|
||||||
@ -136,34 +136,54 @@ impl FigureMgr {
|
|||||||
} else if vd_frac > 1.0 {
|
} else if vd_frac > 1.0 {
|
||||||
match body {
|
match body {
|
||||||
Body::Humanoid(_) => {
|
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(_) => {
|
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(_) => {
|
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(_) => {
|
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(_) => {
|
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(_) => {
|
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(_) => {
|
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(_) => {
|
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(_) => {
|
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(_) => {
|
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;
|
continue;
|
||||||
@ -172,73 +192,104 @@ impl FigureMgr {
|
|||||||
// Don't process figures outside the frustum spectrum
|
// Don't process figures outside the frustum spectrum
|
||||||
let frustum = camera.frustum(client);
|
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(
|
let (in_frustum, lpindex) =
|
||||||
&frustum,
|
BoundingSphere::new(pos.0.into_array(), scale.unwrap_or(&Scale(1.0)).0 * 2.0)
|
||||||
match body {
|
.coherent_test_against_frustum(
|
||||||
Body::Humanoid(_) => {
|
&frustum,
|
||||||
self.character_states.get(&entity).map(|state| state.lpindex)
|
match body {
|
||||||
}
|
Body::Humanoid(_) => self
|
||||||
Body::QuadrupedSmall(_) => {
|
.character_states
|
||||||
self.quadruped_small_states.get(&entity).map(|state| state.lpindex)
|
.get(&entity)
|
||||||
}
|
.map(|state| state.lpindex),
|
||||||
Body::QuadrupedMedium(_) => {
|
Body::QuadrupedSmall(_) => self
|
||||||
self.quadruped_medium_states.get(&entity).map(|state| state.lpindex)
|
.quadruped_small_states
|
||||||
}
|
.get(&entity)
|
||||||
Body::BirdMedium(_) => {
|
.map(|state| state.lpindex),
|
||||||
self.bird_medium_states.get(&entity).map(|state| state.lpindex)
|
Body::QuadrupedMedium(_) => self
|
||||||
}
|
.quadruped_medium_states
|
||||||
Body::FishMedium(_) => {
|
.get(&entity)
|
||||||
self.fish_medium_states.get(&entity).map(|state| state.lpindex)
|
.map(|state| state.lpindex),
|
||||||
}
|
Body::BirdMedium(_) => self
|
||||||
Body::Dragon(_) => {
|
.bird_medium_states
|
||||||
self.dragon_states.get(&entity).map(|state| state.lpindex)
|
.get(&entity)
|
||||||
}
|
.map(|state| state.lpindex),
|
||||||
Body::BirdSmall(_) => {
|
Body::FishMedium(_) => self
|
||||||
self.bird_small_states.get(&entity).map(|state| state.lpindex)
|
.fish_medium_states
|
||||||
}
|
.get(&entity)
|
||||||
Body::FishSmall(_) => {
|
.map(|state| state.lpindex),
|
||||||
self.fish_small_states.get(&entity).map(|state| state.lpindex)
|
Body::Dragon(_) => {
|
||||||
}
|
self.dragon_states.get(&entity).map(|state| state.lpindex)
|
||||||
Body::BipedLarge(_) => {
|
}
|
||||||
self.biped_large_states.get(&entity).map(|state| state.lpindex)
|
Body::BirdSmall(_) => self
|
||||||
}
|
.bird_small_states
|
||||||
Body::Object(_) => {
|
.get(&entity)
|
||||||
self.object_states.get(&entity).map(|state| state.lpindex)
|
.map(|state| state.lpindex),
|
||||||
}
|
Body::FishSmall(_) => self
|
||||||
}.unwrap_or(0),
|
.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 {
|
if !in_frustum {
|
||||||
match body {
|
match body {
|
||||||
Body::Humanoid(_) => {
|
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(_) => {
|
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(_) => {
|
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(_) => {
|
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(_) => {
|
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(_) => {
|
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(_) => {
|
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(_) => {
|
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(_) => {
|
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(_) => {
|
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;
|
continue;
|
||||||
@ -1036,29 +1087,60 @@ impl FigureMgr {
|
|||||||
|
|
||||||
pub fn figure_count(&self) -> usize {
|
pub fn figure_count(&self) -> usize {
|
||||||
self.character_states.len()
|
self.character_states.len()
|
||||||
+ self.quadruped_small_states.len()
|
+ self.quadruped_small_states.len()
|
||||||
+ self.character_states.len()
|
+ self.character_states.len()
|
||||||
+ self.quadruped_medium_states.len()
|
+ self.quadruped_medium_states.len()
|
||||||
+ self.bird_medium_states.len()
|
+ self.bird_medium_states.len()
|
||||||
+ self.fish_medium_states.len()
|
+ self.fish_medium_states.len()
|
||||||
+ self.dragon_states.len()
|
+ self.dragon_states.len()
|
||||||
+ self.bird_small_states.len()
|
+ self.bird_small_states.len()
|
||||||
+ self.fish_small_states.len()
|
+ self.fish_small_states.len()
|
||||||
+ self.biped_large_states.len()
|
+ self.biped_large_states.len()
|
||||||
+ self.object_states.len()
|
+ self.object_states.len()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn figure_count_visible(&self) -> usize {
|
pub fn figure_count_visible(&self) -> usize {
|
||||||
self.character_states.iter().filter(|(_, c)| c.visible).count()
|
self.character_states
|
||||||
+ self.quadruped_small_states.iter().filter(|(_, c)| c.visible).count()
|
.iter()
|
||||||
+ self.quadruped_medium_states.iter().filter(|(_, c)| c.visible).count()
|
.filter(|(_, c)| c.visible)
|
||||||
+ self.bird_medium_states.iter().filter(|(_, c)| c.visible).count()
|
.count()
|
||||||
+ self.fish_medium_states.iter().filter(|(_, c)| c.visible).count()
|
+ self
|
||||||
+ self.dragon_states.iter().filter(|(_, c)| c.visible).count()
|
.quadruped_small_states
|
||||||
+ self.bird_small_states.iter().filter(|(_, c)| c.visible).count()
|
.iter()
|
||||||
+ self.fish_small_states.iter().filter(|(_, c)| c.visible).count()
|
.filter(|(_, c)| c.visible)
|
||||||
+ self.biped_large_states.iter().filter(|(_, c)| c.visible).count()
|
.count()
|
||||||
+ self.object_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 crossbeam::channel;
|
||||||
use dot_vox::DotVoxData;
|
use dot_vox::DotVoxData;
|
||||||
use treeculler::{Frustum, AABB, BVol};
|
|
||||||
use hashbrown::{hash_map::Entry, HashMap};
|
use hashbrown::{hash_map::Entry, HashMap};
|
||||||
use std::{f32, fmt::Debug, i32, marker::PhantomData, time::Duration};
|
use std::{f32, fmt::Debug, i32, marker::PhantomData, time::Duration};
|
||||||
|
use treeculler::{BVol, Frustum, AABB};
|
||||||
use vek::*;
|
use vek::*;
|
||||||
|
|
||||||
struct TerrainChunkData {
|
struct TerrainChunkData {
|
||||||
@ -1062,7 +1062,8 @@ impl<V: RectRasterableVol> Terrain<V> {
|
|||||||
chunk.z_bounds.1,
|
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.frustum_last_plane_index = last_plane_index;
|
||||||
chunk.visible = in_frustum;
|
chunk.visible = in_frustum;
|
||||||
@ -1071,8 +1072,8 @@ impl<V: RectRasterableVol> Terrain<V> {
|
|||||||
|
|
||||||
pub fn chunk_count(&self) -> usize {
|
pub fn chunk_count(&self) -> usize {
|
||||||
self.chunks.len()
|
self.chunks.len()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn visible_chunk_count(&self) -> usize {
|
pub fn visible_chunk_count(&self) -> usize {
|
||||||
self.chunks.iter().filter(|(_, c)| c.visible).count()
|
self.chunks.iter().filter(|(_, c)| c.visible).count()
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user