no clue
This commit is contained in:
220
Cargo.lock
generated
220
Cargo.lock
generated
@@ -31,15 +31,6 @@ dependencies = [
|
||||
"zerocopy",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "aho-corasick"
|
||||
version = "1.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916"
|
||||
dependencies = [
|
||||
"memchr",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "allocator-api2"
|
||||
version = "0.2.18"
|
||||
@@ -109,22 +100,13 @@ version = "1.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "175571dd1d178ced59193a6fc02dde1b972eb0bc56c892cde9beeceac5bf0f6b"
|
||||
|
||||
[[package]]
|
||||
name = "ash"
|
||||
version = "0.37.3+1.3.251"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "39e9c3835d686b0a6084ab4234fcd1b07dbf6e4767dce60874b12356a25ecd4a"
|
||||
dependencies = [
|
||||
"libloading 0.7.4",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ash"
|
||||
version = "0.38.0+1.3.281"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0bb44936d800fea8f016d7f2311c6a4f97aebd5dc86f09906139ec848cf3a46f"
|
||||
dependencies = [
|
||||
"libloading 0.8.5",
|
||||
"libloading",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -556,27 +538,12 @@ dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crossbeam-queue"
|
||||
version = "0.3.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "df0346b5d5e76ac2fe4e327c5fd1118d6be7c51dfb18f9b7922923f287471e35"
|
||||
dependencies = [
|
||||
"crossbeam-utils",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crossbeam-utils"
|
||||
version = "0.8.20"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "22ec99545bb0ed0ea7bb9b8e1e9122ea386ff8a48c0922e43f36d45ab09e0e80"
|
||||
|
||||
[[package]]
|
||||
name = "crunchy"
|
||||
version = "0.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7"
|
||||
|
||||
[[package]]
|
||||
name = "cursor-icon"
|
||||
version = "1.1.0"
|
||||
@@ -593,7 +560,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bdbd1f579714e3c809ebd822c81ef148b1ceaeb3d535352afc73fd0c4c6a0017"
|
||||
dependencies = [
|
||||
"bitflags 2.6.0",
|
||||
"libloading 0.8.5",
|
||||
"libloading",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
@@ -609,7 +576,7 @@ version = "0.5.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "330c60081dcc4c72131f8eb70510f1ac07223e5d4163db481a04a0befcffa412"
|
||||
dependencies = [
|
||||
"libloading 0.8.5",
|
||||
"libloading",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -860,17 +827,6 @@ dependencies = [
|
||||
"bitflags 2.6.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "half"
|
||||
version = "2.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6dd08c532ae367adf81c312a4580bc67f1d0fe8bc9c460520283f4c0ff277888"
|
||||
dependencies = [
|
||||
"bytemuck",
|
||||
"cfg-if",
|
||||
"crunchy",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hashbrown"
|
||||
version = "0.14.5"
|
||||
@@ -891,18 +847,12 @@ dependencies = [
|
||||
"bitflags 2.6.0",
|
||||
"com",
|
||||
"libc",
|
||||
"libloading 0.8.5",
|
||||
"libloading",
|
||||
"thiserror",
|
||||
"widestring",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "heck"
|
||||
version = "0.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8"
|
||||
|
||||
[[package]]
|
||||
name = "hermit-abi"
|
||||
version = "0.4.0"
|
||||
@@ -934,12 +884,6 @@ dependencies = [
|
||||
"hashbrown",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "itoa"
|
||||
version = "1.0.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b"
|
||||
|
||||
[[package]]
|
||||
name = "jni"
|
||||
version = "0.21.1"
|
||||
@@ -987,7 +931,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6aae1df220ece3c0ada96b8153459b67eebe9ae9212258bb0134ae60416fdf76"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"libloading 0.8.5",
|
||||
"libloading",
|
||||
"pkg-config",
|
||||
]
|
||||
|
||||
@@ -1003,16 +947,6 @@ version = "0.2.158"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d8adc4bb1803a324070e64a98ae98f38934d91957a99cfb3a43dcbc01bc56439"
|
||||
|
||||
[[package]]
|
||||
name = "libloading"
|
||||
version = "0.7.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b67380fd3b2fbe7527a606e18729d21c6f3951633d0500574c4dc22d2d638b9f"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "libloading"
|
||||
version = "0.8.5"
|
||||
@@ -1193,7 +1127,7 @@ dependencies = [
|
||||
"log",
|
||||
"ndk-sys 0.6.0+11769913",
|
||||
"num_enum",
|
||||
"raw-window-handle 0.6.2",
|
||||
"raw-window-handle",
|
||||
"thiserror",
|
||||
]
|
||||
|
||||
@@ -1299,7 +1233,7 @@ version = "0.7.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "af1844ef2428cc3e1cb900be36181049ef3d3193c63e43026cfe202983b27a56"
|
||||
dependencies = [
|
||||
"proc-macro-crate 3.2.0",
|
||||
"proc-macro-crate",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.77",
|
||||
@@ -1660,16 +1594,6 @@ version = "0.3.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e8cf8e6a8aa66ce33f63993ffc4ea4271eb5b0530a9002db8455ea6050c77bfa"
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro-crate"
|
||||
version = "1.3.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7f4c021e1093a56626774e81216a4ce732a735e5bad4868a03f3ed65ca0c3919"
|
||||
dependencies = [
|
||||
"once_cell",
|
||||
"toml_edit 0.19.15",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro-crate"
|
||||
version = "3.2.0"
|
||||
@@ -1748,12 +1672,6 @@ version = "0.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9c8a99fddc9f0ba0a85884b8d14e3592853e787d581ca1816c91349b10e4eeab"
|
||||
|
||||
[[package]]
|
||||
name = "raw-window-handle"
|
||||
version = "0.5.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f2ff9a1f06a88b01621b7ae906ef0211290d1c8a168a15542486a8f61c0833b9"
|
||||
|
||||
[[package]]
|
||||
name = "raw-window-handle"
|
||||
version = "0.6.2"
|
||||
@@ -1784,35 +1702,6 @@ dependencies = [
|
||||
"bitflags 2.6.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "regex"
|
||||
version = "1.10.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4219d74c6b67a3654a9fbebc4b419e22126d13d2f3c4a07ee0cb61ff79a79619"
|
||||
dependencies = [
|
||||
"aho-corasick",
|
||||
"memchr",
|
||||
"regex-automata",
|
||||
"regex-syntax",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "regex-automata"
|
||||
version = "0.4.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "38caf58cc5ef2fed281f89292ef23f6365465ed9a41b7a7754eb4e26496c92df"
|
||||
dependencies = [
|
||||
"aho-corasick",
|
||||
"memchr",
|
||||
"regex-syntax",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "regex-syntax"
|
||||
version = "0.8.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b"
|
||||
|
||||
[[package]]
|
||||
name = "renderdoc-sys"
|
||||
version = "1.1.0"
|
||||
@@ -1844,12 +1733,6 @@ dependencies = [
|
||||
"windows-sys 0.52.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ryu"
|
||||
version = "1.0.18"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f"
|
||||
|
||||
[[package]]
|
||||
name = "safe_arch"
|
||||
version = "0.7.2"
|
||||
@@ -1913,18 +1796,6 @@ dependencies = [
|
||||
"syn 2.0.77",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_json"
|
||||
version = "1.0.128"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6ff5456707a1de34e7e37f2a6fd3d3f808c318259cbd01ab6377795054b483d8"
|
||||
dependencies = [
|
||||
"itoa",
|
||||
"memchr",
|
||||
"ryu",
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "shlex"
|
||||
version = "1.3.0"
|
||||
@@ -2149,17 +2020,6 @@ version = "0.6.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0dd7358ecb8fc2f8d014bf86f6f638ce72ba252a2c3a2572f2a795f1d23efb41"
|
||||
|
||||
[[package]]
|
||||
name = "toml_edit"
|
||||
version = "0.19.15"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421"
|
||||
dependencies = [
|
||||
"indexmap",
|
||||
"toml_datetime",
|
||||
"winnow 0.5.40",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "toml_edit"
|
||||
version = "0.21.1"
|
||||
@@ -2259,15 +2119,6 @@ version = "0.9.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a"
|
||||
|
||||
[[package]]
|
||||
name = "vk-parse"
|
||||
version = "0.12.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "81086c28be67a8759cd80cbb3c8f7b520e0874605fc5eb74d5a1c9c2d1878e79"
|
||||
dependencies = [
|
||||
"xml-rs",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "voxelgame"
|
||||
version = "0.1.0"
|
||||
@@ -2283,53 +2134,10 @@ dependencies = [
|
||||
"rustc-hash 2.0.0",
|
||||
"simba 0.8.1",
|
||||
"simdnoise",
|
||||
"vulkano",
|
||||
"wgpu",
|
||||
"winit",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "vulkano"
|
||||
version = "0.34.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "70f4278f76307b3c388679234b397b4f90de29cdba53873c26b624ed82653d75"
|
||||
dependencies = [
|
||||
"ahash",
|
||||
"ash 0.37.3+1.3.251",
|
||||
"bytemuck",
|
||||
"core-graphics-types",
|
||||
"crossbeam-queue",
|
||||
"half",
|
||||
"heck",
|
||||
"indexmap",
|
||||
"libloading 0.8.5",
|
||||
"objc",
|
||||
"once_cell",
|
||||
"parking_lot",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"raw-window-handle 0.5.2",
|
||||
"regex",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"smallvec",
|
||||
"thread_local",
|
||||
"vk-parse",
|
||||
"vulkano-macros",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "vulkano-macros"
|
||||
version = "0.34.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "52be622d364272fd77e298e7f68e8547ae66e7687cb86eb85335412cee7e3965"
|
||||
dependencies = [
|
||||
"proc-macro-crate 1.3.1",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 1.0.109",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "walkdir"
|
||||
version = "2.5.0"
|
||||
@@ -2566,7 +2374,7 @@ dependencies = [
|
||||
"naga",
|
||||
"parking_lot",
|
||||
"profiling",
|
||||
"raw-window-handle 0.6.2",
|
||||
"raw-window-handle",
|
||||
"smallvec",
|
||||
"static_assertions",
|
||||
"wasm-bindgen",
|
||||
@@ -2594,7 +2402,7 @@ dependencies = [
|
||||
"once_cell",
|
||||
"parking_lot",
|
||||
"profiling",
|
||||
"raw-window-handle 0.6.2",
|
||||
"raw-window-handle",
|
||||
"rustc-hash 1.1.0",
|
||||
"smallvec",
|
||||
"thiserror",
|
||||
@@ -2610,7 +2418,7 @@ checksum = "f6bbf4b4de8b2a83c0401d9e5ae0080a2792055f25859a02bf9be97952bbed4f"
|
||||
dependencies = [
|
||||
"android_system_properties",
|
||||
"arrayvec",
|
||||
"ash 0.38.0+1.3.281",
|
||||
"ash",
|
||||
"bit-set",
|
||||
"bitflags 2.6.0",
|
||||
"block",
|
||||
@@ -2626,7 +2434,7 @@ dependencies = [
|
||||
"js-sys",
|
||||
"khronos-egl",
|
||||
"libc",
|
||||
"libloading 0.8.5",
|
||||
"libloading",
|
||||
"log",
|
||||
"metal",
|
||||
"naga",
|
||||
@@ -2636,7 +2444,7 @@ dependencies = [
|
||||
"parking_lot",
|
||||
"profiling",
|
||||
"range-alloc",
|
||||
"raw-window-handle 0.6.2",
|
||||
"raw-window-handle",
|
||||
"renderdoc-sys",
|
||||
"rustc-hash 1.1.0",
|
||||
"smallvec",
|
||||
@@ -2959,7 +2767,7 @@ dependencies = [
|
||||
"orbclient",
|
||||
"percent-encoding",
|
||||
"pin-project",
|
||||
"raw-window-handle 0.6.2",
|
||||
"raw-window-handle",
|
||||
"redox_syscall 0.4.1",
|
||||
"rustix",
|
||||
"sctk-adwaita",
|
||||
@@ -3020,7 +2828,7 @@ dependencies = [
|
||||
"as-raw-xcb-connection",
|
||||
"gethostname",
|
||||
"libc",
|
||||
"libloading 0.8.5",
|
||||
"libloading",
|
||||
"once_cell",
|
||||
"rustix",
|
||||
"x11rb-protocol",
|
||||
|
||||
@@ -21,5 +21,10 @@ bevy_derive = "0.13.2"
|
||||
winit = {version="0.30.1", features=["serde"]}
|
||||
block-mesh = "0.2.0"
|
||||
rustc-hash = "2.0.0"
|
||||
vulkano = "0.34.1"
|
||||
simdnoise = { git = "https://github.com/valadaptive/rust-simd-noise", rev = "965175f" }
|
||||
|
||||
[profile.dev]
|
||||
opt-level = 1
|
||||
[profile.dev.package."*"]
|
||||
opt-level = 3
|
||||
|
||||
|
||||
@@ -19,7 +19,8 @@ use system::render::add_grid;
|
||||
|
||||
use crate::{
|
||||
common::{ClientMessage, ServerHandle, ServerMessage},
|
||||
server::Server, util::timer::Timer,
|
||||
server::Server,
|
||||
util::timer::Timer,
|
||||
};
|
||||
|
||||
use self::{input::Input, render::Renderer, ClientState};
|
||||
@@ -47,8 +48,6 @@ pub struct Client<'a> {
|
||||
server: ServerHandle,
|
||||
server_id_map: HashMap<Entity, Entity>,
|
||||
systems: ClientSystems,
|
||||
frame_target: Instant,
|
||||
frame_time: Duration,
|
||||
second_target: Instant,
|
||||
the_thing: bool,
|
||||
}
|
||||
@@ -93,8 +92,6 @@ impl Client<'_> {
|
||||
world,
|
||||
server,
|
||||
server_id_map: HashMap::new(),
|
||||
frame_target: Instant::now(),
|
||||
frame_time: FRAME_TIME,
|
||||
second_target: Instant::now(),
|
||||
the_thing: false,
|
||||
}
|
||||
@@ -127,16 +124,6 @@ impl Client<'_> {
|
||||
}
|
||||
}
|
||||
|
||||
if now >= self.frame_target {
|
||||
self.frame_target += self.frame_time;
|
||||
let mut commands = std::mem::take(&mut self.render_commands);
|
||||
let world_cmds = std::mem::take(&mut self.world.resource_mut::<RenderCommands>().0);
|
||||
commands.extend(world_cmds);
|
||||
self.renderer.handle_commands(commands);
|
||||
self.renderer.draw();
|
||||
self.render_timer.add(self.renderer.timer().duration(0));
|
||||
}
|
||||
|
||||
if now >= self.second_target {
|
||||
self.second_target += Duration::from_secs(1);
|
||||
let timer = &self.render_timer;
|
||||
@@ -177,7 +164,15 @@ impl Client<'_> {
|
||||
match event {
|
||||
WindowEvent::CloseRequested => self.exit = true,
|
||||
WindowEvent::Resized(size) => self.renderer.resize(size),
|
||||
// WindowEvent::RedrawRequested => self.renderer.draw(),
|
||||
WindowEvent::RedrawRequested => {
|
||||
let mut commands = std::mem::take(&mut self.render_commands);
|
||||
let world_cmds = std::mem::take(&mut self.world.resource_mut::<RenderCommands>().0);
|
||||
commands.extend(world_cmds);
|
||||
self.renderer.handle_commands(commands);
|
||||
self.renderer.draw();
|
||||
self.render_timer.add(self.renderer.timer().duration(0));
|
||||
self.window.request_redraw();
|
||||
}
|
||||
WindowEvent::CursorLeft { .. } => {
|
||||
self.input.clear();
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ const EPSILON = 0.00000000001;
|
||||
const MAX_ITERS = 10000;
|
||||
// NOTE: CANNOT GO HIGHER THAN 23 due to how floating point
|
||||
// numbers are stored and the bit manipulation used
|
||||
const MAX_SCALE: u32 = 13;
|
||||
const MAX_SCALE: u32 = 23;
|
||||
fn trace_full(pos_view: vec4<f32>, dir_view: vec4<f32>) -> vec4<f32> {
|
||||
if arrayLength(&voxel_data) == 1 {
|
||||
return vec4<f32>(0.0);
|
||||
|
||||
@@ -1,82 +0,0 @@
|
||||
use crate::{
|
||||
client::camera::Camera,
|
||||
common::component::{ChunkMesh, ChunkPos}, util::oct_tree::OctTree,
|
||||
};
|
||||
|
||||
use super::{voxel::VoxelColor, Renderer};
|
||||
use bevy_ecs::entity::Entity;
|
||||
use nalgebra::{Rotation3, Vector3};
|
||||
use ndarray::Array3;
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub enum RenderCommand {
|
||||
CreateVoxelGrid(CreateVoxelGrid),
|
||||
AddChunk(AddChunk),
|
||||
UpdateGridTransform(UpdateGridTransform),
|
||||
ViewUpdate(Camera),
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct CreateVoxelGrid {
|
||||
pub id: Entity,
|
||||
pub pos: Vector3<f32>,
|
||||
pub orientation: Rotation3<f32>,
|
||||
pub dimensions: Vector3<usize>,
|
||||
pub grid: Array3<VoxelColor>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct AddChunk {
|
||||
pub id: Entity,
|
||||
pub pos: ChunkPos,
|
||||
pub mesh: ChunkMesh,
|
||||
pub tree: OctTree,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct UpdateGridTransform {
|
||||
pub id: Entity,
|
||||
pub pos: Vector3<f32>,
|
||||
pub orientation: Rotation3<f32>,
|
||||
}
|
||||
|
||||
impl Renderer {
|
||||
pub fn handle_commands(&mut self, commands: Vec<RenderCommand>) {
|
||||
let mut new_camera = false;
|
||||
for cmd in commands {
|
||||
match cmd {
|
||||
RenderCommand::CreateVoxelGrid(desc) => self.voxel_pipeline.add_group(
|
||||
&self.device,
|
||||
&mut self.encoder,
|
||||
&mut self.staging_belt,
|
||||
desc,
|
||||
),
|
||||
RenderCommand::ViewUpdate(camera) => {
|
||||
new_camera = true;
|
||||
self.camera = camera;
|
||||
}
|
||||
RenderCommand::UpdateGridTransform(update) => self.voxel_pipeline.update_transform(
|
||||
&self.device,
|
||||
&mut self.encoder,
|
||||
&mut self.staging_belt,
|
||||
update,
|
||||
),
|
||||
RenderCommand::AddChunk(desc) => self.voxel_pipeline.add_chunk(
|
||||
&self.device,
|
||||
&mut self.encoder,
|
||||
&mut self.staging_belt,
|
||||
desc,
|
||||
),
|
||||
}
|
||||
}
|
||||
if new_camera {
|
||||
self.voxel_pipeline.update_view(
|
||||
&self.device,
|
||||
&mut self.encoder,
|
||||
&mut self.staging_belt,
|
||||
self.size,
|
||||
&self.camera,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,79 +0,0 @@
|
||||
mod command;
|
||||
pub mod voxel;
|
||||
use std::sync::Arc;
|
||||
|
||||
pub use command::*;
|
||||
use vulkano::{
|
||||
device::{Device, DeviceCreateInfo, QueueCreateInfo, QueueFlags}, instance::{Instance, InstanceCreateInfo}, memory::allocator::StandardMemoryAllocator, VulkanLibrary
|
||||
};
|
||||
|
||||
use super::camera::Camera;
|
||||
use crate::client::rsc::CLEAR_COLOR;
|
||||
use nalgebra::Vector2;
|
||||
use voxel::VoxelPipeline;
|
||||
use winit::{dpi::PhysicalSize, window::Window};
|
||||
|
||||
pub struct Renderer {
|
||||
camera: Camera,
|
||||
}
|
||||
|
||||
impl Renderer {
|
||||
pub fn new(window: Arc<Window>) -> Self {
|
||||
let library = VulkanLibrary::new().expect("no local Vulkan library/DLL");
|
||||
let instance = Instance::new(library, InstanceCreateInfo::default())
|
||||
.expect("failed to create instance");
|
||||
let physical_device = instance
|
||||
.enumerate_physical_devices()
|
||||
.expect("could not enumerate devices")
|
||||
.next()
|
||||
.expect("no devices available");
|
||||
let queue_family_index = physical_device
|
||||
.queue_family_properties()
|
||||
.iter()
|
||||
.enumerate()
|
||||
.position(|(_queue_family_index, queue_family_properties)| {
|
||||
queue_family_properties
|
||||
.queue_flags
|
||||
.contains(QueueFlags::GRAPHICS)
|
||||
})
|
||||
.expect("couldn't find a graphical queue family")
|
||||
as u32;
|
||||
|
||||
let (device, mut queues) = Device::new(
|
||||
physical_device,
|
||||
DeviceCreateInfo {
|
||||
// here we pass the desired queue family to use by index
|
||||
queue_create_infos: vec![QueueCreateInfo {
|
||||
queue_family_index,
|
||||
..Default::default()
|
||||
}],
|
||||
..Default::default()
|
||||
},
|
||||
)
|
||||
.expect("failed to create device");
|
||||
|
||||
let queue = queues.next().unwrap();
|
||||
let memory_allocator = Arc::new(StandardMemoryAllocator::new_default(device.clone()));
|
||||
|
||||
Self {
|
||||
camera: Camera::default(),
|
||||
size: Vector2::new(size.width, size.height),
|
||||
voxel_pipeline: VoxelPipeline::new(&device, &config),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn reset_shader(&mut self) {
|
||||
todo!()
|
||||
}
|
||||
|
||||
pub fn update_shader(&mut self) {
|
||||
todo!()
|
||||
}
|
||||
|
||||
pub fn draw(&mut self) {}
|
||||
|
||||
pub fn resize(&mut self, size: PhysicalSize<u32>) {
|
||||
self.size = Vector2::new(size.width, size.height);
|
||||
todo!();
|
||||
}
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use vulkano::{buffer::{Buffer, BufferCreateInfo, BufferUsage}, memory::allocator::{AllocationCreateInfo, MemoryAllocator, MemoryTypeFilter}};
|
||||
|
||||
pub struct VoxelPipeline {
|
||||
|
||||
}
|
||||
|
||||
impl VoxelPipeline {
|
||||
pub fn init(memory_allocator: Arc<impl MemoryAllocator>) {
|
||||
let buffer = Buffer::from_data(
|
||||
memory_allocator.clone(),
|
||||
BufferCreateInfo {
|
||||
usage: BufferUsage::UNIFORM_BUFFER,
|
||||
..Default::default()
|
||||
},
|
||||
AllocationCreateInfo {
|
||||
memory_type_filter: MemoryTypeFilter::PREFER_DEVICE
|
||||
| MemoryTypeFilter::HOST_SEQUENTIAL_WRITE,
|
||||
..Default::default()
|
||||
},
|
||||
data,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,7 @@ use bevy_derive::{Deref, DerefMut};
|
||||
use bevy_ecs::{bundle::Bundle, component::Component, entity::Entity, system::Resource};
|
||||
use nalgebra::Vector3;
|
||||
|
||||
pub const SCALE: u32 = 9;
|
||||
pub const SCALE: u32 = 14;
|
||||
pub const SIDE_LENGTH: usize = 2usize.pow(SCALE);
|
||||
pub const SHAPE: (usize, usize, usize) = (SIDE_LENGTH, SIDE_LENGTH, SIDE_LENGTH);
|
||||
pub const DIMENSIONS: Vector3<usize> = Vector3::new(SIDE_LENGTH, SIDE_LENGTH, SIDE_LENGTH);
|
||||
|
||||
@@ -14,18 +14,23 @@ impl OctNode {
|
||||
pub const fn new_node(addr: u32) -> Self {
|
||||
Self(addr)
|
||||
}
|
||||
|
||||
pub const fn new_leaf(data: u32) -> Self {
|
||||
Self(data | LEAF_BIT)
|
||||
}
|
||||
|
||||
pub const fn is_leaf(&self) -> bool {
|
||||
self.0 >= LEAF_BIT
|
||||
}
|
||||
|
||||
pub const fn is_node(&self) -> bool {
|
||||
self.0 < LEAF_BIT
|
||||
}
|
||||
|
||||
pub const fn node_data(&self) -> u32 {
|
||||
self.0
|
||||
}
|
||||
|
||||
pub const fn leaf_data(&self) -> u32 {
|
||||
self.0 & !LEAF_BIT
|
||||
}
|
||||
@@ -67,9 +72,11 @@ impl OctTree {
|
||||
levels,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn from_leaf_fn(f_leaf: &mut impl FnMut(Vector3<usize>) -> u32, levels: u32) -> OctTree {
|
||||
Self::from_fn(f_leaf, &mut |_, _| None, levels)
|
||||
}
|
||||
|
||||
pub fn from_fn(
|
||||
f_leaf: &mut impl FnMut(Vector3<usize>) -> u32,
|
||||
f_node: &mut impl FnMut(Vector3<usize>, u32) -> Option<u32>,
|
||||
@@ -77,6 +84,7 @@ impl OctTree {
|
||||
) -> OctTree {
|
||||
Self::from_fn_offset(f_leaf, f_node, levels, Vector3::from_element(0))
|
||||
}
|
||||
|
||||
pub fn from_fn_offset(
|
||||
f_leaf: &mut impl FnMut(Vector3<usize>) -> u32,
|
||||
f_node: &mut impl FnMut(Vector3<usize>, u32) -> Option<u32>,
|
||||
@@ -98,6 +106,7 @@ impl OctTree {
|
||||
levels,
|
||||
}
|
||||
}
|
||||
|
||||
fn from_fn_offset_inner(
|
||||
f_leaf: &mut impl FnMut(Vector3<usize>) -> u32,
|
||||
f_node: &mut impl FnMut(Vector3<usize>, u32) -> Option<u32>,
|
||||
@@ -157,9 +166,11 @@ impl OctTree {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn from_arr(arr: ArrayView3<u32>, levels: u32) -> Self {
|
||||
Self::from_fn(&mut |p| arr[(p.x, p.y, p.z)], &mut |_, _| None, levels)
|
||||
}
|
||||
|
||||
pub fn get(&self, mut pos: Vector3<usize>) -> u32 {
|
||||
let mut data_start = 1;
|
||||
let mut i = 0;
|
||||
@@ -175,9 +186,16 @@ impl OctTree {
|
||||
}
|
||||
self.data[i].leaf_data()
|
||||
}
|
||||
|
||||
pub fn raw(&self) -> &[OctNode] {
|
||||
&self.data
|
||||
}
|
||||
|
||||
pub fn from_children(children: [OctTree; 8]) {
|
||||
// Self {
|
||||
// data:
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
pub struct OctTreeIter<'a> {
|
||||
|
||||
Reference in New Issue
Block a user