mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Finished switch to hashbrown.
This commit is contained in:
parent
ed4909670d
commit
b4a46f3e6e
5
Cargo.lock
generated
5
Cargo.lock
generated
@ -1283,6 +1283,9 @@ dependencies = [
|
|||||||
name = "hashbrown"
|
name = "hashbrown"
|
||||||
version = "0.5.0"
|
version = "0.5.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
dependencies = [
|
||||||
|
"serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "heaptrack"
|
name = "heaptrack"
|
||||||
@ -2912,7 +2915,7 @@ dependencies = [
|
|||||||
"bincode 1.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
"bincode 1.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"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)",
|
||||||
"find_folder 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"find_folder 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"fxhash 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"hashbrown 0.5.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)",
|
||||||
"log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
"log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
@ -12,4 +12,4 @@ num_cpus = "1.10.1"
|
|||||||
log = "0.4.8"
|
log = "0.4.8"
|
||||||
specs = "0.14.2"
|
specs = "0.14.2"
|
||||||
vek = "0.9.8"
|
vek = "0.9.8"
|
||||||
hashbrown = "0.5.0"
|
hashbrown = { version = "0.5.0", features = ["serde", "nightly"] }
|
||||||
|
@ -23,5 +23,5 @@ rand = "0.7.0"
|
|||||||
rayon = "1.1.0"
|
rayon = "1.1.0"
|
||||||
lazy_static = "1.3.0"
|
lazy_static = "1.3.0"
|
||||||
lz4-compress = "0.1.1"
|
lz4-compress = "0.1.1"
|
||||||
fxhash = "0.2.1"
|
hashbrown = { version = "0.5.0", features = ["serde", "nightly"] }
|
||||||
find_folder = "0.3.0"
|
find_folder = "0.3.0"
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
//! Load assets (images or voxel data) from files
|
//! Load assets (images or voxel data) from files
|
||||||
|
|
||||||
use dot_vox::DotVoxData;
|
use dot_vox::DotVoxData;
|
||||||
|
use hashbrown::HashMap;
|
||||||
use image::DynamicImage;
|
use image::DynamicImage;
|
||||||
use lazy_static::lazy_static;
|
use lazy_static::lazy_static;
|
||||||
use serde_json::Value;
|
use serde_json::Value;
|
||||||
use std::{
|
use std::{
|
||||||
any::Any,
|
any::Any,
|
||||||
collections::HashMap,
|
|
||||||
env,
|
env,
|
||||||
fs::{self, read_link, File, ReadDir},
|
fs::{self, read_link, File, ReadDir},
|
||||||
io::{BufReader, Read},
|
io::{BufReader, Read},
|
||||||
|
@ -4,7 +4,7 @@ use crate::{
|
|||||||
terrain::{Block, TerrainChunk},
|
terrain::{Block, TerrainChunk},
|
||||||
ChatType,
|
ChatType,
|
||||||
};
|
};
|
||||||
use fxhash::FxHashMap;
|
use hashbrown::HashMap;
|
||||||
use vek::*;
|
use vek::*;
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
|
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
|
||||||
@ -60,7 +60,7 @@ pub enum ServerMsg {
|
|||||||
key: Vec2<i32>,
|
key: Vec2<i32>,
|
||||||
chunk: Box<TerrainChunk>,
|
chunk: Box<TerrainChunk>,
|
||||||
},
|
},
|
||||||
TerrainBlockUpdates(FxHashMap<Vec3<i32>, Block>),
|
TerrainBlockUpdates(HashMap<Vec3<i32>, Block>),
|
||||||
Error(ServerError),
|
Error(ServerError),
|
||||||
Disconnect,
|
Disconnect,
|
||||||
Shutdown,
|
Shutdown,
|
||||||
|
@ -9,7 +9,7 @@ use crate::{
|
|||||||
terrain::{Block, TerrainChunk, TerrainMap},
|
terrain::{Block, TerrainChunk, TerrainMap},
|
||||||
vol::WriteVol,
|
vol::WriteVol,
|
||||||
};
|
};
|
||||||
use fxhash::{FxHashMap, FxHashSet};
|
use hashbrown::{HashMap, HashSet};
|
||||||
use rayon::{ThreadPool, ThreadPoolBuilder};
|
use rayon::{ThreadPool, ThreadPoolBuilder};
|
||||||
use serde_derive::{Deserialize, Serialize};
|
use serde_derive::{Deserialize, Serialize};
|
||||||
use specs::{
|
use specs::{
|
||||||
@ -45,7 +45,7 @@ const MAX_DELTA_TIME: f32 = 1.0;
|
|||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct BlockChange {
|
pub struct BlockChange {
|
||||||
blocks: FxHashMap<Vec3<i32>, Block>,
|
blocks: HashMap<Vec3<i32>, Block>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl BlockChange {
|
impl BlockChange {
|
||||||
@ -60,10 +60,10 @@ impl BlockChange {
|
|||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct TerrainChanges {
|
pub struct TerrainChanges {
|
||||||
pub new_chunks: FxHashSet<Vec2<i32>>,
|
pub new_chunks: HashSet<Vec2<i32>>,
|
||||||
pub modified_chunks: FxHashSet<Vec2<i32>>,
|
pub modified_chunks: HashSet<Vec2<i32>>,
|
||||||
pub removed_chunks: FxHashSet<Vec2<i32>>,
|
pub removed_chunks: HashSet<Vec2<i32>>,
|
||||||
pub modified_blocks: FxHashMap<Vec3<i32>, Block>,
|
pub modified_blocks: HashMap<Vec3<i32>, Block>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TerrainChanges {
|
impl TerrainChanges {
|
||||||
|
@ -3,7 +3,7 @@ use crate::{
|
|||||||
vol::{BaseVol, ReadVol, VolSize, WriteVol},
|
vol::{BaseVol, ReadVol, VolSize, WriteVol},
|
||||||
volumes::chunk::{Chunk, ChunkErr},
|
volumes::chunk::{Chunk, ChunkErr},
|
||||||
};
|
};
|
||||||
use fxhash::FxHashMap;
|
use hashbrown::HashMap;
|
||||||
use serde_derive::{Deserialize, Serialize};
|
use serde_derive::{Deserialize, Serialize};
|
||||||
use std::ops::Add;
|
use std::ops::Add;
|
||||||
use vek::*;
|
use vek::*;
|
||||||
@ -179,7 +179,7 @@ impl WriteVol for Chonk {
|
|||||||
// Can't fail
|
// Can't fail
|
||||||
SubChunk::Homogeneous(cblock) if block == *cblock => Ok(()),
|
SubChunk::Homogeneous(cblock) if block == *cblock => Ok(()),
|
||||||
SubChunk::Homogeneous(cblock) => {
|
SubChunk::Homogeneous(cblock) => {
|
||||||
let mut map = FxHashMap::default();
|
let mut map = HashMap::default();
|
||||||
map.insert(rpos.map(|e| e as u8), block);
|
map.insert(rpos.map(|e| e as u8), block);
|
||||||
|
|
||||||
self.sub_chunks[sub_chunk_idx] = SubChunk::Hash(*cblock, map);
|
self.sub_chunks[sub_chunk_idx] = SubChunk::Hash(*cblock, map);
|
||||||
@ -238,7 +238,7 @@ impl VolSize for SubChunkSize {
|
|||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
pub enum SubChunk {
|
pub enum SubChunk {
|
||||||
Homogeneous(Block),
|
Homogeneous(Block),
|
||||||
Hash(Block, FxHashMap<Vec3<u8>, Block>),
|
Hash(Block, HashMap<Vec3<u8>, Block>),
|
||||||
Heterogeneous(Chunk<Block, SubChunkSize, ()>),
|
Heterogeneous(Chunk<Block, SubChunkSize, ()>),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,8 +2,8 @@ use crate::{
|
|||||||
vol::{BaseVol, ReadVol, SampleVol, VolSize, WriteVol},
|
vol::{BaseVol, ReadVol, SampleVol, VolSize, WriteVol},
|
||||||
volumes::dyna::DynaErr,
|
volumes::dyna::DynaErr,
|
||||||
};
|
};
|
||||||
use fxhash::FxHashMap;
|
use hashbrown::{hash_map, HashMap};
|
||||||
use std::{collections::hash_map, fmt::Debug, marker::PhantomData, sync::Arc};
|
use std::{fmt::Debug, marker::PhantomData, sync::Arc};
|
||||||
use vek::*;
|
use vek::*;
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
@ -19,7 +19,7 @@ pub enum VolMap2dErr<V: BaseVol> {
|
|||||||
// M = Chunk metadata
|
// M = Chunk metadata
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct VolMap2d<V: BaseVol, S: VolSize> {
|
pub struct VolMap2d<V: BaseVol, S: VolSize> {
|
||||||
chunks: FxHashMap<Vec2<i32>, Arc<V>>,
|
chunks: HashMap<Vec2<i32>, Arc<V>>,
|
||||||
phantom: PhantomData<S>,
|
phantom: PhantomData<S>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -122,7 +122,7 @@ impl<V: BaseVol, S: VolSize> VolMap2d<V, S> {
|
|||||||
.reduce_and()
|
.reduce_and()
|
||||||
{
|
{
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
chunks: FxHashMap::default(),
|
chunks: HashMap::default(),
|
||||||
phantom: PhantomData,
|
phantom: PhantomData,
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
@ -177,7 +177,7 @@ impl<V: BaseVol, S: VolSize> VolMap2d<V, S> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub struct ChunkIter<'a, V: BaseVol> {
|
pub struct ChunkIter<'a, V: BaseVol> {
|
||||||
iter: std::collections::hash_map::Iter<'a, Vec2<i32>, Arc<V>>,
|
iter: hash_map::Iter<'a, Vec2<i32>, Arc<V>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, V: BaseVol> Iterator for ChunkIter<'a, V> {
|
impl<'a, V: BaseVol> Iterator for ChunkIter<'a, V> {
|
||||||
|
@ -2,7 +2,8 @@ use crate::{
|
|||||||
vol::{BaseVol, ReadVol, SampleVol, VolSize, WriteVol},
|
vol::{BaseVol, ReadVol, SampleVol, VolSize, WriteVol},
|
||||||
volumes::dyna::DynaErr,
|
volumes::dyna::DynaErr,
|
||||||
};
|
};
|
||||||
use std::{collections::HashMap, fmt::Debug, marker::PhantomData, sync::Arc};
|
use hashbrown::{hash_map, HashMap};
|
||||||
|
use std::{fmt::Debug, marker::PhantomData, sync::Arc};
|
||||||
use vek::*;
|
use vek::*;
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
@ -161,7 +162,7 @@ impl<V: BaseVol, S: VolSize> VolMap3d<V, S> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub struct ChunkIter<'a, V: BaseVol> {
|
pub struct ChunkIter<'a, V: BaseVol> {
|
||||||
iter: std::collections::hash_map::Iter<'a, Vec3<i32>, Arc<V>>,
|
iter: hash_map::Iter<'a, Vec3<i32>, Arc<V>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, V: BaseVol> Iterator for ChunkIter<'a, V> {
|
impl<'a, V: BaseVol> Iterator for ChunkIter<'a, V> {
|
||||||
|
@ -19,4 +19,4 @@ serde = "1.0.98"
|
|||||||
serde_derive = "1.0.98"
|
serde_derive = "1.0.98"
|
||||||
rand = "0.7.0"
|
rand = "0.7.0"
|
||||||
chrono = "0.4.7"
|
chrono = "0.4.7"
|
||||||
hashbrown = "0.5.0"
|
hashbrown = { version = "0.5.0", features = ["serde", "nightly"] }
|
||||||
|
@ -57,4 +57,4 @@ 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"
|
||||||
heaptrack = "0.3.0"
|
heaptrack = "0.3.0"
|
||||||
hashbrown = "0.5.0"
|
hashbrown = { version = "0.5.0", features = ["serde", "nightly"] }
|
||||||
|
@ -8,7 +8,7 @@ edition = "2018"
|
|||||||
common = { package = "veloren-common", path = "../common" }
|
common = { package = "veloren-common", path = "../common" }
|
||||||
vek = "0.9.8"
|
vek = "0.9.8"
|
||||||
noise = "0.5.1"
|
noise = "0.5.1"
|
||||||
hashbrown = "0.5.0"
|
hashbrown = { version = "0.5.0", features = ["serde", "nightly"] }
|
||||||
lazy_static = "1.3.0"
|
lazy_static = "1.3.0"
|
||||||
rand = "0.7.0"
|
rand = "0.7.0"
|
||||||
rand_chacha = "0.2.1"
|
rand_chacha = "0.2.1"
|
||||||
|
Loading…
Reference in New Issue
Block a user