mirror of
https://github.com/griffi-gh/kubi.git
synced 2024-11-24 15:58:43 -06:00
"fix" compile errs
This commit is contained in:
parent
0e22bccbac
commit
eaad06863f
146
Cargo.lock
generated
146
Cargo.lock
generated
|
@ -244,32 +244,13 @@ version = "0.1.6"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0d8c1fef690941d3e7788d328517591fecc684c084084702d6ff1641e993699a"
|
||||
|
||||
[[package]]
|
||||
name = "block-sys"
|
||||
version = "0.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ae85a0696e7ea3b835a453750bf002770776609115e6d25c6d2ff28a8200f7e7"
|
||||
dependencies = [
|
||||
"objc-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "block2"
|
||||
version = "0.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "15b55663a85f33501257357e6421bb33e769d5c9ffb5ba0921c975a123e35e68"
|
||||
dependencies = [
|
||||
"block-sys",
|
||||
"objc2 0.4.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "block2"
|
||||
version = "0.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "43ff7d91d3c1d568065b06c899777d1e48dcf76103a672a0adbc238a7f247f1e"
|
||||
dependencies = [
|
||||
"objc2 0.5.1",
|
||||
"objc2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -1027,8 +1008,8 @@ checksum = "dfa686283ad6dd069f105e5ab091b04c62850d3e4cf5d67debad1933f55023df"
|
|||
|
||||
[[package]]
|
||||
name = "hui"
|
||||
version = "0.1.0-alpha.4"
|
||||
source = "git+https://github.com/griffi-gh/hui?rev=dd5af8b9e2#dd5af8b9e2dc4cb2beb0b130d82167258ea2bd4e"
|
||||
version = "0.1.0-alpha.5"
|
||||
source = "git+https://github.com/griffi-gh/hui?rev=3a50d2d0dde#3a50d2d0dde7044d02860dac9ab059bd353657a2"
|
||||
dependencies = [
|
||||
"derive_more",
|
||||
"derive_setters",
|
||||
|
@ -1041,13 +1022,14 @@ dependencies = [
|
|||
"log",
|
||||
"nohash-hasher",
|
||||
"rect_packer",
|
||||
"rustc-hash",
|
||||
"tinyset",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hui-derive"
|
||||
version = "0.1.0-alpha.4"
|
||||
source = "git+https://github.com/griffi-gh/hui?rev=dd5af8b9e2#dd5af8b9e2dc4cb2beb0b130d82167258ea2bd4e"
|
||||
version = "0.1.0-alpha.5"
|
||||
source = "git+https://github.com/griffi-gh/hui?rev=3a50d2d0dde#3a50d2d0dde7044d02860dac9ab059bd353657a2"
|
||||
dependencies = [
|
||||
"quote",
|
||||
"syn 2.0.60",
|
||||
|
@ -1055,13 +1037,13 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "hui-winit"
|
||||
version = "0.1.0-alpha.4"
|
||||
source = "git+https://github.com/griffi-gh/hui?rev=dd5af8b9e2#dd5af8b9e2dc4cb2beb0b130d82167258ea2bd4e"
|
||||
version = "0.1.0-alpha.5"
|
||||
source = "git+https://github.com/griffi-gh/hui?rev=3a50d2d0dde#3a50d2d0dde7044d02860dac9ab059bd353657a2"
|
||||
dependencies = [
|
||||
"glam",
|
||||
"hui",
|
||||
"log",
|
||||
"winit 0.29.15",
|
||||
"winit",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -1093,17 +1075,6 @@ dependencies = [
|
|||
"cc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "icrate"
|
||||
version = "0.0.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "99d3aaff8a54577104bafdf686ff18565c3b6903ca5782a2026ef06e2c7aa319"
|
||||
dependencies = [
|
||||
"block2 0.3.0",
|
||||
"dispatch",
|
||||
"objc2 0.4.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ident_case"
|
||||
version = "1.0.1"
|
||||
|
@ -1281,7 +1252,7 @@ dependencies = [
|
|||
"uflow",
|
||||
"wgpu",
|
||||
"winapi",
|
||||
"winit 0.30.0",
|
||||
"winit",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -1649,16 +1620,6 @@ version = "0.3.3"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "da284c198fb9b7b0603f8635185e85fbd5b64ee154b1ed406d489077de2d6d60"
|
||||
|
||||
[[package]]
|
||||
name = "objc2"
|
||||
version = "0.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "559c5a40fdd30eb5e344fbceacf7595a81e242529fb4e21cf5f43fb4f11ff98d"
|
||||
dependencies = [
|
||||
"objc-sys",
|
||||
"objc2-encode 3.0.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "objc2"
|
||||
version = "0.5.1"
|
||||
|
@ -1666,7 +1627,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
checksum = "b4b25e1034d0e636cd84707ccdaa9f81243d399196b8a773946dcffec0401659"
|
||||
dependencies = [
|
||||
"objc-sys",
|
||||
"objc2-encode 4.0.1",
|
||||
"objc2-encode",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -1675,8 +1636,8 @@ version = "0.2.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fb79768a710a9a1798848179edb186d1af7e8a8679f369e4b8d201dd2a034047"
|
||||
dependencies = [
|
||||
"block2 0.5.0",
|
||||
"objc2 0.5.1",
|
||||
"block2",
|
||||
"objc2",
|
||||
"objc2-core-data",
|
||||
"objc2-foundation",
|
||||
]
|
||||
|
@ -1687,17 +1648,11 @@ version = "0.2.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6e092bc42eaf30a08844e6a076938c60751225ec81431ab89f5d1ccd9f958d6c"
|
||||
dependencies = [
|
||||
"block2 0.5.0",
|
||||
"objc2 0.5.1",
|
||||
"block2",
|
||||
"objc2",
|
||||
"objc2-foundation",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "objc2-encode"
|
||||
version = "3.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d079845b37af429bfe5dfa76e6d087d788031045b25cfc6fd898486fd9847666"
|
||||
|
||||
[[package]]
|
||||
name = "objc2-encode"
|
||||
version = "4.0.1"
|
||||
|
@ -1710,9 +1665,9 @@ version = "0.2.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cfaefe14254871ea16c7d88968c0ff14ba554712a20d76421eec52f0a7fb8904"
|
||||
dependencies = [
|
||||
"block2 0.5.0",
|
||||
"block2",
|
||||
"dispatch",
|
||||
"objc2 0.5.1",
|
||||
"objc2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -2000,15 +1955,6 @@ version = "0.2.1"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d8ffb4dfda4b01cc420847665dc480760d596ce186f2772a66ed32fe9acb1c45"
|
||||
|
||||
[[package]]
|
||||
name = "redox_syscall"
|
||||
version = "0.3.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29"
|
||||
dependencies = [
|
||||
"bitflags 1.3.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "redox_syscall"
|
||||
version = "0.4.1"
|
||||
|
@ -2815,16 +2761,6 @@ dependencies = [
|
|||
"wasm-bindgen",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "web-time"
|
||||
version = "0.2.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "aa30049b1c872b72c89866d458eae9f20380ab280ffd1b1e18df2d3e2d98cfe0"
|
||||
dependencies = [
|
||||
"js-sys",
|
||||
"wasm-bindgen",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "web-time"
|
||||
version = "1.1.0"
|
||||
|
@ -3009,15 +2945,6 @@ dependencies = [
|
|||
"windows-targets 0.42.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-sys"
|
||||
version = "0.48.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9"
|
||||
dependencies = [
|
||||
"windows-targets 0.48.5",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-sys"
|
||||
version = "0.52.0"
|
||||
|
@ -3205,41 +3132,6 @@ version = "0.52.5"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0"
|
||||
|
||||
[[package]]
|
||||
name = "winit"
|
||||
version = "0.29.15"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0d59ad965a635657faf09c8f062badd885748428933dad8e8bdd64064d92e5ca"
|
||||
dependencies = [
|
||||
"android-activity 0.5.2",
|
||||
"atomic-waker",
|
||||
"bitflags 2.5.0",
|
||||
"calloop",
|
||||
"cfg_aliases 0.1.1",
|
||||
"core-foundation",
|
||||
"core-graphics",
|
||||
"cursor-icon",
|
||||
"icrate",
|
||||
"js-sys",
|
||||
"libc",
|
||||
"log",
|
||||
"ndk 0.8.0",
|
||||
"ndk-sys 0.5.0+25.2.9519653",
|
||||
"objc2 0.4.1",
|
||||
"once_cell",
|
||||
"orbclient",
|
||||
"redox_syscall 0.3.5",
|
||||
"rustix",
|
||||
"smol_str",
|
||||
"unicode-segmentation",
|
||||
"wasm-bindgen",
|
||||
"wasm-bindgen-futures",
|
||||
"web-sys",
|
||||
"web-time 0.2.4",
|
||||
"windows-sys 0.48.0",
|
||||
"xkbcommon-dl",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winit"
|
||||
version = "0.30.0"
|
||||
|
@ -3262,7 +3154,7 @@ dependencies = [
|
|||
"libc",
|
||||
"memmap2",
|
||||
"ndk 0.9.0",
|
||||
"objc2 0.5.1",
|
||||
"objc2",
|
||||
"objc2-app-kit",
|
||||
"objc2-foundation",
|
||||
"orbclient",
|
||||
|
@ -3283,7 +3175,7 @@ dependencies = [
|
|||
"wayland-protocols",
|
||||
"wayland-protocols-plasma",
|
||||
"web-sys",
|
||||
"web-time 1.1.0",
|
||||
"web-time",
|
||||
"windows-sys 0.52.0",
|
||||
"x11-dl",
|
||||
"x11rb",
|
||||
|
|
|
@ -21,10 +21,13 @@ opt-level = 1
|
|||
[profile.dev.package.uflow]
|
||||
opt-level = 3
|
||||
|
||||
[profile.dev.package.glium]
|
||||
[profile.dev.package.wgpu]
|
||||
opt-level = 3
|
||||
|
||||
[profile.dev.package.bracket-noise]
|
||||
[profile.dev.package.wgpu-core]
|
||||
opt-level = 3
|
||||
|
||||
[profile.dev.package.wgpu-hal]
|
||||
opt-level = 3
|
||||
|
||||
[profile.dev.package.fastnoise-lite]
|
||||
|
|
|
@ -9,7 +9,7 @@ pub fn init() {
|
|||
use env_logger::{fmt::Color, Builder, Env};
|
||||
|
||||
let env = Env::default()
|
||||
.filter_or("RUST_LOG", "trace,gilrs=warn,rusty_xinput=warn");
|
||||
.filter_or("RUST_LOG", "trace,gilrs=warn,rusty_xinput=warn,wgpu=warn,wgpu_core=warn,wgpu_hal=warn,hui=info,hui-winit=info,hui-glium=info,hui-wgpu=info");
|
||||
Builder::from_env(env)
|
||||
.format(|buf, record| {
|
||||
let mut level_style = buf.style();
|
||||
|
|
|
@ -11,8 +11,8 @@ crate-type = ["lib", "cdylib"]
|
|||
[dependencies]
|
||||
kubi-shared = { path = "../kubi-shared" }
|
||||
kubi-logging = { path = "../kubi-logging" }
|
||||
hui = { version = "0.1.0-alpha.4", git = "https://github.com/griffi-gh/hui", rev = "dd5af8b9e2" }
|
||||
hui-winit = { version = "0.1.0-alpha.4", git = "https://github.com/griffi-gh/hui", rev = "dd5af8b9e2" }
|
||||
hui = { git = "https://github.com/griffi-gh/hui", rev = "3a50d2d0dde" }
|
||||
hui-winit = { git = "https://github.com/griffi-gh/hui", rev = "3a50d2d0dde", features = ["winit_30"] }
|
||||
log = "0.4"
|
||||
wgpu = { version = "0.20", features = ["webgl"] }
|
||||
pollster = "0.3"
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use shipyard::{AllStoragesView, IntoIter, NonSendSync, Unique, UniqueView, UniqueViewMut, View};
|
||||
use crate::{events::InputDeviceEvent, rendering::{Renderer, WindowSize}};
|
||||
use crate::{events::InputDeviceEvent, rendering::Renderer};
|
||||
use winit::{
|
||||
dpi::PhysicalPosition, event::{DeviceEvent, ElementState, RawKeyEvent}, keyboard::{KeyCode, PhysicalKey}, window::CursorGrabMode
|
||||
};
|
||||
|
@ -16,7 +16,7 @@ pub fn update_cursor_lock_state(
|
|||
}
|
||||
if lock.is_inserted_or_modified() {
|
||||
//TODO MIGRATION
|
||||
let window = &display.window;
|
||||
let window = display.window();
|
||||
window.set_cursor_grab(match lock.0 {
|
||||
true => CursorGrabMode::Confined,
|
||||
false => CursorGrabMode::None,
|
||||
|
@ -42,7 +42,6 @@ pub fn debug_toggle_lock(
|
|||
mut lock: UniqueViewMut<CursorLock>,
|
||||
device_events: View<InputDeviceEvent>,
|
||||
ren: NonSendSync<UniqueView<Renderer>>,
|
||||
size: UniqueView<WindowSize>,
|
||||
) {
|
||||
for evt in device_events.iter() {
|
||||
if let DeviceEvent::Key(RawKeyEvent {
|
||||
|
@ -51,8 +50,8 @@ pub fn debug_toggle_lock(
|
|||
}) = evt.event {
|
||||
lock.0 = !lock.0;
|
||||
if !lock.0 {
|
||||
let center = PhysicalPosition::new(size.0.x as f64 / 2., size.0.y as f64 / 2.);
|
||||
let _ = ren.window.set_cursor_position(center);
|
||||
let center = PhysicalPosition::new(ren.size().width as f64 / 2., ren.size().height as f64 / 2.);
|
||||
let _ = ren.window().set_cursor_position(center);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -91,7 +91,7 @@ pub fn initial_resize_event(
|
|||
) {
|
||||
let (w, h) = {
|
||||
let renderer = storages.borrow::<NonSendSync<UniqueView<Renderer>>>().unwrap();
|
||||
renderer.display.get_framebuffer_dimensions()
|
||||
(renderer.size().width, renderer.size().height)
|
||||
};
|
||||
storages.add_entity((
|
||||
EventComponent,
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use hui::UiInstance;
|
||||
//use hui_glium::GliumUiRenderer;
|
||||
use shipyard::{AllStoragesView, Unique, UniqueView, NonSendSync, UniqueViewMut};
|
||||
use crate::rendering::{RenderTarget, Renderer, WindowSize};
|
||||
use crate::rendering::{Renderer, WindowSize};
|
||||
|
||||
#[derive(Unique)]
|
||||
pub struct UiState {
|
||||
|
@ -34,13 +34,13 @@ pub fn kubi_ui_end(
|
|||
//renderer.update(hui);
|
||||
}
|
||||
|
||||
pub fn kubi_ui_draw(
|
||||
ui: NonSendSync<UniqueView<UiState>>,
|
||||
mut target: NonSendSync<UniqueViewMut<RenderTarget>>,
|
||||
size: UniqueView<WindowSize>
|
||||
) {
|
||||
// pub fn kubi_ui_draw(
|
||||
// ui: NonSendSync<UniqueView<UiState>>,
|
||||
// mut target: NonSendSync<UniqueViewMut<RenderTarget>>,
|
||||
// size: UniqueView<WindowSize>
|
||||
// ) {
|
||||
// ui.renderer.draw(&mut target.0, size.0.as_vec2());
|
||||
}
|
||||
// }
|
||||
|
||||
pub fn hui_process_winit_events(
|
||||
event: &winit::event::Event<()>,
|
||||
|
|
|
@ -75,18 +75,12 @@ use events::{
|
|||
};
|
||||
use input::{init_input, process_inputs};
|
||||
use player_controller::{debug_switch_ctl_type, update_player_controllers};
|
||||
// use rendering::{
|
||||
// clear_background, entities::render_entities, init_window_size, primitives::init_primitives, resize_renderer, selection_box::render_selection_box, sumberge::render_submerged_view, update_window_size, world::{draw_current_chunk_border, draw_world, draw_world_trans, init_trans_chunk_queue}, BackgroundColor, RenderTarget, Renderer
|
||||
// };
|
||||
use rendering::{
|
||||
Renderer,
|
||||
RenderTarget,
|
||||
BackgroundColor,
|
||||
clear_background,
|
||||
init_window_size,
|
||||
update_window_size,
|
||||
primitives::init_primitives,
|
||||
world::{init_trans_chunk_queue, draw_world, draw_world_trans, draw_current_chunk_border},
|
||||
selection_box::render_selection_box,
|
||||
entities::render_entities,
|
||||
sumberge::render_submerged_view,
|
||||
init_window_size, resize_renderer, update_window_size,
|
||||
BackgroundColor, Renderer
|
||||
};
|
||||
use block_placement::update_block_placement;
|
||||
use delta_time::{DeltaTime, init_delta_time};
|
||||
|
@ -95,7 +89,7 @@ use control_flow::{exit_on_esc, insert_control_flow_unique, RequestExit};
|
|||
use state::{is_ingame, is_ingame_or_loading, is_loading, init_state, update_state, is_connecting};
|
||||
use networking::{update_networking, update_networking_late, is_multiplayer, disconnect_on_exit, is_singleplayer};
|
||||
use init::initialize_from_args;
|
||||
use hui_integration::{kubi_ui_begin, kubi_ui_draw, kubi_ui_end, kubi_ui_init};
|
||||
use hui_integration::{kubi_ui_begin, /*kubi_ui_draw,*/ kubi_ui_end, kubi_ui_init};
|
||||
use loading_screen::update_loading_screen;
|
||||
use connecting_screen::update_connecting_screen;
|
||||
use fixed_timestamp::init_fixed_timestamp_storage;
|
||||
|
@ -121,7 +115,7 @@ fn startup() -> Workload {
|
|||
init_window_size,
|
||||
kubi_ui_init,
|
||||
load_prefabs,
|
||||
init_primitives,
|
||||
//init_primitives,
|
||||
insert_lock_state,
|
||||
init_state,
|
||||
initialize_from_args,
|
||||
|
@ -132,7 +126,7 @@ fn startup() -> Workload {
|
|||
init_client_physics,
|
||||
init_chat_manager,
|
||||
init_crosshair_image,
|
||||
init_trans_chunk_queue,
|
||||
//init_trans_chunk_queue,
|
||||
).into_sequential_workload()
|
||||
}
|
||||
|
||||
|
@ -140,6 +134,7 @@ fn update() -> Workload {
|
|||
(
|
||||
debug_toggle_lock,
|
||||
update_window_size,
|
||||
resize_renderer,
|
||||
update_cursor_lock_state,
|
||||
process_inputs,
|
||||
kubi_ui_begin,
|
||||
|
@ -181,20 +176,20 @@ fn update() -> Workload {
|
|||
).into_sequential_workload()
|
||||
}
|
||||
|
||||
fn render() -> Workload {
|
||||
(
|
||||
clear_background,
|
||||
(
|
||||
draw_world,
|
||||
draw_current_chunk_border,
|
||||
render_selection_box,
|
||||
render_entities,
|
||||
draw_world_trans,
|
||||
render_submerged_view,
|
||||
).into_sequential_workload().run_if(is_ingame),
|
||||
kubi_ui_draw,
|
||||
).into_sequential_workload()
|
||||
}
|
||||
// fn render() -> Workload {
|
||||
// (
|
||||
// clear_background,
|
||||
// (
|
||||
// draw_world,
|
||||
// draw_current_chunk_border,
|
||||
// render_selection_box,
|
||||
// render_entities,
|
||||
// draw_world_trans,
|
||||
// render_submerged_view,
|
||||
// ).into_sequential_workload().run_if(is_ingame),
|
||||
// kubi_ui_draw,
|
||||
// ).into_sequential_workload()
|
||||
// }
|
||||
|
||||
fn after_frame_end() -> Workload {
|
||||
(
|
||||
|
@ -244,7 +239,7 @@ pub fn kubi_main(
|
|||
world.add_workload(pre_startup);
|
||||
world.add_workload(startup);
|
||||
world.add_workload(update);
|
||||
world.add_workload(render);
|
||||
//world.add_workload(render);
|
||||
world.add_workload(after_frame_end);
|
||||
|
||||
//Save _visualizer.json
|
||||
|
@ -326,18 +321,18 @@ pub fn kubi_main(
|
|||
world.run_workload(update).unwrap();
|
||||
|
||||
//Start rendering (maybe use custom views for this?)
|
||||
let target = {
|
||||
let renderer = world.borrow::<NonSendSync<UniqueView<Renderer>>>().unwrap();
|
||||
renderer.display.draw()
|
||||
};
|
||||
world.add_unique_non_send_sync(RenderTarget(target));
|
||||
// let target = {
|
||||
// let renderer = world.borrow::<NonSendSync<UniqueView<Renderer>>>().unwrap();
|
||||
// renderer.display.draw()
|
||||
// };
|
||||
// world.add_unique_non_send_sync(RenderTarget(target));
|
||||
|
||||
//Run render workflow
|
||||
world.run_workload(render).unwrap();
|
||||
//world.run_workload(render).unwrap();
|
||||
|
||||
//Finish rendering
|
||||
let target = world.remove_unique::<RenderTarget>().unwrap();
|
||||
target.0.finish().unwrap();
|
||||
// let target = world.remove_unique::<RenderTarget>().unwrap();
|
||||
// target.0.finish().unwrap();
|
||||
|
||||
//After frame end
|
||||
world.run_workload(after_frame_end).unwrap();
|
||||
|
|
|
@ -1,15 +1,13 @@
|
|||
use std::{io::{BufReader, Read}, path::Path};
|
||||
use hui::text::FontHandle;
|
||||
use shipyard::{AllStoragesView, NonSendSync, Unique, UniqueView, UniqueViewMut};
|
||||
use glium::{texture::{SrgbTexture2dArray, MipmapsOption}, Program};
|
||||
use kubi_shared::block::BlockTexture;
|
||||
use crate::{filesystem::AssetManager, hui_integration::UiState, rendering::Renderer};
|
||||
|
||||
mod texture;
|
||||
mod shaders;
|
||||
|
||||
use texture::load_texture2darray_prefab;
|
||||
use shaders::include_shader_prefab;
|
||||
//use texture::load_texture2darray_prefab;
|
||||
|
||||
pub trait AssetPaths {
|
||||
fn file_name(self) -> &'static str;
|
||||
|
@ -41,7 +39,7 @@ impl AssetPaths for BlockTexture {
|
|||
|
||||
#[derive(Unique)]
|
||||
#[repr(transparent)]
|
||||
pub struct BlockTexturesPrefab(pub SrgbTexture2dArray);
|
||||
pub struct BlockTexturesPrefab(pub wgpu::Texture);
|
||||
|
||||
// #[derive(Unique)]
|
||||
// #[repr(transparent)]
|
||||
|
@ -65,15 +63,15 @@ pub fn load_prefabs(
|
|||
mut ui: NonSendSync<UniqueViewMut<UiState>>,
|
||||
assman: UniqueView<AssetManager>
|
||||
) {
|
||||
log::info!("Loading textures...");
|
||||
storages.add_unique_non_send_sync(BlockTexturesPrefab(
|
||||
load_texture2darray_prefab::<BlockTexture, _>(
|
||||
&assman,
|
||||
"blocks".into(),
|
||||
&renderer.display,
|
||||
MipmapsOption::AutoGeneratedMipmaps
|
||||
)
|
||||
));
|
||||
// log::info!("Loading textures...");
|
||||
// storages.add_unique_non_send_sync(BlockTexturesPrefab(
|
||||
// load_texture2darray_prefab::<BlockTexture, _>(
|
||||
// &assman,
|
||||
// "blocks".into(),
|
||||
// &renderer.display,
|
||||
// MipmapsOption::AutoGeneratedMipmaps
|
||||
// )
|
||||
// ));
|
||||
|
||||
log::info!("Loading the UI stuff...");
|
||||
{
|
||||
|
@ -85,33 +83,33 @@ pub fn load_prefabs(
|
|||
storages.add_unique(UiFontPrefab(font_handle));
|
||||
}
|
||||
|
||||
log::info!("Compiling shaders...");
|
||||
storages.add_unique_non_send_sync(ChunkShaderPrefab(
|
||||
include_shader_prefab!(
|
||||
"world",
|
||||
"../shaders/world.vert",
|
||||
"../shaders/world.frag",
|
||||
&renderer.display
|
||||
)
|
||||
));
|
||||
storages.add_unique_non_send_sync(ColoredShaderPrefab(
|
||||
include_shader_prefab!(
|
||||
"colored",
|
||||
"../shaders/colored.vert",
|
||||
"../shaders/colored.frag",
|
||||
&renderer.display
|
||||
)
|
||||
));
|
||||
storages.add_unique_non_send_sync(Colored2ShaderPrefab(
|
||||
include_shader_prefab!(
|
||||
"colored",
|
||||
"../shaders/colored2.vert",
|
||||
"../shaders/colored2.frag",
|
||||
&renderer.display
|
||||
)
|
||||
));
|
||||
//log::info!("Compiling shaders...");
|
||||
// storages.add_unique_non_send_sync(ChunkShaderPrefab(
|
||||
// include_shader_prefab!(
|
||||
// "world",
|
||||
// "../shaders/world.vert",
|
||||
// "../shaders/world.frag",
|
||||
// &renderer.display
|
||||
// )
|
||||
// ));
|
||||
// storages.add_unique_non_send_sync(ColoredShaderPrefab(
|
||||
// include_shader_prefab!(
|
||||
// "colored",
|
||||
// "../shaders/colored.vert",
|
||||
// "../shaders/colored.frag",
|
||||
// &renderer.display
|
||||
// )
|
||||
// ));
|
||||
// storages.add_unique_non_send_sync(Colored2ShaderPrefab(
|
||||
// include_shader_prefab!(
|
||||
// "colored",
|
||||
// "../shaders/colored2.vert",
|
||||
// "../shaders/colored2.frag",
|
||||
// &renderer.display
|
||||
// )
|
||||
// ));
|
||||
|
||||
log::info!("releasing shader compiler");
|
||||
//log::info!("releasing shader compiler");
|
||||
|
||||
//renderer.display.release_shader_compiler();
|
||||
}
|
||||
|
|
|
@ -1,46 +1,45 @@
|
|||
use strum::IntoEnumIterator;
|
||||
use rayon::prelude::*;
|
||||
use std::{path::PathBuf, io::BufReader};
|
||||
use glium::{texture::{SrgbTexture2dArray, RawImage2d, MipmapsOption}, backend::Facade};
|
||||
use crate::filesystem::AssetManager;
|
||||
use super::AssetPaths;
|
||||
// use strum::IntoEnumIterator;
|
||||
// use rayon::prelude::*;
|
||||
// use std::{path::PathBuf, io::BufReader};
|
||||
// use crate::filesystem::AssetManager;
|
||||
// use super::AssetPaths;
|
||||
|
||||
pub fn load_texture2darray_prefab<
|
||||
T: AssetPaths + IntoEnumIterator,
|
||||
E: Facade
|
||||
>(
|
||||
assman: &AssetManager,
|
||||
directory: PathBuf,
|
||||
facade: &E,
|
||||
mipmaps: MipmapsOption,
|
||||
) -> SrgbTexture2dArray {
|
||||
log::info!("started loading {}", directory.as_os_str().to_str().unwrap());
|
||||
//Load raw images
|
||||
let tex_files: Vec<&'static str> = T::iter().map(|x| x.file_name()).collect();
|
||||
let raw_images: Vec<RawImage2d<u8>> = tex_files.par_iter().map(|&file_name| {
|
||||
log::info!("loading texture {}", file_name);
|
||||
//Get path to the image and open the file
|
||||
let reader = {
|
||||
let path = directory.join(file_name);
|
||||
BufReader::new(assman.open_asset(&path).expect("Failed to open texture file"))
|
||||
};
|
||||
//Parse image data
|
||||
let (image_data, dimensions) = {
|
||||
let image = image::load(
|
||||
reader,
|
||||
image::ImageFormat::Png
|
||||
).unwrap().to_rgba8();
|
||||
let dimensions = image.dimensions();
|
||||
(image.into_raw(), dimensions)
|
||||
};
|
||||
//Create a glium RawImage
|
||||
RawImage2d::from_raw_rgba_reversed(
|
||||
&image_data,
|
||||
dimensions
|
||||
)
|
||||
}).collect();
|
||||
log::info!("done loading texture files, uploading to the gpu");
|
||||
//Upload images to the GPU
|
||||
SrgbTexture2dArray::with_mipmaps(facade, raw_images, mipmaps)
|
||||
.expect("Failed to upload texture array to GPU")
|
||||
}
|
||||
// pub fn load_texture2darray_prefab<
|
||||
// T: AssetPaths + IntoEnumIterator,
|
||||
// E: Facade
|
||||
// >(
|
||||
// assman: &AssetManager,
|
||||
// directory: PathBuf,
|
||||
// facade: &E,
|
||||
// mipmaps: MipmapsOption,
|
||||
// ) -> SrgbTexture2dArray {
|
||||
// log::info!("started loading {}", directory.as_os_str().to_str().unwrap());
|
||||
// //Load raw images
|
||||
// let tex_files: Vec<&'static str> = T::iter().map(|x| x.file_name()).collect();
|
||||
// let raw_images: Vec<RawImage2d<u8>> = tex_files.par_iter().map(|&file_name| {
|
||||
// log::info!("loading texture {}", file_name);
|
||||
// //Get path to the image and open the file
|
||||
// let reader = {
|
||||
// let path = directory.join(file_name);
|
||||
// BufReader::new(assman.open_asset(&path).expect("Failed to open texture file"))
|
||||
// };
|
||||
// //Parse image data
|
||||
// let (image_data, dimensions) = {
|
||||
// let image = image::load(
|
||||
// reader,
|
||||
// image::ImageFormat::Png
|
||||
// ).unwrap().to_rgba8();
|
||||
// let dimensions = image.dimensions();
|
||||
// (image.into_raw(), dimensions)
|
||||
// };
|
||||
// //Create a glium RawImage
|
||||
// RawImage2d::from_raw_rgba_reversed(
|
||||
// &image_data,
|
||||
// dimensions
|
||||
// )
|
||||
// }).collect();
|
||||
// log::info!("done loading texture files, uploading to the gpu");
|
||||
// //Upload images to the GPU
|
||||
// SrgbTexture2dArray::with_mipmaps(facade, raw_images, mipmaps)
|
||||
// .expect("Failed to upload texture array to GPU")
|
||||
// }
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
use pollster::FutureExt;
|
||||
use shipyard::{Unique, NonSendSync, UniqueView, UniqueViewMut, View, IntoIter, AllStoragesView};
|
||||
use raw_window_handle::HasRawWindowHandle;
|
||||
use shipyard::{AllStoragesView, AllStoragesViewMut, IntoIter, NonSendSync, Unique, UniqueView, UniqueViewMut, View};
|
||||
use wgpu::SurfaceTargetUnsafe;
|
||||
use winit::{
|
||||
event_loop::ActiveEventLoop,
|
||||
window::{WindowAttributes, Fullscreen, Window},
|
||||
|
@ -14,6 +16,11 @@ pub mod selection_box;
|
|||
pub mod entities;
|
||||
pub mod sumberge;
|
||||
|
||||
pub struct BufferPair {
|
||||
pub index: wgpu::Buffer,
|
||||
pub vertex: wgpu::Buffer,
|
||||
}
|
||||
|
||||
#[derive(Unique)]
|
||||
#[repr(transparent)]
|
||||
pub struct BackgroundColor(pub Vec3);
|
||||
|
@ -26,14 +33,16 @@ pub struct WindowSize(pub UVec2);
|
|||
|
||||
#[derive(Unique)]
|
||||
pub struct Renderer {
|
||||
pub window: Window,
|
||||
pub instance: wgpu::Instance,
|
||||
pub surface: wgpu::Surface<'static>,
|
||||
pub device: wgpu::Device,
|
||||
pub queue: wgpu::Queue,
|
||||
pub surface_config: wgpu::SurfaceConfiguration,
|
||||
pub size: PhysicalSize<u32>,
|
||||
instance: wgpu::Instance,
|
||||
surface: wgpu::Surface<'static>,
|
||||
device: wgpu::Device,
|
||||
queue: wgpu::Queue,
|
||||
surface_config: wgpu::SurfaceConfiguration,
|
||||
size: PhysicalSize<u32>,
|
||||
// pub depth_texture: wgpu::Texture,
|
||||
|
||||
//must be last due to drop order
|
||||
window: Window,
|
||||
}
|
||||
|
||||
impl Renderer {
|
||||
|
@ -95,7 +104,11 @@ impl Renderer {
|
|||
..Default::default()
|
||||
});
|
||||
|
||||
let surface = instance.create_surface(window).unwrap();
|
||||
// Create a surface with `create_surface_unsafe` to get a surface with 'static lifetime
|
||||
// It should never outlive the window it's created from
|
||||
let surface = unsafe {
|
||||
instance.create_surface_unsafe(SurfaceTargetUnsafe::from_window(&window).unwrap()).unwrap()
|
||||
};
|
||||
|
||||
let adapter = instance.request_adapter(
|
||||
&wgpu::RequestAdapterOptions {
|
||||
|
@ -139,13 +152,89 @@ impl Renderer {
|
|||
pub fn reconfigure(&self) {
|
||||
self.surface.configure(&self.device, &self.surface_config);
|
||||
}
|
||||
|
||||
//getters:
|
||||
pub fn size(&self) -> PhysicalSize<u32> {
|
||||
self.size
|
||||
}
|
||||
|
||||
pub fn clear_background(
|
||||
mut target: NonSendSync<UniqueViewMut<RenderTarget>>,
|
||||
color: UniqueView<BackgroundColor>,
|
||||
pub fn window(&self) -> &Window {
|
||||
&self.window
|
||||
}
|
||||
|
||||
pub fn surface(&self) -> &wgpu::Surface<'static> {
|
||||
&self.surface
|
||||
}
|
||||
|
||||
pub fn device(&self) -> &wgpu::Device {
|
||||
&self.device
|
||||
}
|
||||
|
||||
pub fn queue(&self) -> &wgpu::Queue {
|
||||
&self.queue
|
||||
}
|
||||
|
||||
pub fn surface_config(&self) -> &wgpu::SurfaceConfiguration {
|
||||
&self.surface_config
|
||||
}
|
||||
}
|
||||
|
||||
pub fn render_master(storages: AllStoragesViewMut) {
|
||||
let renderer = storages.borrow::<UniqueView<Renderer>>().unwrap();
|
||||
|
||||
let mut encoder = renderer.device.create_command_encoder(&wgpu::CommandEncoderDescriptor {
|
||||
label: Some("main_encoder"),
|
||||
});
|
||||
let surface_texture = renderer.surface().get_current_texture().unwrap();
|
||||
let surface_view = surface_texture.texture.create_view(&wgpu::TextureViewDescriptor::default());
|
||||
|
||||
{
|
||||
let bg_color = storages.borrow::<UniqueView<BackgroundColor>>().unwrap();
|
||||
let mut render_pass = encoder.begin_render_pass(&wgpu::RenderPassDescriptor {
|
||||
label: Some("main0_pass"),
|
||||
color_attachments: &[Some(wgpu::RenderPassColorAttachment {
|
||||
view: &surface_view,
|
||||
resolve_target: None,
|
||||
ops: wgpu::Operations {
|
||||
load: wgpu::LoadOp::Clear(wgpu::Color {
|
||||
r: bg_color.0.x as f64,
|
||||
g: bg_color.0.y as f64,
|
||||
b: bg_color.0.z as f64,
|
||||
a: 1.0,
|
||||
}),
|
||||
store: wgpu::StoreOp::Store,
|
||||
},
|
||||
})],
|
||||
depth_stencil_attachment: None,
|
||||
..Default::default()
|
||||
});
|
||||
|
||||
// render_pass.set_pipeline(&renderer.pipeline);
|
||||
// render_pass.set_bind_group(0, &renderer.bind_group, &[]);
|
||||
// render_pass.set_vertex_buffer(0, renderer.vertex_buffer.slice(..));
|
||||
// render_pass.set_index_buffer(renderer.index_buffer.slice(..));
|
||||
// render_pass.draw_indexed(0..renderer.num_indices, 0, 0..1);
|
||||
}
|
||||
|
||||
renderer.queue().submit(Some(encoder.finish()));
|
||||
}
|
||||
|
||||
// pub fn clear_background(
|
||||
// mut target: NonSendSync<UniqueViewMut<RenderTarget>>,
|
||||
// color: UniqueView<BackgroundColor>,
|
||||
// ) {
|
||||
// target.0.clear_color_srgb_and_depth((color.0.x, color.0.y, color.0.z, 1.), 1.);
|
||||
// }
|
||||
|
||||
//Resize the renderer
|
||||
|
||||
pub fn resize_renderer(
|
||||
mut renderer: UniqueViewMut<Renderer>,
|
||||
resize: View<WindowResizedEvent>,
|
||||
) {
|
||||
target.0.clear_color_srgb_and_depth((color.0.x, color.0.y, color.0.z, 1.), 1.);
|
||||
if let Some(size) = resize.iter().last() {
|
||||
renderer.resize(PhysicalSize::new(size.0.x, size.0.y));
|
||||
}
|
||||
}
|
||||
|
||||
//not sure if this belongs here
|
||||
|
|
|
@ -1,58 +1,58 @@
|
|||
use shipyard::{NonSendSync, UniqueViewMut, UniqueView, View, IntoIter, IntoWithId};
|
||||
use glium::{DepthTest, Depth, PolygonMode, BackfaceCullingMode, DrawParameters, Surface, uniform};
|
||||
use kubi_shared::{entity::Entity, transform::Transform};
|
||||
use crate::{
|
||||
prefabs::ColoredShaderPrefab,
|
||||
camera::Camera,
|
||||
settings::GameSettings
|
||||
};
|
||||
use super::{
|
||||
RenderTarget,
|
||||
primitives::cube::CenteredCubePrimitive
|
||||
};
|
||||
// use shipyard::{NonSendSync, UniqueViewMut, UniqueView, View, IntoIter, IntoWithId};
|
||||
// use glium::{DepthTest, Depth, PolygonMode, BackfaceCullingMode, DrawParameters, Surface, uniform};
|
||||
// use kubi_shared::{entity::Entity, transform::Transform};
|
||||
// use crate::{
|
||||
// prefabs::ColoredShaderPrefab,
|
||||
// camera::Camera,
|
||||
// settings::GameSettings
|
||||
// };
|
||||
// use super::{
|
||||
// RenderTarget,
|
||||
// primitives::cube::CenteredCubePrimitive
|
||||
// };
|
||||
|
||||
// TODO: entity models
|
||||
pub fn render_entities(
|
||||
mut target: NonSendSync<UniqueViewMut<RenderTarget>>,
|
||||
buffers: NonSendSync<UniqueView<CenteredCubePrimitive>>,
|
||||
program: NonSendSync<UniqueView<ColoredShaderPrefab>>,
|
||||
camera: View<Camera>,
|
||||
settings: UniqueView<GameSettings>,
|
||||
entities: View<Entity>,
|
||||
transform: View<Transform>,
|
||||
) {
|
||||
let (camera_id, camera) = camera.iter().with_id().next().expect("No cameras in the scene");
|
||||
// // TODO: entity models
|
||||
// pub fn render_entities(
|
||||
// mut target: NonSendSync<UniqueViewMut<RenderTarget>>,
|
||||
// buffers: NonSendSync<UniqueView<CenteredCubePrimitive>>,
|
||||
// program: NonSendSync<UniqueView<ColoredShaderPrefab>>,
|
||||
// camera: View<Camera>,
|
||||
// settings: UniqueView<GameSettings>,
|
||||
// entities: View<Entity>,
|
||||
// transform: View<Transform>,
|
||||
// ) {
|
||||
// let (camera_id, camera) = camera.iter().with_id().next().expect("No cameras in the scene");
|
||||
|
||||
let draw_parameters = DrawParameters {
|
||||
depth: Depth {
|
||||
test: DepthTest::IfLess,
|
||||
write: true,
|
||||
..Default::default()
|
||||
},
|
||||
multisampling: settings.msaa.is_some(),
|
||||
polygon_mode: PolygonMode::Fill,
|
||||
backface_culling: BackfaceCullingMode::CullClockwise,
|
||||
..Default::default()
|
||||
};
|
||||
let view = camera.view_matrix.to_cols_array_2d();
|
||||
let perspective = camera.perspective_matrix.to_cols_array_2d();
|
||||
// let draw_parameters = DrawParameters {
|
||||
// depth: Depth {
|
||||
// test: DepthTest::IfLess,
|
||||
// write: true,
|
||||
// ..Default::default()
|
||||
// },
|
||||
// multisampling: settings.msaa.is_some(),
|
||||
// polygon_mode: PolygonMode::Fill,
|
||||
// backface_culling: BackfaceCullingMode::CullClockwise,
|
||||
// ..Default::default()
|
||||
// };
|
||||
// let view = camera.view_matrix.to_cols_array_2d();
|
||||
// let perspective = camera.perspective_matrix.to_cols_array_2d();
|
||||
|
||||
for (entity_id, (_, trans)) in (&entities, &transform).iter().with_id() {
|
||||
//skip rendering camera holder (as the entity would block the view)
|
||||
if entity_id == camera_id { continue }
|
||||
// for (entity_id, (_, trans)) in (&entities, &transform).iter().with_id() {
|
||||
// //skip rendering camera holder (as the entity would block the view)
|
||||
// if entity_id == camera_id { continue }
|
||||
|
||||
//render entity
|
||||
target.0.draw(
|
||||
&buffers.0,
|
||||
&buffers.1,
|
||||
&program.0,
|
||||
&uniform! {
|
||||
color: [1.0, 1.0, 1.0, 1.0_f32],
|
||||
model: trans.0.to_cols_array_2d(),
|
||||
view: view,
|
||||
perspective: perspective,
|
||||
},
|
||||
&draw_parameters
|
||||
).unwrap();
|
||||
}
|
||||
}
|
||||
// //render entity
|
||||
// target.0.draw(
|
||||
// &buffers.0,
|
||||
// &buffers.1,
|
||||
// &program.0,
|
||||
// &uniform! {
|
||||
// color: [1.0, 1.0, 1.0, 1.0_f32],
|
||||
// model: trans.0.to_cols_array_2d(),
|
||||
// view: view,
|
||||
// perspective: perspective,
|
||||
// },
|
||||
// &draw_parameters
|
||||
// ).unwrap();
|
||||
// }
|
||||
// }
|
||||
|
|
|
@ -1,30 +1,30 @@
|
|||
use shipyard::{Workload, IntoWorkload};
|
||||
use glium::implement_vertex;
|
||||
// use shipyard::{Workload, IntoWorkload};
|
||||
// use glium::implement_vertex;
|
||||
|
||||
pub mod cube;
|
||||
pub mod rect;
|
||||
pub mod stri;
|
||||
// pub mod cube;
|
||||
// pub mod rect;
|
||||
// pub mod stri;
|
||||
|
||||
use cube::init_cube_primitive;
|
||||
use rect::init_rect_primitive;
|
||||
use stri::init_stri_primitive;
|
||||
// use cube::init_cube_primitive;
|
||||
// use rect::init_rect_primitive;
|
||||
// use stri::init_stri_primitive;
|
||||
|
||||
#[derive(Clone, Copy, Default)]
|
||||
pub struct PositionOnlyVertex {
|
||||
pub position: [f32; 3],
|
||||
}
|
||||
implement_vertex!(PositionOnlyVertex, position);
|
||||
// #[derive(Clone, Copy, Default)]
|
||||
// pub struct PositionOnlyVertex {
|
||||
// pub position: [f32; 3],
|
||||
// }
|
||||
// implement_vertex!(PositionOnlyVertex, position);
|
||||
|
||||
#[derive(Clone, Copy, Default)]
|
||||
pub struct PositionOnlyVertex2d {
|
||||
pub position: [f32; 2],
|
||||
}
|
||||
implement_vertex!(PositionOnlyVertex2d, position);
|
||||
// #[derive(Clone, Copy, Default)]
|
||||
// pub struct PositionOnlyVertex2d {
|
||||
// pub position: [f32; 2],
|
||||
// }
|
||||
// implement_vertex!(PositionOnlyVertex2d, position);
|
||||
|
||||
pub fn init_primitives() -> Workload {
|
||||
(
|
||||
init_cube_primitive,
|
||||
init_rect_primitive,
|
||||
init_stri_primitive,
|
||||
).into_workload()
|
||||
}
|
||||
// pub fn init_primitives() -> Workload {
|
||||
// (
|
||||
// init_cube_primitive,
|
||||
// init_rect_primitive,
|
||||
// init_stri_primitive,
|
||||
// ).into_workload()
|
||||
// }
|
||||
|
|
|
@ -1,85 +1,85 @@
|
|||
use shipyard::{AllStoragesView, NonSendSync, UniqueView, Unique};
|
||||
use glium::{VertexBuffer, IndexBuffer, index::PrimitiveType};
|
||||
use crate::rendering::Renderer;
|
||||
use super::PositionOnlyVertex;
|
||||
// use shipyard::{AllStoragesView, NonSendSync, UniqueView, Unique};
|
||||
// use glium::{VertexBuffer, IndexBuffer, index::PrimitiveType};
|
||||
// use crate::rendering::Renderer;
|
||||
// use super::PositionOnlyVertex;
|
||||
|
||||
#[derive(Unique)]
|
||||
pub struct CubePrimitive(pub VertexBuffer<PositionOnlyVertex>, pub IndexBuffer<u16>);
|
||||
// #[derive(Unique)]
|
||||
// pub struct CubePrimitive(pub VertexBuffer<PositionOnlyVertex>, pub IndexBuffer<u16>);
|
||||
|
||||
#[derive(Unique)]
|
||||
pub struct CenteredCubePrimitive(pub VertexBuffer<PositionOnlyVertex>, pub IndexBuffer<u16>);
|
||||
// #[derive(Unique)]
|
||||
// pub struct CenteredCubePrimitive(pub VertexBuffer<PositionOnlyVertex>, pub IndexBuffer<u16>);
|
||||
|
||||
const CENTERED_CUBE_VERTICES: &[PositionOnlyVertex] = &[
|
||||
// front
|
||||
PositionOnlyVertex { position: [-0.5, -0.5, 0.5] },
|
||||
PositionOnlyVertex { position: [ 0.5, -0.5, 0.5] },
|
||||
PositionOnlyVertex { position: [ 0.5, 0.5, 0.5] },
|
||||
PositionOnlyVertex { position: [-0.5, 0.5, 0.5] },
|
||||
// back
|
||||
PositionOnlyVertex { position: [-0.5, -0.5, -0.5] },
|
||||
PositionOnlyVertex { position: [ 0.5, -0.5, -0.5] },
|
||||
PositionOnlyVertex { position: [ 0.5, 0.5, -0.5] },
|
||||
PositionOnlyVertex { position: [-0.5, 0.5, -0.5] },
|
||||
];
|
||||
const CUBE_VERTICES: &[PositionOnlyVertex] = &[
|
||||
// front
|
||||
PositionOnlyVertex { position: [0.0, 0.0, 1.0] },
|
||||
PositionOnlyVertex { position: [1.0, 0.0, 1.0] },
|
||||
PositionOnlyVertex { position: [1.0, 1.0, 1.0] },
|
||||
PositionOnlyVertex { position: [0.0, 1.0, 1.0] },
|
||||
// back
|
||||
PositionOnlyVertex { position: [0.0, 0.0, 0.0] },
|
||||
PositionOnlyVertex { position: [1.0, 0.0, 0.0] },
|
||||
PositionOnlyVertex { position: [1.0, 1.0, 0.0] },
|
||||
PositionOnlyVertex { position: [0.0, 1.0, 0.0] },
|
||||
];
|
||||
const CUBE_INDICES: &[u16] = &[
|
||||
// front
|
||||
0, 1, 2,
|
||||
2, 3, 0,
|
||||
// right
|
||||
1, 5, 6,
|
||||
6, 2, 1,
|
||||
// back
|
||||
7, 6, 5,
|
||||
5, 4, 7,
|
||||
// left
|
||||
4, 0, 3,
|
||||
3, 7, 4,
|
||||
// bottom
|
||||
4, 5, 1,
|
||||
1, 0, 4,
|
||||
// top
|
||||
3, 2, 6,
|
||||
6, 7, 3
|
||||
];
|
||||
// const CENTERED_CUBE_VERTICES: &[PositionOnlyVertex] = &[
|
||||
// // front
|
||||
// PositionOnlyVertex { position: [-0.5, -0.5, 0.5] },
|
||||
// PositionOnlyVertex { position: [ 0.5, -0.5, 0.5] },
|
||||
// PositionOnlyVertex { position: [ 0.5, 0.5, 0.5] },
|
||||
// PositionOnlyVertex { position: [-0.5, 0.5, 0.5] },
|
||||
// // back
|
||||
// PositionOnlyVertex { position: [-0.5, -0.5, -0.5] },
|
||||
// PositionOnlyVertex { position: [ 0.5, -0.5, -0.5] },
|
||||
// PositionOnlyVertex { position: [ 0.5, 0.5, -0.5] },
|
||||
// PositionOnlyVertex { position: [-0.5, 0.5, -0.5] },
|
||||
// ];
|
||||
// const CUBE_VERTICES: &[PositionOnlyVertex] = &[
|
||||
// // front
|
||||
// PositionOnlyVertex { position: [0.0, 0.0, 1.0] },
|
||||
// PositionOnlyVertex { position: [1.0, 0.0, 1.0] },
|
||||
// PositionOnlyVertex { position: [1.0, 1.0, 1.0] },
|
||||
// PositionOnlyVertex { position: [0.0, 1.0, 1.0] },
|
||||
// // back
|
||||
// PositionOnlyVertex { position: [0.0, 0.0, 0.0] },
|
||||
// PositionOnlyVertex { position: [1.0, 0.0, 0.0] },
|
||||
// PositionOnlyVertex { position: [1.0, 1.0, 0.0] },
|
||||
// PositionOnlyVertex { position: [0.0, 1.0, 0.0] },
|
||||
// ];
|
||||
// const CUBE_INDICES: &[u16] = &[
|
||||
// // front
|
||||
// 0, 1, 2,
|
||||
// 2, 3, 0,
|
||||
// // right
|
||||
// 1, 5, 6,
|
||||
// 6, 2, 1,
|
||||
// // back
|
||||
// 7, 6, 5,
|
||||
// 5, 4, 7,
|
||||
// // left
|
||||
// 4, 0, 3,
|
||||
// 3, 7, 4,
|
||||
// // bottom
|
||||
// 4, 5, 1,
|
||||
// 1, 0, 4,
|
||||
// // top
|
||||
// 3, 2, 6,
|
||||
// 6, 7, 3
|
||||
// ];
|
||||
|
||||
pub(super) fn init_cube_primitive(
|
||||
storages: AllStoragesView,
|
||||
display: NonSendSync<UniqueView<Renderer>>
|
||||
) {
|
||||
{
|
||||
let vert = VertexBuffer::immutable(
|
||||
&display.display,
|
||||
CUBE_VERTICES
|
||||
).unwrap();
|
||||
let index = IndexBuffer::immutable(
|
||||
&display.display,
|
||||
PrimitiveType::TrianglesList,
|
||||
CUBE_INDICES
|
||||
).unwrap();
|
||||
storages.add_unique_non_send_sync(CubePrimitive(vert, index));
|
||||
}
|
||||
{
|
||||
let vert = VertexBuffer::immutable(
|
||||
&display.display,
|
||||
CENTERED_CUBE_VERTICES
|
||||
).unwrap();
|
||||
let index = IndexBuffer::immutable(
|
||||
&display.display,
|
||||
PrimitiveType::TrianglesList,
|
||||
CUBE_INDICES
|
||||
).unwrap();
|
||||
storages.add_unique_non_send_sync(CenteredCubePrimitive(vert, index));
|
||||
}
|
||||
}
|
||||
// pub(super) fn init_cube_primitive(
|
||||
// storages: AllStoragesView,
|
||||
// display: NonSendSync<UniqueView<Renderer>>
|
||||
// ) {
|
||||
// {
|
||||
// let vert = VertexBuffer::immutable(
|
||||
// &display.display,
|
||||
// CUBE_VERTICES
|
||||
// ).unwrap();
|
||||
// let index = IndexBuffer::immutable(
|
||||
// &display.display,
|
||||
// PrimitiveType::TrianglesList,
|
||||
// CUBE_INDICES
|
||||
// ).unwrap();
|
||||
// storages.add_unique_non_send_sync(CubePrimitive(vert, index));
|
||||
// }
|
||||
// {
|
||||
// let vert = VertexBuffer::immutable(
|
||||
// &display.display,
|
||||
// CENTERED_CUBE_VERTICES
|
||||
// ).unwrap();
|
||||
// let index = IndexBuffer::immutable(
|
||||
// &display.display,
|
||||
// PrimitiveType::TrianglesList,
|
||||
// CUBE_INDICES
|
||||
// ).unwrap();
|
||||
// storages.add_unique_non_send_sync(CenteredCubePrimitive(vert, index));
|
||||
// }
|
||||
// }
|
||||
|
|
|
@ -1,31 +1,31 @@
|
|||
use shipyard::{Unique, AllStoragesView, NonSendSync, UniqueView};
|
||||
use glium::{VertexBuffer, IndexBuffer, index::PrimitiveType};
|
||||
use crate::rendering::Renderer;
|
||||
use super::PositionOnlyVertex2d;
|
||||
// use shipyard::{Unique, AllStoragesView, NonSendSync, UniqueView};
|
||||
// use glium::{VertexBuffer, IndexBuffer, index::PrimitiveType};
|
||||
// use crate::rendering::Renderer;
|
||||
// use super::PositionOnlyVertex2d;
|
||||
|
||||
#[derive(Unique)]
|
||||
pub struct RectPrimitive(pub VertexBuffer<PositionOnlyVertex2d>, pub IndexBuffer<u16>);
|
||||
// #[derive(Unique)]
|
||||
// pub struct RectPrimitive(pub VertexBuffer<PositionOnlyVertex2d>, pub IndexBuffer<u16>);
|
||||
|
||||
const RECT_VERTEX: &[PositionOnlyVertex2d] = &[
|
||||
PositionOnlyVertex2d { position: [0., 0.] },
|
||||
PositionOnlyVertex2d { position: [1., 0.] },
|
||||
PositionOnlyVertex2d { position: [0., 1.] },
|
||||
PositionOnlyVertex2d { position: [1., 1.] },
|
||||
];
|
||||
const RECT_INDEX: &[u16] = &[0, 1, 2, 1, 3, 2];
|
||||
// const RECT_VERTEX: &[PositionOnlyVertex2d] = &[
|
||||
// PositionOnlyVertex2d { position: [0., 0.] },
|
||||
// PositionOnlyVertex2d { position: [1., 0.] },
|
||||
// PositionOnlyVertex2d { position: [0., 1.] },
|
||||
// PositionOnlyVertex2d { position: [1., 1.] },
|
||||
// ];
|
||||
// const RECT_INDEX: &[u16] = &[0, 1, 2, 1, 3, 2];
|
||||
|
||||
pub(super) fn init_rect_primitive(
|
||||
storages: AllStoragesView,
|
||||
display: NonSendSync<UniqueView<Renderer>>
|
||||
) {
|
||||
let vert = VertexBuffer::immutable(
|
||||
&display.display,
|
||||
RECT_VERTEX
|
||||
).unwrap();
|
||||
let index = IndexBuffer::immutable(
|
||||
&display.display,
|
||||
PrimitiveType::TrianglesList,
|
||||
RECT_INDEX
|
||||
).unwrap();
|
||||
storages.add_unique_non_send_sync(RectPrimitive(vert, index));
|
||||
}
|
||||
// pub(super) fn init_rect_primitive(
|
||||
// storages: AllStoragesView,
|
||||
// display: NonSendSync<UniqueView<Renderer>>
|
||||
// ) {
|
||||
// let vert = VertexBuffer::immutable(
|
||||
// &display.display,
|
||||
// RECT_VERTEX
|
||||
// ).unwrap();
|
||||
// let index = IndexBuffer::immutable(
|
||||
// &display.display,
|
||||
// PrimitiveType::TrianglesList,
|
||||
// RECT_INDEX
|
||||
// ).unwrap();
|
||||
// storages.add_unique_non_send_sync(RectPrimitive(vert, index));
|
||||
// }
|
||||
|
|
|
@ -1,30 +1,30 @@
|
|||
use shipyard::{Unique, AllStoragesView, NonSendSync, UniqueView};
|
||||
use glium::{VertexBuffer, IndexBuffer, index::PrimitiveType};
|
||||
use crate::rendering::Renderer;
|
||||
use super::PositionOnlyVertex2d;
|
||||
// use shipyard::{Unique, AllStoragesView, NonSendSync, UniqueView};
|
||||
// use glium::{VertexBuffer, IndexBuffer, index::PrimitiveType};
|
||||
// use crate::rendering::Renderer;
|
||||
// use super::PositionOnlyVertex2d;
|
||||
|
||||
#[derive(Unique)]
|
||||
pub struct STriPrimitive(pub VertexBuffer<PositionOnlyVertex2d>, pub IndexBuffer<u16>);
|
||||
// #[derive(Unique)]
|
||||
// pub struct STriPrimitive(pub VertexBuffer<PositionOnlyVertex2d>, pub IndexBuffer<u16>);
|
||||
|
||||
const STRI_VERTEX: &[PositionOnlyVertex2d] = &[
|
||||
PositionOnlyVertex2d { position: [-1., -1.] },
|
||||
PositionOnlyVertex2d { position: [ 3., -1.] },
|
||||
PositionOnlyVertex2d { position: [-1., 3.] },
|
||||
];
|
||||
const STRI_INDEX: &[u16] = &[0, 1, 2];
|
||||
// const STRI_VERTEX: &[PositionOnlyVertex2d] = &[
|
||||
// PositionOnlyVertex2d { position: [-1., -1.] },
|
||||
// PositionOnlyVertex2d { position: [ 3., -1.] },
|
||||
// PositionOnlyVertex2d { position: [-1., 3.] },
|
||||
// ];
|
||||
// const STRI_INDEX: &[u16] = &[0, 1, 2];
|
||||
|
||||
pub(super) fn init_stri_primitive(
|
||||
storages: AllStoragesView,
|
||||
display: NonSendSync<UniqueView<Renderer>>
|
||||
) {
|
||||
let vert = VertexBuffer::immutable(
|
||||
&display.display,
|
||||
STRI_VERTEX
|
||||
).unwrap();
|
||||
let index = IndexBuffer::immutable(
|
||||
&display.display,
|
||||
PrimitiveType::TrianglesList,
|
||||
STRI_INDEX
|
||||
).unwrap();
|
||||
storages.add_unique_non_send_sync(STriPrimitive(vert, index));
|
||||
}
|
||||
// pub(super) fn init_stri_primitive(
|
||||
// storages: AllStoragesView,
|
||||
// display: NonSendSync<UniqueView<Renderer>>
|
||||
// ) {
|
||||
// let vert = VertexBuffer::immutable(
|
||||
// &display.display,
|
||||
// STRI_VERTEX
|
||||
// ).unwrap();
|
||||
// let index = IndexBuffer::immutable(
|
||||
// &display.display,
|
||||
// PrimitiveType::TrianglesList,
|
||||
// STRI_INDEX
|
||||
// ).unwrap();
|
||||
// storages.add_unique_non_send_sync(STriPrimitive(vert, index));
|
||||
// }
|
||||
|
|
|
@ -1,59 +1,59 @@
|
|||
use glam::{Mat4, Vec3, Quat};
|
||||
use shipyard::{View, IntoIter, NonSendSync, UniqueViewMut, UniqueView};
|
||||
use glium::{
|
||||
Surface,
|
||||
DrawParameters,
|
||||
BackfaceCullingMode,
|
||||
Blend, Depth, DepthTest,
|
||||
uniform,
|
||||
};
|
||||
use crate::{
|
||||
world::raycast::LookingAtBlock,
|
||||
camera::Camera,
|
||||
prefabs::ColoredShaderPrefab
|
||||
};
|
||||
use super::{
|
||||
RenderTarget,
|
||||
primitives::cube::CubePrimitive,
|
||||
};
|
||||
// use glam::{Mat4, Vec3, Quat};
|
||||
// use shipyard::{View, IntoIter, NonSendSync, UniqueViewMut, UniqueView};
|
||||
// use glium::{
|
||||
// Surface,
|
||||
// DrawParameters,
|
||||
// BackfaceCullingMode,
|
||||
// Blend, Depth, DepthTest,
|
||||
// uniform,
|
||||
// };
|
||||
// use crate::{
|
||||
// world::raycast::LookingAtBlock,
|
||||
// camera::Camera,
|
||||
// prefabs::ColoredShaderPrefab
|
||||
// };
|
||||
// use super::{
|
||||
// RenderTarget,
|
||||
// primitives::cube::CubePrimitive,
|
||||
// };
|
||||
|
||||
const SMOL: f32 = 0.0025;
|
||||
// const SMOL: f32 = 0.0025;
|
||||
|
||||
pub fn render_selection_box(
|
||||
lookat: View<LookingAtBlock>,
|
||||
camera: View<Camera>,
|
||||
mut target: NonSendSync<UniqueViewMut<RenderTarget>>,
|
||||
program: NonSendSync<UniqueView<ColoredShaderPrefab>>,
|
||||
buffers: NonSendSync<UniqueView<CubePrimitive>>,
|
||||
) {
|
||||
let camera = camera.iter().next().unwrap();
|
||||
let Some(lookat) = lookat.iter().next() else { return };
|
||||
let Some(lookat) = lookat.0 else { return };
|
||||
// pub fn render_selection_box(
|
||||
// lookat: View<LookingAtBlock>,
|
||||
// camera: View<Camera>,
|
||||
// mut target: NonSendSync<UniqueViewMut<RenderTarget>>,
|
||||
// program: NonSendSync<UniqueView<ColoredShaderPrefab>>,
|
||||
// buffers: NonSendSync<UniqueView<CubePrimitive>>,
|
||||
// ) {
|
||||
// let camera = camera.iter().next().unwrap();
|
||||
// let Some(lookat) = lookat.iter().next() else { return };
|
||||
// let Some(lookat) = lookat.0 else { return };
|
||||
|
||||
//Darken block
|
||||
target.0.draw(
|
||||
&buffers.0,
|
||||
&buffers.1,
|
||||
&program.0,
|
||||
&uniform! {
|
||||
color: [0., 0., 0., 0.5_f32],
|
||||
model: Mat4::from_scale_rotation_translation(
|
||||
Vec3::splat(1. + SMOL * 2.),
|
||||
Quat::default(),
|
||||
lookat.block_position.as_vec3() - Vec3::splat(SMOL)
|
||||
).to_cols_array_2d(),
|
||||
perspective: camera.perspective_matrix.to_cols_array_2d(),
|
||||
view: camera.view_matrix.to_cols_array_2d(),
|
||||
},
|
||||
&DrawParameters {
|
||||
backface_culling: BackfaceCullingMode::CullClockwise,
|
||||
blend: Blend::alpha_blending(),
|
||||
depth: Depth {
|
||||
//this may be unreliable... unless scale is applied! hacky...
|
||||
test: DepthTest::IfLessOrEqual,
|
||||
..Default::default()
|
||||
},
|
||||
..Default::default()
|
||||
}
|
||||
).unwrap();
|
||||
}
|
||||
// //Darken block
|
||||
// target.0.draw(
|
||||
// &buffers.0,
|
||||
// &buffers.1,
|
||||
// &program.0,
|
||||
// &uniform! {
|
||||
// color: [0., 0., 0., 0.5_f32],
|
||||
// model: Mat4::from_scale_rotation_translation(
|
||||
// Vec3::splat(1. + SMOL * 2.),
|
||||
// Quat::default(),
|
||||
// lookat.block_position.as_vec3() - Vec3::splat(SMOL)
|
||||
// ).to_cols_array_2d(),
|
||||
// perspective: camera.perspective_matrix.to_cols_array_2d(),
|
||||
// view: camera.view_matrix.to_cols_array_2d(),
|
||||
// },
|
||||
// &DrawParameters {
|
||||
// backface_culling: BackfaceCullingMode::CullClockwise,
|
||||
// blend: Blend::alpha_blending(),
|
||||
// depth: Depth {
|
||||
// //this may be unreliable... unless scale is applied! hacky...
|
||||
// test: DepthTest::IfLessOrEqual,
|
||||
// ..Default::default()
|
||||
// },
|
||||
// ..Default::default()
|
||||
// }
|
||||
// ).unwrap();
|
||||
// }
|
||||
|
|
|
@ -1,39 +1,39 @@
|
|||
use glium::{uniform, Blend, DrawParameters, Surface};
|
||||
use kubi_shared::transform::Transform;
|
||||
use shipyard::{IntoIter, NonSendSync, UniqueView, UniqueViewMut, View};
|
||||
use crate::{
|
||||
player::MainPlayer,
|
||||
prefabs::Colored2ShaderPrefab,
|
||||
rendering::primitives::stri::STriPrimitive,
|
||||
world::ChunkStorage,
|
||||
};
|
||||
use super::RenderTarget;
|
||||
// use glium::{uniform, Blend, DrawParameters, Surface};
|
||||
// use kubi_shared::transform::Transform;
|
||||
// use shipyard::{IntoIter, NonSendSync, UniqueView, UniqueViewMut, View};
|
||||
// use crate::{
|
||||
// player::MainPlayer,
|
||||
// prefabs::Colored2ShaderPrefab,
|
||||
// rendering::primitives::stri::STriPrimitive,
|
||||
// world::ChunkStorage,
|
||||
// };
|
||||
// use super::RenderTarget;
|
||||
|
||||
pub fn render_submerged_view(
|
||||
mut target: NonSendSync<UniqueViewMut<RenderTarget>>,
|
||||
primitive: NonSendSync<UniqueView<STriPrimitive>>,
|
||||
program: NonSendSync<UniqueView<Colored2ShaderPrefab>>,
|
||||
plr: View<MainPlayer>,
|
||||
trans: View<Transform>,
|
||||
world: UniqueView<ChunkStorage>,
|
||||
) {
|
||||
let (_, plr_trans) = (&plr, &trans).iter().next().expect("Main player MIA");
|
||||
let plr_pos = plr_trans.0.to_scale_rotation_translation().2;
|
||||
let block_at_pos = world.get_block(plr_pos.floor().as_ivec3());
|
||||
let Some(block_at_pos) = block_at_pos else { return };
|
||||
let Some(color) = block_at_pos.descriptor().submerge else { return };
|
||||
// pub fn render_submerged_view(
|
||||
// mut target: NonSendSync<UniqueViewMut<RenderTarget>>,
|
||||
// primitive: NonSendSync<UniqueView<STriPrimitive>>,
|
||||
// program: NonSendSync<UniqueView<Colored2ShaderPrefab>>,
|
||||
// plr: View<MainPlayer>,
|
||||
// trans: View<Transform>,
|
||||
// world: UniqueView<ChunkStorage>,
|
||||
// ) {
|
||||
// let (_, plr_trans) = (&plr, &trans).iter().next().expect("Main player MIA");
|
||||
// let plr_pos = plr_trans.0.to_scale_rotation_translation().2;
|
||||
// let block_at_pos = world.get_block(plr_pos.floor().as_ivec3());
|
||||
// let Some(block_at_pos) = block_at_pos else { return };
|
||||
// let Some(color) = block_at_pos.descriptor().submerge else { return };
|
||||
|
||||
let draw_parameters = DrawParameters {
|
||||
blend: Blend::alpha_blending(),
|
||||
..Default::default()
|
||||
};
|
||||
target.0.draw(
|
||||
&primitive.0,
|
||||
&primitive.1,
|
||||
&program.0,
|
||||
&uniform! {
|
||||
color: color.to_array(),
|
||||
},
|
||||
&draw_parameters,
|
||||
).unwrap();
|
||||
}
|
||||
// let draw_parameters = DrawParameters {
|
||||
// blend: Blend::alpha_blending(),
|
||||
// ..Default::default()
|
||||
// };
|
||||
// target.0.draw(
|
||||
// &primitive.0,
|
||||
// &primitive.1,
|
||||
// &program.0,
|
||||
// &uniform! {
|
||||
// color: color.to_array(),
|
||||
// },
|
||||
// &draw_parameters,
|
||||
// ).unwrap();
|
||||
// }
|
||||
|
|
|
@ -1,28 +1,28 @@
|
|||
use glam::{ivec3, IVec3, Mat4, Quat, Vec3};
|
||||
use shipyard::{track, AllStoragesView, IntoIter, NonSendSync, Unique, UniqueView, UniqueViewMut, View};
|
||||
use glium::{
|
||||
draw_parameters::{
|
||||
BackfaceCullingMode, Depth, DepthTest, PolygonMode
|
||||
}, implement_vertex, uniform, uniforms::{
|
||||
MagnifySamplerFilter, MinifySamplerFilter, Sampler, SamplerBehavior, SamplerWrapFunction
|
||||
}, Blend, DrawParameters, Smooth, Surface
|
||||
};
|
||||
use crate::{
|
||||
camera::Camera,
|
||||
player::MainPlayer,
|
||||
transform::Transform,
|
||||
prefabs::{
|
||||
ChunkShaderPrefab,
|
||||
BlockTexturesPrefab,
|
||||
ColoredShaderPrefab,
|
||||
},
|
||||
world::{
|
||||
ChunkStorage,
|
||||
ChunkMeshStorage,
|
||||
chunk::CHUNK_SIZE,
|
||||
}, settings::GameSettings,
|
||||
};
|
||||
use super::{RenderTarget, primitives::cube::CubePrimitive};
|
||||
// use glam::{ivec3, IVec3, Mat4, Quat, Vec3};
|
||||
// use shipyard::{track, AllStoragesView, IntoIter, NonSendSync, Unique, UniqueView, UniqueViewMut, View};
|
||||
// use glium::{
|
||||
// draw_parameters::{
|
||||
// BackfaceCullingMode, Depth, DepthTest, PolygonMode
|
||||
// }, implement_vertex, uniform, uniforms::{
|
||||
// MagnifySamplerFilter, MinifySamplerFilter, Sampler, SamplerBehavior, SamplerWrapFunction
|
||||
// }, Blend, DrawParameters, Smooth, Surface
|
||||
// };
|
||||
// use crate::{
|
||||
// camera::Camera,
|
||||
// player::MainPlayer,
|
||||
// transform::Transform,
|
||||
// prefabs::{
|
||||
// ChunkShaderPrefab,
|
||||
// BlockTexturesPrefab,
|
||||
// ColoredShaderPrefab,
|
||||
// },
|
||||
// world::{
|
||||
// ChunkStorage,
|
||||
// ChunkMeshStorage,
|
||||
// chunk::CHUNK_SIZE,
|
||||
// }, settings::GameSettings,
|
||||
// };
|
||||
// use super::{RenderTarget, primitives::cube::CubePrimitive};
|
||||
|
||||
#[derive(Clone, Copy)]
|
||||
#[repr(C)]
|
||||
|
@ -32,217 +32,216 @@ pub struct ChunkVertex {
|
|||
pub uv: [f32; 2],
|
||||
pub tex_index: u8,
|
||||
}
|
||||
implement_vertex!(ChunkVertex, position, normal, uv, tex_index);
|
||||
|
||||
#[derive(Unique)]
|
||||
pub struct TransChunkQueue(pub Vec<IVec3>);
|
||||
// #[derive(Unique)]
|
||||
// pub struct TransChunkQueue(pub Vec<IVec3>);
|
||||
|
||||
pub fn init_trans_chunk_queue(storages: AllStoragesView) {
|
||||
storages.add_unique(TransChunkQueue(Vec::with_capacity(512)));
|
||||
}
|
||||
// pub fn init_trans_chunk_queue(storages: AllStoragesView) {
|
||||
// storages.add_unique(TransChunkQueue(Vec::with_capacity(512)));
|
||||
// }
|
||||
|
||||
fn draw_params(settings: &GameSettings) -> DrawParameters {
|
||||
DrawParameters {
|
||||
depth: Depth {
|
||||
test: DepthTest::IfLess,
|
||||
write: true,
|
||||
..Default::default()
|
||||
},
|
||||
multisampling: settings.msaa.is_some(),
|
||||
polygon_mode: PolygonMode::Fill, //Change to Line for wireframe
|
||||
backface_culling: BackfaceCullingMode::CullClockwise,
|
||||
..Default::default()
|
||||
}
|
||||
}
|
||||
// fn draw_params(settings: &GameSettings) -> DrawParameters {
|
||||
// DrawParameters {
|
||||
// depth: Depth {
|
||||
// test: DepthTest::IfLess,
|
||||
// write: true,
|
||||
// ..Default::default()
|
||||
// },
|
||||
// multisampling: settings.msaa.is_some(),
|
||||
// polygon_mode: PolygonMode::Fill, //Change to Line for wireframe
|
||||
// backface_culling: BackfaceCullingMode::CullClockwise,
|
||||
// ..Default::default()
|
||||
// }
|
||||
// }
|
||||
|
||||
fn texture_sampler<'a, T>(texture: &'a T, settings: &GameSettings) -> Sampler<'a, T> {
|
||||
Sampler(texture, SamplerBehavior {
|
||||
minify_filter: MinifySamplerFilter::LinearMipmapLinear,
|
||||
magnify_filter: MagnifySamplerFilter::Nearest,
|
||||
max_anisotropy: settings.max_anisotropy.unwrap_or_default(),
|
||||
wrap_function: (SamplerWrapFunction::Clamp, SamplerWrapFunction::Clamp, SamplerWrapFunction::Clamp),
|
||||
depth_texture_comparison: None,
|
||||
})
|
||||
}
|
||||
// fn texture_sampler<'a, T>(texture: &'a T, settings: &GameSettings) -> Sampler<'a, T> {
|
||||
// Sampler(texture, SamplerBehavior {
|
||||
// minify_filter: MinifySamplerFilter::LinearMipmapLinear,
|
||||
// magnify_filter: MagnifySamplerFilter::Nearest,
|
||||
// max_anisotropy: settings.max_anisotropy.unwrap_or_default(),
|
||||
// wrap_function: (SamplerWrapFunction::Clamp, SamplerWrapFunction::Clamp, SamplerWrapFunction::Clamp),
|
||||
// depth_texture_comparison: None,
|
||||
// })
|
||||
// }
|
||||
|
||||
pub fn draw_world(
|
||||
mut target: NonSendSync<UniqueViewMut<RenderTarget>>,
|
||||
chunks: UniqueView<ChunkStorage>,
|
||||
meshes: NonSendSync<UniqueView<ChunkMeshStorage>>,
|
||||
program: NonSendSync<UniqueView<ChunkShaderPrefab>>,
|
||||
texture: NonSendSync<UniqueView<BlockTexturesPrefab>>,
|
||||
transform: View<Transform>,
|
||||
camera: View<Camera>,
|
||||
settings: UniqueView<GameSettings>,
|
||||
mut trans_queue: UniqueViewMut<TransChunkQueue>,
|
||||
) {
|
||||
// let (camera, transform) = (&camera, &transform).iter().next().expect("No cameras in the scene");
|
||||
// let camera_position = transform.0.to_scale_rotation_translation().2;
|
||||
// pub fn draw_world(
|
||||
// mut target: NonSendSync<UniqueViewMut<RenderTarget>>,
|
||||
// chunks: UniqueView<ChunkStorage>,
|
||||
// meshes: NonSendSync<UniqueView<ChunkMeshStorage>>,
|
||||
// program: NonSendSync<UniqueView<ChunkShaderPrefab>>,
|
||||
// texture: NonSendSync<UniqueView<BlockTexturesPrefab>>,
|
||||
// transform: View<Transform>,
|
||||
// camera: View<Camera>,
|
||||
// settings: UniqueView<GameSettings>,
|
||||
// mut trans_queue: UniqueViewMut<TransChunkQueue>,
|
||||
// ) {
|
||||
// // let (camera, transform) = (&camera, &transform).iter().next().expect("No cameras in the scene");
|
||||
// // let camera_position = transform.0.to_scale_rotation_translation().2;
|
||||
|
||||
let camera = camera.iter().next().expect("No cameras in the scene");
|
||||
let view = camera.view_matrix.to_cols_array_2d();
|
||||
let perspective = camera.perspective_matrix.to_cols_array_2d();
|
||||
// let camera = camera.iter().next().expect("No cameras in the scene");
|
||||
// let view = camera.view_matrix.to_cols_array_2d();
|
||||
// let perspective = camera.perspective_matrix.to_cols_array_2d();
|
||||
|
||||
let draw_parameters = draw_params(&settings);
|
||||
let texture_sampler = texture_sampler(&texture.0, &settings);
|
||||
// let draw_parameters = draw_params(&settings);
|
||||
// let texture_sampler = texture_sampler(&texture.0, &settings);
|
||||
|
||||
for (&position, chunk) in &chunks.chunks {
|
||||
if let Some(key) = chunk.mesh_index {
|
||||
let mesh = meshes.get(key).expect("Mesh index pointing to nothing");
|
||||
let world_position = position.as_vec3() * CHUNK_SIZE as f32;
|
||||
// for (&position, chunk) in &chunks.chunks {
|
||||
// if let Some(key) = chunk.mesh_index {
|
||||
// let mesh = meshes.get(key).expect("Mesh index pointing to nothing");
|
||||
// let world_position = position.as_vec3() * CHUNK_SIZE as f32;
|
||||
|
||||
//Skip mesh if its empty
|
||||
if mesh.index_buffer.len() == 0 && mesh.trans_index_buffer.len() == 0 {
|
||||
continue
|
||||
}
|
||||
// //Skip mesh if its empty
|
||||
// if mesh.index_buffer.len() == 0 && mesh.trans_index_buffer.len() == 0 {
|
||||
// continue
|
||||
// }
|
||||
|
||||
//Frustum culling
|
||||
{
|
||||
let minp = world_position;
|
||||
let maxp = world_position + Vec3::splat(CHUNK_SIZE as f32);
|
||||
if !camera.frustum.is_box_visible(minp, maxp) {
|
||||
continue
|
||||
}
|
||||
}
|
||||
// //Frustum culling
|
||||
// {
|
||||
// let minp = world_position;
|
||||
// let maxp = world_position + Vec3::splat(CHUNK_SIZE as f32);
|
||||
// if !camera.frustum.is_box_visible(minp, maxp) {
|
||||
// continue
|
||||
// }
|
||||
// }
|
||||
|
||||
//Draw chunk mesh
|
||||
if mesh.index_buffer.len() > 0 {
|
||||
target.0.draw(
|
||||
&mesh.vertex_buffer,
|
||||
&mesh.index_buffer,
|
||||
&program.0,
|
||||
&uniform! {
|
||||
position_offset: world_position.to_array(),
|
||||
view: view,
|
||||
perspective: perspective,
|
||||
tex: texture_sampler,
|
||||
discard_alpha: true,
|
||||
},
|
||||
&draw_parameters
|
||||
).unwrap();
|
||||
}
|
||||
// //Draw chunk mesh
|
||||
// if mesh.index_buffer.len() > 0 {
|
||||
// target.0.draw(
|
||||
// &mesh.vertex_buffer,
|
||||
// &mesh.index_buffer,
|
||||
// &program.0,
|
||||
// &uniform! {
|
||||
// position_offset: world_position.to_array(),
|
||||
// view: view,
|
||||
// perspective: perspective,
|
||||
// tex: texture_sampler,
|
||||
// discard_alpha: true,
|
||||
// },
|
||||
// &draw_parameters
|
||||
// ).unwrap();
|
||||
// }
|
||||
|
||||
if mesh.trans_index_buffer.len() > 0 {
|
||||
trans_queue.0.push(position);
|
||||
}
|
||||
}
|
||||
}
|
||||
// if mesh.trans_index_buffer.len() > 0 {
|
||||
// trans_queue.0.push(position);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// const HALF_CHUNK_SIZE: IVec3 = IVec3::splat((CHUNK_SIZE >> 1) as i32);
|
||||
// trans_queue.0.sort_by_cached_key(|&pos| -(
|
||||
// (pos + HALF_CHUNK_SIZE).distance_squared(camera_position.as_ivec3())
|
||||
// ));
|
||||
}
|
||||
// // const HALF_CHUNK_SIZE: IVec3 = IVec3::splat((CHUNK_SIZE >> 1) as i32);
|
||||
// // trans_queue.0.sort_by_cached_key(|&pos| -(
|
||||
// // (pos + HALF_CHUNK_SIZE).distance_squared(camera_position.as_ivec3())
|
||||
// // ));
|
||||
// }
|
||||
|
||||
pub fn draw_world_trans(
|
||||
mut target: NonSendSync<UniqueViewMut<RenderTarget>>,
|
||||
chunks: UniqueView<ChunkStorage>,
|
||||
meshes: NonSendSync<UniqueView<ChunkMeshStorage>>,
|
||||
program: NonSendSync<UniqueView<ChunkShaderPrefab>>,
|
||||
texture: NonSendSync<UniqueView<BlockTexturesPrefab>>,
|
||||
camera: View<Camera>,
|
||||
settings: UniqueView<GameSettings>,
|
||||
mut trans_queue: UniqueViewMut<TransChunkQueue>,
|
||||
) {
|
||||
let camera = camera.iter().next().expect("No cameras in the scene");
|
||||
let view = camera.view_matrix.to_cols_array_2d();
|
||||
let perspective = camera.perspective_matrix.to_cols_array_2d();
|
||||
// pub fn draw_world_trans(
|
||||
// mut target: NonSendSync<UniqueViewMut<RenderTarget>>,
|
||||
// chunks: UniqueView<ChunkStorage>,
|
||||
// meshes: NonSendSync<UniqueView<ChunkMeshStorage>>,
|
||||
// program: NonSendSync<UniqueView<ChunkShaderPrefab>>,
|
||||
// texture: NonSendSync<UniqueView<BlockTexturesPrefab>>,
|
||||
// camera: View<Camera>,
|
||||
// settings: UniqueView<GameSettings>,
|
||||
// mut trans_queue: UniqueViewMut<TransChunkQueue>,
|
||||
// ) {
|
||||
// let camera = camera.iter().next().expect("No cameras in the scene");
|
||||
// let view = camera.view_matrix.to_cols_array_2d();
|
||||
// let perspective = camera.perspective_matrix.to_cols_array_2d();
|
||||
|
||||
let mut draw_parameters = draw_params(&settings);
|
||||
draw_parameters.blend = Blend::alpha_blending();
|
||||
draw_parameters.backface_culling = BackfaceCullingMode::CullingDisabled;
|
||||
draw_parameters.smooth = Some(Smooth::Fastest);
|
||||
// let mut draw_parameters = draw_params(&settings);
|
||||
// draw_parameters.blend = Blend::alpha_blending();
|
||||
// draw_parameters.backface_culling = BackfaceCullingMode::CullingDisabled;
|
||||
// draw_parameters.smooth = Some(Smooth::Fastest);
|
||||
|
||||
let texture_sampler = texture_sampler(&texture.0, &settings);
|
||||
// let texture_sampler = texture_sampler(&texture.0, &settings);
|
||||
|
||||
for position in trans_queue.0.drain(..).rev() {
|
||||
let world_position = position.as_vec3() * CHUNK_SIZE as f32;
|
||||
let mesh_idx = chunks.chunks[&position].mesh_index.expect("No mesh index");
|
||||
let mesh = meshes.get(mesh_idx).expect("Mesh index pointing to nothing");
|
||||
target.0.draw(
|
||||
&mesh.trans_vertex_buffer,
|
||||
&mesh.trans_index_buffer,
|
||||
&program.0,
|
||||
&uniform! {
|
||||
position_offset: world_position.to_array(),
|
||||
view: view,
|
||||
perspective: perspective,
|
||||
tex: texture_sampler,
|
||||
discard_alpha: false,
|
||||
},
|
||||
&draw_parameters
|
||||
).unwrap();
|
||||
}
|
||||
}
|
||||
// for position in trans_queue.0.drain(..).rev() {
|
||||
// let world_position = position.as_vec3() * CHUNK_SIZE as f32;
|
||||
// let mesh_idx = chunks.chunks[&position].mesh_index.expect("No mesh index");
|
||||
// let mesh = meshes.get(mesh_idx).expect("Mesh index pointing to nothing");
|
||||
// target.0.draw(
|
||||
// &mesh.trans_vertex_buffer,
|
||||
// &mesh.trans_index_buffer,
|
||||
// &program.0,
|
||||
// &uniform! {
|
||||
// position_offset: world_position.to_array(),
|
||||
// view: view,
|
||||
// perspective: perspective,
|
||||
// tex: texture_sampler,
|
||||
// discard_alpha: false,
|
||||
// },
|
||||
// &draw_parameters
|
||||
// ).unwrap();
|
||||
// }
|
||||
// }
|
||||
|
||||
pub fn draw_current_chunk_border(
|
||||
mut target: NonSendSync<UniqueViewMut<RenderTarget>>,
|
||||
player: View<MainPlayer>,
|
||||
transforms: View<Transform, track::All>,
|
||||
buffers: NonSendSync<UniqueView<CubePrimitive>>,
|
||||
program: NonSendSync<UniqueView<ColoredShaderPrefab>>,
|
||||
camera: View<Camera>,
|
||||
settings: UniqueView<GameSettings>,
|
||||
) {
|
||||
if cfg!(target_os = "android") {
|
||||
return
|
||||
}
|
||||
if !settings.debug_draw_current_chunk_border {
|
||||
return
|
||||
}
|
||||
let camera = camera.iter().next().expect("No cameras in the scene");
|
||||
let view = camera.view_matrix.to_cols_array_2d();
|
||||
let perspective = camera.perspective_matrix.to_cols_array_2d();
|
||||
let (_, &player_transform) = (&player, &transforms).iter().next().expect("No player");
|
||||
let (_, _, player_position) = player_transform.0.to_scale_rotation_translation();
|
||||
let player_in_chunk = ivec3(
|
||||
(player_position.x as i32).div_euclid(CHUNK_SIZE as i32),
|
||||
(player_position.y as i32).div_euclid(CHUNK_SIZE as i32),
|
||||
(player_position.z as i32).div_euclid(CHUNK_SIZE as i32),
|
||||
);
|
||||
let world_position = player_in_chunk.as_vec3() * CHUNK_SIZE as f32;
|
||||
target.0.draw(
|
||||
&buffers.0,
|
||||
&buffers.1,
|
||||
&program.0,
|
||||
&uniform! {
|
||||
model: Mat4::from_scale_rotation_translation(
|
||||
Vec3::splat(CHUNK_SIZE as f32),
|
||||
Quat::default(),
|
||||
world_position
|
||||
).to_cols_array_2d(),
|
||||
color: [0.25f32; 4],
|
||||
view: view,
|
||||
perspective: perspective,
|
||||
},
|
||||
&DrawParameters {
|
||||
depth: Depth {
|
||||
test: DepthTest::IfLess,
|
||||
..Default::default()
|
||||
},
|
||||
blend: Blend::alpha_blending(),
|
||||
..Default::default()
|
||||
}
|
||||
).unwrap();
|
||||
target.0.draw(
|
||||
&buffers.0,
|
||||
&buffers.1,
|
||||
&program.0,
|
||||
&uniform! {
|
||||
model: Mat4::from_scale_rotation_translation(
|
||||
Vec3::splat(CHUNK_SIZE as f32),
|
||||
Quat::default(),
|
||||
world_position
|
||||
).to_cols_array_2d(),
|
||||
color: [0.0f32; 4],
|
||||
view: view,
|
||||
perspective: perspective,
|
||||
},
|
||||
&DrawParameters {
|
||||
polygon_mode: PolygonMode::Point,
|
||||
line_width: Some(2.),
|
||||
point_size: Some(5.),
|
||||
..Default::default()
|
||||
}
|
||||
).unwrap();
|
||||
}
|
||||
// pub fn draw_current_chunk_border(
|
||||
// mut target: NonSendSync<UniqueViewMut<RenderTarget>>,
|
||||
// player: View<MainPlayer>,
|
||||
// transforms: View<Transform, track::All>,
|
||||
// buffers: NonSendSync<UniqueView<CubePrimitive>>,
|
||||
// program: NonSendSync<UniqueView<ColoredShaderPrefab>>,
|
||||
// camera: View<Camera>,
|
||||
// settings: UniqueView<GameSettings>,
|
||||
// ) {
|
||||
// if cfg!(target_os = "android") {
|
||||
// return
|
||||
// }
|
||||
// if !settings.debug_draw_current_chunk_border {
|
||||
// return
|
||||
// }
|
||||
// let camera = camera.iter().next().expect("No cameras in the scene");
|
||||
// let view = camera.view_matrix.to_cols_array_2d();
|
||||
// let perspective = camera.perspective_matrix.to_cols_array_2d();
|
||||
// let (_, &player_transform) = (&player, &transforms).iter().next().expect("No player");
|
||||
// let (_, _, player_position) = player_transform.0.to_scale_rotation_translation();
|
||||
// let player_in_chunk = ivec3(
|
||||
// (player_position.x as i32).div_euclid(CHUNK_SIZE as i32),
|
||||
// (player_position.y as i32).div_euclid(CHUNK_SIZE as i32),
|
||||
// (player_position.z as i32).div_euclid(CHUNK_SIZE as i32),
|
||||
// );
|
||||
// let world_position = player_in_chunk.as_vec3() * CHUNK_SIZE as f32;
|
||||
// target.0.draw(
|
||||
// &buffers.0,
|
||||
// &buffers.1,
|
||||
// &program.0,
|
||||
// &uniform! {
|
||||
// model: Mat4::from_scale_rotation_translation(
|
||||
// Vec3::splat(CHUNK_SIZE as f32),
|
||||
// Quat::default(),
|
||||
// world_position
|
||||
// ).to_cols_array_2d(),
|
||||
// color: [0.25f32; 4],
|
||||
// view: view,
|
||||
// perspective: perspective,
|
||||
// },
|
||||
// &DrawParameters {
|
||||
// depth: Depth {
|
||||
// test: DepthTest::IfLess,
|
||||
// ..Default::default()
|
||||
// },
|
||||
// blend: Blend::alpha_blending(),
|
||||
// ..Default::default()
|
||||
// }
|
||||
// ).unwrap();
|
||||
// target.0.draw(
|
||||
// &buffers.0,
|
||||
// &buffers.1,
|
||||
// &program.0,
|
||||
// &uniform! {
|
||||
// model: Mat4::from_scale_rotation_translation(
|
||||
// Vec3::splat(CHUNK_SIZE as f32),
|
||||
// Quat::default(),
|
||||
// world_position
|
||||
// ).to_cols_array_2d(),
|
||||
// color: [0.0f32; 4],
|
||||
// view: view,
|
||||
// perspective: perspective,
|
||||
// },
|
||||
// &DrawParameters {
|
||||
// polygon_mode: PolygonMode::Point,
|
||||
// line_width: Some(2.),
|
||||
// point_size: Some(5.),
|
||||
// ..Default::default()
|
||||
// }
|
||||
// ).unwrap();
|
||||
// }
|
||||
|
|
|
@ -7,7 +7,7 @@ use hui::{
|
|||
UiElementExt,
|
||||
},
|
||||
layout::{Alignment, Direction},
|
||||
frame_rect, size,
|
||||
rect_frame, size,
|
||||
};
|
||||
use shipyard::{UniqueView, UniqueViewMut, Workload, NonSendSync, IntoWorkload};
|
||||
use winit::keyboard::KeyCode;
|
||||
|
@ -28,7 +28,7 @@ pub fn loading_screen_base(bg_alpha: f32, xui: impl FnOnce(&mut ElementList)) ->
|
|||
.with_children(|ui| {
|
||||
Container::default()
|
||||
.with_size(size!(400, auto))
|
||||
.with_background(frame_rect! {
|
||||
.with_background(rect_frame! {
|
||||
color: (0.2, 0.2, 0.2),
|
||||
corner_radius: 8.
|
||||
})
|
||||
|
@ -63,11 +63,11 @@ fn render_loading_ui(
|
|||
ProgressBar::default()
|
||||
.with_value(value)
|
||||
.with_size(size!(100%, 15))
|
||||
.with_background(frame_rect! {
|
||||
.with_background(rect_frame! {
|
||||
color: (0.1, 0.1, 0.1),
|
||||
corner_radius: 2.
|
||||
})
|
||||
.with_foreground(frame_rect! {
|
||||
.with_foreground(rect_frame! {
|
||||
color: (0.4, 0.4, 1.0),
|
||||
corner_radius: 2.
|
||||
})
|
||||
|
|
|
@ -2,7 +2,7 @@ use hui::{
|
|||
element::{br::Break, container::Container, slider::Slider, text::Text, UiElementExt},
|
||||
layout::{Alignment, Direction},
|
||||
signal::Signal,
|
||||
frame_rect, size,
|
||||
rect_frame, size,
|
||||
};
|
||||
use shipyard::{NonSendSync, UniqueView, UniqueViewMut};
|
||||
use winit::keyboard::KeyCode;
|
||||
|
@ -34,7 +34,7 @@ pub fn render_settings_ui(
|
|||
.with_align(Alignment::Center)
|
||||
.with_children(|ui| {
|
||||
Container::default()
|
||||
.with_background(frame_rect! {
|
||||
.with_background(rect_frame! {
|
||||
color: (0.2, 0.2, 0.2),
|
||||
corner_radius: 8.
|
||||
})
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
use std::sync::Arc;
|
||||
use glam::IVec3;
|
||||
use atomic::Atomic;
|
||||
use glium::{VertexBuffer, IndexBuffer};
|
||||
use kubi_shared::worldgen::AbortState;
|
||||
use crate::rendering::world::ChunkVertex;
|
||||
use crate::rendering::{world::ChunkVertex, BufferPair};
|
||||
|
||||
pub use kubi_shared::chunk::{CHUNK_SIZE, BlockData};
|
||||
|
||||
|
@ -18,10 +17,8 @@ impl ChunkData {
|
|||
}
|
||||
|
||||
pub struct ChunkMesh {
|
||||
pub vertex_buffer: VertexBuffer<ChunkVertex>,
|
||||
pub index_buffer: IndexBuffer<u32>,
|
||||
pub trans_vertex_buffer: VertexBuffer<ChunkVertex>,
|
||||
pub trans_index_buffer: IndexBuffer<u32>,
|
||||
pub main: BufferPair,
|
||||
pub trans: BufferPair,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Default)]
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
use std::sync::Arc;
|
||||
use atomic::{Atomic, Ordering};
|
||||
use glam::{IVec3, ivec3};
|
||||
use glium::{VertexBuffer, IndexBuffer, index::PrimitiveType};
|
||||
use kubi_shared::{networking::{channels::Channel, messages::ClientToServerMessage}, worldgen::AbortState};
|
||||
use shipyard::{View, UniqueView, UniqueViewMut, IntoIter, Workload, IntoWorkload, NonSendSync, track};
|
||||
use uflow::SendMode;
|
||||
|
@ -327,21 +326,23 @@ fn process_completed_tasks(
|
|||
|
||||
//apply the mesh
|
||||
//TODO: Skip if mesh is empty? (i.e. set to None)
|
||||
let mesh = ChunkMesh {
|
||||
vertex_buffer: VertexBuffer::immutable(&renderer.display, &vertices).unwrap(),
|
||||
index_buffer: IndexBuffer::immutable(&renderer.display, PrimitiveType::TrianglesList, &indices).unwrap(),
|
||||
trans_vertex_buffer: VertexBuffer::immutable(&renderer.display, &trans_vertices).unwrap(),
|
||||
trans_index_buffer: IndexBuffer::immutable(&renderer.display, PrimitiveType::TrianglesList, &trans_indices).unwrap(),
|
||||
};
|
||||
if let Some(index) = chunk.mesh_index {
|
||||
meshes.update(index, mesh).expect("Mesh update failed");
|
||||
} else {
|
||||
let mesh_index = meshes.insert(mesh);
|
||||
chunk.mesh_index = Some(mesh_index);
|
||||
}
|
||||
unimplemented!();
|
||||
|
||||
//update chunk state
|
||||
chunk.current_state = CurrentChunkState::Rendered;
|
||||
// let mesh = ChunkMesh {
|
||||
// vertex_buffer: VertexBuffer::immutable(&renderer.display, &vertices).unwrap(),
|
||||
// index_buffer: IndexBuffer::immutable(&renderer.display, PrimitiveType::TrianglesList, &indices).unwrap(),
|
||||
// trans_vertex_buffer: VertexBuffer::immutable(&renderer.display, &trans_vertices).unwrap(),
|
||||
// trans_index_buffer: IndexBuffer::immutable(&renderer.display, PrimitiveType::TrianglesList, &trans_indices).unwrap(),
|
||||
// };
|
||||
// if let Some(index) = chunk.mesh_index {
|
||||
// meshes.update(index, mesh).expect("Mesh update failed");
|
||||
// } else {
|
||||
// let mesh_index = meshes.insert(mesh);
|
||||
// chunk.mesh_index = Some(mesh_index);
|
||||
// }
|
||||
|
||||
// //update chunk state
|
||||
// chunk.current_state = CurrentChunkState::Rendered;
|
||||
|
||||
//increase ops counter
|
||||
ops += 1;
|
||||
|
|
Loading…
Reference in a new issue