2020-06-17 18:05:47 +00:00
|
|
|
use crate::site::Site;
|
2020-08-12 13:51:21 +00:00
|
|
|
use common::store::Store;
|
|
|
|
use noise::{Seedable, SuperSimplex};
|
2020-06-17 18:05:47 +00:00
|
|
|
|
|
|
|
pub struct Index {
|
2020-07-25 11:19:13 +00:00
|
|
|
pub seed: u32,
|
2020-06-17 18:05:47 +00:00
|
|
|
pub time: f32,
|
2020-07-26 11:41:46 +00:00
|
|
|
pub noise: Noise,
|
2020-06-17 18:05:47 +00:00
|
|
|
pub sites: Store<Site>,
|
|
|
|
}
|
2020-07-25 11:19:13 +00:00
|
|
|
|
|
|
|
impl Index {
|
|
|
|
pub fn new(seed: u32) -> Self {
|
|
|
|
Self {
|
|
|
|
seed,
|
2020-07-26 11:41:46 +00:00
|
|
|
time: 0.0,
|
|
|
|
noise: Noise::new(seed),
|
|
|
|
sites: Store::default(),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub struct Noise {
|
|
|
|
pub cave_nz: SuperSimplex,
|
2020-08-09 16:34:48 +00:00
|
|
|
pub scatter_nz: SuperSimplex,
|
2020-07-26 11:41:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
impl Noise {
|
|
|
|
fn new(seed: u32) -> Self {
|
|
|
|
Self {
|
2020-08-09 16:34:48 +00:00
|
|
|
cave_nz: SuperSimplex::new().set_seed(seed + 0),
|
|
|
|
scatter_nz: SuperSimplex::new().set_seed(seed + 1),
|
2020-07-25 11:19:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|