mirror of
https://github.com/griffi-gh/kubi.git
synced 2024-11-25 16:28:42 -06:00
control
This commit is contained in:
parent
90c5b2a1e2
commit
6b8deab094
|
@ -1,6 +1,7 @@
|
|||
use flume::{Sender, Receiver};
|
||||
use glam::IVec3;
|
||||
use shipyard::Unique;
|
||||
use rayon::{ThreadPool, ThreadPoolBuilder};
|
||||
use super::{
|
||||
chunk::BlockData,
|
||||
render::ChunkVertex,
|
||||
|
@ -33,16 +34,18 @@ pub enum ChunkTaskResponse {
|
|||
#[derive(Unique)]
|
||||
pub struct ChunkTaskManager {
|
||||
channel: (Sender<ChunkTaskResponse>, Receiver<ChunkTaskResponse>),
|
||||
pool: ThreadPool,
|
||||
}
|
||||
impl ChunkTaskManager {
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
channel: flume::unbounded::<ChunkTaskResponse>(), //maybe put a bound or even bound(0)?
|
||||
pool: ThreadPoolBuilder::new().num_threads(4).build().unwrap()
|
||||
}
|
||||
}
|
||||
pub fn spawn_task(&self, task: ChunkTask) {
|
||||
let sender = self.channel.0.clone();
|
||||
rayon::spawn(move || {
|
||||
self.pool.spawn(move || {
|
||||
let _ = sender.send(match task {
|
||||
ChunkTask::GenerateMesh { position, data } => {
|
||||
let (vertices, indexes) = generate_mesh(data);
|
||||
|
|
|
@ -18,7 +18,7 @@ pub fn generate_world(chunk_position: IVec3, seed: u64) -> BlockData {
|
|||
for z in 0..CHUNK_SIZE {
|
||||
let position = ivec3(x as i32, y as i32, z as i32) + offset;
|
||||
let noise = noise.get_noise3d(position.x as f32, position.y as f32, position.z as f32);
|
||||
if noise > 0.8 {
|
||||
if (0.7..0.8).contains(&noise) {
|
||||
blocks[x][y][z] = Block::Stone;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue