Compare commits

..

No commits in common. "762071736886309e5e6e3e5e2798bfef524d8714" and "8e39fc24fd0c1ad16a39bb76ef1c768c2fd874d9" have entirely different histories.

14 changed files with 78 additions and 151 deletions

4
Cargo.lock generated
View file

@ -1190,6 +1190,10 @@ dependencies = [
"log",
]
[[package]]
name = "kubi-pool"
version = "0.0.0"
[[package]]
name = "kubi-server"
version = "0.0.0"

View file

@ -4,6 +4,7 @@ members = [
"kubi-server",
"kubi-shared",
"kubi-logging",
"kubi-pool"
]
default-members = ["kubi"]
resolver = "2"

View file

@ -118,12 +118,15 @@ name = "Kubi Server" # server name
<h2>"In-house" libraries</h2>
- [`hui`, `hui-glium`, `hui-winit`](https://github.com/griffi-gh/hui): semi-imm.mode backend-agnostic ui system\
- [`hui`](https://github.com/griffi-gh/hui): semi-imm.mode backend-agnostic ui system\
mostly ready to use, it has already replaced the Kubi legacy ui
- [`kubi-ui-glium`](kubi-ui-glium) Glium-based backend for `kubi-ui`
- [`kubi-pool`](kubi-pool): very early work-in-progress work-stealing threadpool system\
aiming to replace `rayon` threadpool that's currently used inside the kubi client (for more control over task priority)
- [`kubi-logging`](kubi-logging) fancy-ass custom formatter for `env-logger`
deprecated:
- ~~`kubi-udp`~~ eventually got replaced by `uflow` (https://github.com/lowquark/uflow) in #5
- ~~`kubi-pool`~~ decided there's no need to replace rayon for now
~~`kubi-udp`~~ was a huge pita to work with and eventually got replaced by `uflow` (https://github.com/lowquark/uflow) in #5
<h6 align="right"><i>~ uwu</i></h6>

7
kubi-pool/Cargo.toml Normal file
View file

@ -0,0 +1,7 @@
[package]
name = "kubi-pool"
version = "0.0.0"
edition = "2021"
publish = false
[dependencies]

33
kubi-pool/src/lib.rs Normal file
View file

@ -0,0 +1,33 @@
use std::{thread::JoinHandle, collections::VecDeque};
pub struct KubiPool<T, R> {
callback: fn(T) -> R,
threads: Vec<JoinHandle<()>>,
}
struct Task<T> {
priority: u8,
data: T,
}
fn task_loop<T, R>() {
let tasks = VecDeque::<Task<T>>::new();
loop {
};
}
impl<T: 'static, R: 'static> KubiPool<T, R> {
pub fn new(threads: usize, callback: fn(T) -> R) -> Self {
Self {
callback,
threads: (0..threads).map(|_| {
std::thread::spawn(move || task_loop::<T, R>())
}).collect(),
}
}
pub fn resize(&mut self, threads: usize) {
}
}

View file

@ -1,4 +1,3 @@
use glam::{vec4, Vec4};
use serde::{Serialize, Deserialize};
use strum::EnumIter;
use num_enum::TryFromPrimitive;
@ -54,7 +53,6 @@ impl Block {
collision: CollisionType::None,
raycast_collision: false,
drops: None,
submerge: None,
},
Self::Marker => BlockDescriptor {
name: "marker",
@ -62,7 +60,6 @@ impl Block {
collision: CollisionType::None,
raycast_collision: false,
drops: None,
submerge: None,
},
Self::Stone => BlockDescriptor {
name: "stone",
@ -73,7 +70,6 @@ impl Block {
collision: CollisionType::Solid,
raycast_collision: true,
drops: None,
submerge: None,
},
Self::Dirt => BlockDescriptor {
name: "dirt",
@ -84,7 +80,6 @@ impl Block {
collision: CollisionType::Solid,
raycast_collision: true,
drops: None,
submerge: None,
},
Self::Grass => BlockDescriptor {
name: "grass",
@ -99,7 +94,6 @@ impl Block {
collision: CollisionType::Solid,
raycast_collision: true,
drops: None,
submerge: None,
},
Self::Sand => BlockDescriptor {
name: "sand",
@ -110,7 +104,6 @@ impl Block {
collision: CollisionType::Solid,
raycast_collision: true,
drops: None,
submerge: None,
},
Self::Cobblestone => BlockDescriptor {
name: "cobblestone",
@ -121,7 +114,6 @@ impl Block {
collision: CollisionType::Solid,
raycast_collision: true,
drops: None,
submerge: None,
},
Self::TallGrass => BlockDescriptor {
name: "tall grass",
@ -129,7 +121,6 @@ impl Block {
collision: CollisionType::None,
raycast_collision: true,
drops: None,
submerge: None,
},
Self::Planks => BlockDescriptor {
name: "planks",
@ -140,7 +131,6 @@ impl Block {
collision: CollisionType::Solid,
raycast_collision: true,
drops: None,
submerge: None,
},
Self::Torch => BlockDescriptor {
name: "torch",
@ -148,7 +138,6 @@ impl Block {
collision: CollisionType::None,
raycast_collision: true,
drops: None,
submerge: None,
},
Self::Wood => BlockDescriptor {
name: "leaf",
@ -159,7 +148,6 @@ impl Block {
collision: CollisionType::Solid,
raycast_collision: true,
drops: None,
submerge: None,
},
Self::Leaf => BlockDescriptor {
name: "leaf",
@ -170,7 +158,6 @@ impl Block {
collision: CollisionType::Solid,
raycast_collision: true,
drops: None,
submerge: None,
},
Self::Water => BlockDescriptor {
name: "water",
@ -181,7 +168,6 @@ impl Block {
collision: CollisionType::None,
raycast_collision: true,
drops: None,
submerge: Some(vec4(0., 0., 0.25, 0.75)),
},
}
}
@ -194,7 +180,6 @@ pub struct BlockDescriptor {
pub collision: CollisionType,
pub raycast_collision: bool,
pub drops: Option<Item>,
pub submerge: Option<Vec4>,
}
#[derive(Clone, Copy, Debug)]

View file

@ -1,10 +0,0 @@
#version 300 es
precision highp float;
out vec4 out_color;
uniform vec4 color;
void main() {
out_color = color;
}

View file

@ -1,9 +0,0 @@
#version 300 es
precision highp float;
in vec2 position;
void main() {
gl_Position = vec4(position, 0.0, 1.0);
}

View file

@ -76,7 +76,6 @@ use rendering::{
world::{draw_world, draw_current_chunk_border},
selection_box::render_selection_box,
entities::render_entities,
sumberge::render_submerged_view,
};
use block_placement::update_block_placement;
use delta_time::{DeltaTime, init_delta_time};
@ -179,7 +178,6 @@ fn render() -> Workload {
draw_current_chunk_border,
render_selection_box,
render_entities,
render_submerged_view,
).into_sequential_workload().run_if(is_ingame),
kubi_ui_draw,
).into_sequential_workload()

View file

@ -51,10 +51,6 @@ pub struct ChunkShaderPrefab(pub Program);
#[repr(transparent)]
pub struct ColoredShaderPrefab(pub Program);
#[derive(Unique)]
#[repr(transparent)]
pub struct Colored2ShaderPrefab(pub Program);
#[derive(Unique)]
#[repr(transparent)]
pub struct UiFontPrefab(pub FontHandle);
@ -102,14 +98,6 @@ pub fn load_prefabs(
&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");

View file

@ -22,7 +22,6 @@ pub mod primitives;
pub mod world;
pub mod selection_box;
pub mod entities;
pub mod sumberge;
#[derive(Unique)]
#[repr(transparent)]

View file

@ -1,30 +1,27 @@
use shipyard::{Workload, IntoWorkload};
use glium::implement_vertex;
pub mod cube;
pub mod rect;
pub mod stri;
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 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()
}
use shipyard::{Workload, IntoWorkload};
use glium::implement_vertex;
pub mod cube;
pub mod rect;
use cube::init_cube_primitive;
use rect::init_rect_primitive;
#[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);
pub fn init_primitives() -> Workload {
(
init_cube_primitive,
init_rect_primitive,
).into_sequential_workload()
}

View file

@ -1,30 +0,0 @@
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>);
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));
}

View file

@ -1,39 +0,0 @@
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 };
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();
}