mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Use hashbrown in voxygen instead of a billion different shitty maps.
This commit is contained in:
parent
4f2d99f809
commit
0bbef0d851
3
Cargo.lock
generated
3
Cargo.lock
generated
@ -2973,15 +2973,14 @@ dependencies = [
|
|||||||
"dot_vox 4.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"dot_vox 4.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"euc 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"euc 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
"failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"frustum_query 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
"frustum_query 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"fxhash 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"gfx 0.18.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"gfx 0.18.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"gfx_device_gl 0.16.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"gfx_device_gl 0.16.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"gfx_window_glutin 0.31.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"gfx_window_glutin 0.31.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"glsl-include 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"glsl-include 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"glutin 0.21.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"glutin 0.21.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"guillotiere 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
"guillotiere 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"hashbrown 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"heaptrack 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"heaptrack 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"image 0.22.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"image 0.22.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
@ -46,7 +46,6 @@ serde = "1.0.98"
|
|||||||
serde_derive = "1.0.98"
|
serde_derive = "1.0.98"
|
||||||
ron = "0.5.1"
|
ron = "0.5.1"
|
||||||
guillotiere = "0.4.2"
|
guillotiere = "0.4.2"
|
||||||
fnv = "1.0.6"
|
|
||||||
simplelog = "0.6.0"
|
simplelog = "0.6.0"
|
||||||
msgbox = { git = "https://github.com/bekker/msgbox-rs.git" }
|
msgbox = { git = "https://github.com/bekker/msgbox-rs.git" }
|
||||||
directories = "2.0.2"
|
directories = "2.0.2"
|
||||||
@ -57,5 +56,5 @@ rand = "0.7.0"
|
|||||||
frustum_query = "0.1.2"
|
frustum_query = "0.1.2"
|
||||||
rodio = { git = "https://github.com/desttinghim/rodio.git", rev = "dd93f905c1afefaac03c496a666ecab27d3e391b" }
|
rodio = { git = "https://github.com/desttinghim/rodio.git", rev = "dd93f905c1afefaac03c496a666ecab27d3e391b" }
|
||||||
crossbeam = "0.7.2"
|
crossbeam = "0.7.2"
|
||||||
fxhash = "0.2.1"
|
|
||||||
heaptrack = "0.3.0"
|
heaptrack = "0.3.0"
|
||||||
|
hashbrown = "0.5.0"
|
||||||
|
@ -18,9 +18,10 @@ use common::{
|
|||||||
vol::VolSize,
|
vol::VolSize,
|
||||||
};
|
};
|
||||||
use dot_vox::DotVoxData;
|
use dot_vox::DotVoxData;
|
||||||
|
use hashbrown::HashMap;
|
||||||
use log::warn;
|
use log::warn;
|
||||||
use specs::{Entity as EcsEntity, Join};
|
use specs::{Entity as EcsEntity, Join};
|
||||||
use std::{collections::HashMap, f32};
|
use std::f32;
|
||||||
use vek::*;
|
use vek::*;
|
||||||
|
|
||||||
const DAMAGE_FADE_COEFFICIENT: f64 = 5.0;
|
const DAMAGE_FADE_COEFFICIENT: f64 = 5.0;
|
||||||
|
@ -9,7 +9,7 @@ use common::{
|
|||||||
volumes::vol_map_2d::VolMap2dErr,
|
volumes::vol_map_2d::VolMap2dErr,
|
||||||
};
|
};
|
||||||
use frustum_query::frustum::Frustum;
|
use frustum_query::frustum::Frustum;
|
||||||
use fxhash::FxHashMap;
|
use hashbrown::HashMap;
|
||||||
use std::{i32, ops::Mul, sync::mpsc, time::Duration};
|
use std::{i32, ops::Mul, sync::mpsc, time::Duration};
|
||||||
use vek::*;
|
use vek::*;
|
||||||
|
|
||||||
@ -52,13 +52,13 @@ fn mesh_worker(
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub struct Terrain {
|
pub struct Terrain {
|
||||||
chunks: FxHashMap<Vec2<i32>, TerrainChunk>,
|
chunks: HashMap<Vec2<i32>, TerrainChunk>,
|
||||||
|
|
||||||
// The mpsc sender and receiver used for talking to meshing worker threads.
|
// The mpsc sender and receiver used for talking to meshing worker threads.
|
||||||
// We keep the sender component for no reason other than to clone it and send it to new workers.
|
// We keep the sender component for no reason other than to clone it and send it to new workers.
|
||||||
mesh_send_tmp: mpsc::Sender<MeshWorkerResponse>,
|
mesh_send_tmp: mpsc::Sender<MeshWorkerResponse>,
|
||||||
mesh_recv: mpsc::Receiver<MeshWorkerResponse>,
|
mesh_recv: mpsc::Receiver<MeshWorkerResponse>,
|
||||||
mesh_todo: FxHashMap<Vec2<i32>, ChunkMeshState>,
|
mesh_todo: HashMap<Vec2<i32>, ChunkMeshState>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Terrain {
|
impl Terrain {
|
||||||
@ -68,10 +68,10 @@ impl Terrain {
|
|||||||
let (send, recv) = mpsc::channel();
|
let (send, recv) = mpsc::channel();
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
chunks: FxHashMap::default(),
|
chunks: HashMap::default(),
|
||||||
mesh_send_tmp: send,
|
mesh_send_tmp: send,
|
||||||
mesh_recv: recv,
|
mesh_recv: recv,
|
||||||
mesh_todo: FxHashMap::default(),
|
mesh_todo: HashMap::default(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use dot_vox::DotVoxData;
|
use dot_vox::DotVoxData;
|
||||||
use fnv::FnvHashMap;
|
|
||||||
use guillotiere::{size2, AllocId, Allocation, AtlasAllocator};
|
use guillotiere::{size2, AllocId, Allocation, AtlasAllocator};
|
||||||
|
use hashbrown::HashMap;
|
||||||
use image::{DynamicImage, RgbaImage};
|
use image::{DynamicImage, RgbaImage};
|
||||||
use log::{error, warn};
|
use log::{error, warn};
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
@ -28,28 +28,28 @@ pub struct CachedDetails {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub struct GraphicCache {
|
pub struct GraphicCache {
|
||||||
graphic_map: FnvHashMap<Id, Graphic>,
|
graphic_map: HashMap<Id, Graphic>,
|
||||||
next_id: u32,
|
next_id: u32,
|
||||||
|
|
||||||
atlas: AtlasAllocator,
|
atlas: AtlasAllocator,
|
||||||
cache_map: FnvHashMap<Parameters, CachedDetails>,
|
cache_map: HashMap<Parameters, CachedDetails>,
|
||||||
// The current frame
|
// The current frame
|
||||||
current_frame: u32,
|
current_frame: u32,
|
||||||
unused_entries_this_frame: Option<Vec<Option<(u32, Parameters)>>>,
|
unused_entries_this_frame: Option<Vec<Option<(u32, Parameters)>>>,
|
||||||
|
|
||||||
soft_cache: FnvHashMap<Parameters, RgbaImage>,
|
soft_cache: HashMap<Parameters, RgbaImage>,
|
||||||
transfer_ready: Vec<(Parameters, Aabr<u16>)>,
|
transfer_ready: Vec<(Parameters, Aabr<u16>)>,
|
||||||
}
|
}
|
||||||
impl GraphicCache {
|
impl GraphicCache {
|
||||||
pub fn new(size: Vec2<u16>) -> Self {
|
pub fn new(size: Vec2<u16>) -> Self {
|
||||||
Self {
|
Self {
|
||||||
graphic_map: FnvHashMap::default(),
|
graphic_map: HashMap::default(),
|
||||||
next_id: 0,
|
next_id: 0,
|
||||||
atlas: AtlasAllocator::new(size2(i32::from(size.x), i32::from(size.y))),
|
atlas: AtlasAllocator::new(size2(i32::from(size.x), i32::from(size.y))),
|
||||||
cache_map: FnvHashMap::default(),
|
cache_map: HashMap::default(),
|
||||||
current_frame: 0,
|
current_frame: 0,
|
||||||
unused_entries_this_frame: None,
|
unused_entries_this_frame: None,
|
||||||
soft_cache: FnvHashMap::default(),
|
soft_cache: HashMap::default(),
|
||||||
transfer_ready: Vec::new(),
|
transfer_ready: Vec::new(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,9 +3,9 @@ use crate::{
|
|||||||
settings::Settings,
|
settings::Settings,
|
||||||
ui, Error,
|
ui, Error,
|
||||||
};
|
};
|
||||||
|
use hashbrown::HashMap;
|
||||||
use log::{error, warn};
|
use log::{error, warn};
|
||||||
use serde_derive::{Deserialize, Serialize};
|
use serde_derive::{Deserialize, Serialize};
|
||||||
use std::collections::HashMap;
|
|
||||||
use vek::*;
|
use vek::*;
|
||||||
|
|
||||||
/// Represents a key that the game recognises after keyboard mapping.
|
/// Represents a key that the game recognises after keyboard mapping.
|
||||||
|
Loading…
Reference in New Issue
Block a user