dumb iterator implemented ith faster hashmap
This commit is contained in:
parent
7879e57275
commit
31d56ded3f
3 changed files with 13 additions and 4 deletions
7
Cargo.lock
generated
7
Cargo.lock
generated
|
@ -954,6 +954,12 @@ version = "0.8.3"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "adad44e29e4c806119491a7f06f03de4d1af22c3a680dd47f1e6e179439d1f56"
|
||||
|
||||
[[package]]
|
||||
name = "rustc-hash"
|
||||
version = "2.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "583034fd73374156e66797ed8e5b0d5690409c9226b22d87cb7f19821c05d152"
|
||||
|
||||
[[package]]
|
||||
name = "rustix"
|
||||
version = "0.38.32"
|
||||
|
@ -1218,6 +1224,7 @@ dependencies = [
|
|||
"png",
|
||||
"pretty_env_logger",
|
||||
"rand",
|
||||
"rustc-hash",
|
||||
"serde",
|
||||
"thiserror",
|
||||
"tobj",
|
||||
|
|
|
@ -16,4 +16,5 @@ tobj = { version = "3", features = ["log"] }
|
|||
vulkanalia = { version = "=0.23.0", features = ["libloading", "provisional", "window"] }
|
||||
winit = "0.29"
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
rand = "0.8"
|
||||
rand = "0.8"
|
||||
rustc-hash = "*"
|
|
@ -4,6 +4,7 @@ use anyhow::Result;
|
|||
use cgmath::{vec2, vec3};
|
||||
|
||||
use std::collections::HashMap;
|
||||
use rustc_hash::FxHashMap;
|
||||
|
||||
use crate::app_data::AppData;
|
||||
use crate::buffer;
|
||||
|
@ -13,7 +14,7 @@ use crate::primitives::cube::Cube;
|
|||
extern crate rand;
|
||||
use rand::Rng;
|
||||
|
||||
const CHUNK_SIZE: usize = 100;
|
||||
const CHUNK_SIZE: usize = 500;
|
||||
|
||||
#[derive(Clone, Debug, Default)]
|
||||
pub struct Scene {
|
||||
|
@ -80,12 +81,12 @@ impl Scene {
|
|||
#[derive(Clone, Debug)]
|
||||
struct Chunk {
|
||||
//todo change to hashmap?
|
||||
blocks: HashMap<cgmath::Vector3<u32>, Cube>,
|
||||
blocks: HashMap<cgmath::Vector3<u32>, Cube, rustc_hash::FxBuildHasher>,
|
||||
}
|
||||
|
||||
impl Chunk {
|
||||
pub fn create() -> Result<Self> {
|
||||
let mut map = HashMap::new();
|
||||
let mut map: HashMap<cgmath::Vector3<u32>, Cube, rustc_hash::FxBuildHasher> = FxHashMap::default();
|
||||
Ok(Self {
|
||||
blocks: map
|
||||
})
|
||||
|
|
Loading…
Reference in a new issue