materials, brick and nodes structure, preparing for world generation

This commit is contained in:
Piotrek
2021-04-24 17:06:44 +02:00
parent 829ae1ddb6
commit 97ece7a823
13 changed files with 311 additions and 244 deletions
+46 -3
View File
@@ -5,19 +5,62 @@ use winit::{
use std::sync::Arc;
mod camera_controller; use camera_controller::CameraController;
mod world_gen; use world_gen::WorldGen;
use crate::renderer::Renderer;
//use crate::renderer::BrickData;
pub struct App {
pub window: Window,
pub renderer: Renderer,
world_gen: WorldGen,
camera_controller: CameraController,
}
impl App {
pub fn new(window: Window, renderer: Renderer) -> Self {
pub fn new(window: Window) -> Self {
let mut renderer = futures::executor::block_on(Renderer::new(&window));
let camera_controller = CameraController::new();
Self { window, renderer, camera_controller }
let mut world_gen = WorldGen::new();
// let start = std::time::Instant::now();
// for x in 0..128 {
// for z in 0..128 {
// // Dirt
// for y in 0..31 {
// renderer.set_voxel(x, y, z, 1);
// }
// // Grass
// renderer.set_voxel(x, 31, z, 2);
// }
// }
// println!("Generated in {}ms", start.elapsed().as_millis());
let start = std::time::Instant::now();
for bx in 0..4 {
for bz in 0..4 {
let brick_id = renderer.brick_get_id(bx, 0, bz);
renderer.brick_mark_changed(brick_id);
for x in 0..32 {
for z in 0..32 {
// Dirt
for y in 0..31 {
renderer.brick_set_voxel(brick_id, x, y, z, 1);
}
// Grass
renderer.brick_set_voxel(brick_id, x, 31, z, 2);
}
}
}
}
println!("Generated in {}ms", start.elapsed().as_millis());
Self { window, renderer, camera_controller, world_gen }
}
pub fn input(&mut self, event: Arc<Event<()>>) {