Compare commits

..

No commits in common. "4948d85e05b9f151537da2bded5bde6cfc5be643" and "9f5b974f82f080c7c5dce2627a68b948691f5bfd" have entirely different histories.

15 changed files with 1118 additions and 1107 deletions

635
Cargo.lock generated

File diff suppressed because it is too large Load diff

View file

@ -33,8 +33,3 @@ opt-level = 3
[profile.dev.package.rayon]
opt-level = 3
#this is cursed as fuck
#enabling debug assertions here causes the game to abort
[profile.dev.package.android-activity]
debug-assertions = false

View file

@ -8,10 +8,10 @@ publish = false
kubi-shared = { path = "../kubi-shared" }
kubi-logging = { path = "../kubi-logging" }
log = "0.4"
shipyard = { git = "https://github.com/leudz/shipyard", rev = "9099b990e", default-features = false, features = ["std", "proc", "thread_local"] }
shipyard = { git = "https://github.com/leudz/shipyard", rev = "8ef90ea6c4d1eb6c9cb0988f0d2f873f75044d49", default-features = false, features = ["std", "proc", "thread_local"] }
serde = { version = "1.0", default-features = false, features = ["alloc", "derive"] }
toml = "0.8"
glam = { version = "0.25", features = ["debug-glam-assert", "fast-math"] }
glam = { version = "0.24", features = ["debug-glam-assert", "fast-math"] }
hashbrown = "0.14"
nohash-hasher = "0.2"
anyhow = "1.0"

View file

@ -5,9 +5,9 @@ edition = "2021"
publish = false
[dependencies]
glam = { version = "0.25", features = ["debug-glam-assert", "fast-math", "serde"] }
shipyard = { git = "https://github.com/leudz/shipyard", rev = "9099b990e", default-features = false, features = ["std"] }
strum = { version = "0.26", features = ["derive"] }
glam = { version = "0.24", features = ["debug-glam-assert", "fast-math", "serde"] }
shipyard = { git = "https://github.com/leudz/shipyard", rev = "8ef90ea6c4d1eb6c9cb0988f0d2f873f75044d49", default-features = false, features = ["std"] }
strum = { version = "0.25", features = ["derive"] }
num_enum = "0.7"
postcard = { version = "1.0", features = ["alloc"] }
serde = { version = "1.0", default-features = false, features = ["alloc", "derive"] }

View file

@ -10,7 +10,7 @@ publish = false
kubi-ui = { path = "../kubi-ui" }
kubi-ui-glium = { path = "../kubi-ui-glium" }
kubi-logging = { path = "../kubi-logging" }
glium = { git = "https://github.com/glium/glium", rev = "a352c667" }
glium = { git = "https://github.com/glium/glium", rev = "968fc92378caf" }
winit = "0.29"
glam = "0.25"
glam = "0.24"
log = "0.4"

View file

@ -7,6 +7,6 @@ publish = false
[dependencies]
kubi-ui = { path = "../kubi-ui", default-features = false }
#kubi-ui = { path = "../kubi-ui" }
glium = { git = "https://github.com/glium/glium", rev = "a352c667" }
glam = "0.25"
glium = { git = "https://github.com/glium/glium", rev = "968fc92378caf" }
glam = "0.24"
log = "0.4"

View file

@ -50,8 +50,8 @@ impl BufferPair {
pub fn new<F: Facade>(facade: &F) -> Self {
log::debug!("init ui buffers...");
Self {
vertex_buffer: VertexBuffer::empty_dynamic(facade, 1024).unwrap(),
index_buffer: IndexBuffer::empty_dynamic(facade, PrimitiveType::TrianglesList, 1024).unwrap(),
vertex_buffer: VertexBuffer::empty_persistent(facade, 1024).unwrap(),
index_buffer: IndexBuffer::empty_persistent(facade, PrimitiveType::TrianglesList, 1024).unwrap(),
vertex_count: 0,
index_count: 0,
}
@ -68,13 +68,13 @@ impl BufferPair {
let new_idx_size = (need_idx + 1).next_power_of_two();
log::debug!("resizing buffers: vtx {} -> {}, idx {} -> {}", current_vtx_size, new_vtx_size, current_idx_size, new_idx_size);
if current_vtx_size != new_vtx_size {
self.vertex_buffer = VertexBuffer::empty_dynamic(
self.vertex_buffer = VertexBuffer::empty_persistent(
self.vertex_buffer.get_context(),
new_vtx_size
).unwrap();
}
if current_idx_size != new_idx_size {
self.index_buffer = IndexBuffer::empty_dynamic(
self.index_buffer = IndexBuffer::empty_persistent(
self.index_buffer.get_context(),
PrimitiveType::TrianglesList,
new_idx_size

View file

@ -7,7 +7,7 @@ publish = false
[dependencies]
hashbrown = "0.14"
nohash-hasher = "0.2"
glam = "0.25"
glam = "0.24"
fontdue = "0.8"
rect_packer = "0.2"
log = "0.4"

View file

@ -14,18 +14,18 @@ kubi-logging = { path = "../kubi-logging" }
kubi-ui = { path = "../kubi-ui" }
kubi-ui-glium = { path = "../kubi-ui-glium" }
log = "0.4"
glium = { git = "https://github.com/glium/glium", rev = "a352c667" }
glium = { git = "https://github.com/glium/glium", rev = "968fc92378caf" }
glutin = "0.31"
winit = { version = "0.29", features = ["android-native-activity"] }
glutin-winit = "0.4"
raw-window-handle = "=0.5.*"
glam = { version = "0.25", features = ["debug-glam-assert", "fast-math"] }
raw-window-handle = "0.5"
glam = { version = "0.24", features = ["debug-glam-assert", "fast-math"] }
image = { version = "0.24", default_features = false, features = ["png"] }
strum = { version = "0.26", features = ["derive"] }
strum = { version = "0.25", features = ["derive"] }
hashbrown = "0.14"
nohash-hasher = "0.2"
rayon = "1.7"
shipyard = { git = "https://github.com/leudz/shipyard", rev = "9099b990e", default-features = false, features = ["std", "proc", "thread_local"] }
shipyard = { git = "https://github.com/leudz/shipyard", rev = "8ef90ea6c4d1eb6c9cb0988f0d2f873f75044d49", default-features = false, features = ["std", "proc", "thread_local"] }
anyhow = "1.0"
flume = "0.11"
gilrs = { version = "0.10", default_features = false, features = ["xinput"] }
@ -37,7 +37,7 @@ tinyset = "0.4"
serde_json = { version = "1.0", optional = true } #only used for `generate_visualizer_data`
[target.'cfg(target_os = "android")'.dependencies]
android-activity = "^0.5.2"
android-activity = "0.5"
ndk = "0.8"
[target.'cfg(target_os = "windows")'.dependencies]
@ -59,14 +59,15 @@ assets = "../assets"
apk_name = "kubi"
theme = "@android:style/Theme.DeviceDefault.NoActionBar.Fullscreen"
label = "Kubi"
orientation = "sensorLandscape"
[package.metadata.android.sdk]
min_sdk_version = 16
target_sdk_version = 30
[[package.metadata.android.uses_feature]]
glEsVersion = 0x00030000
required = true
glEsVersion = 0x00030000
[[package.metadata.android.uses_feature]]
name = "android.hardware.touchscreen.multitouch"
@ -77,13 +78,6 @@ name = "android.hardware.touchscreen.multitouch.distinct"
required = true
[package.metadata.android.application.activity]
label = "Kubi"
launch_mode = "singleTop"
orientation = "sensorLandscape"
config_changes = "orientation|keyboardHidden|screenLayout|screenSize"
exported = true
resizeable_activity = true
# [package.metadata.android.signing.release]
# path = "$HOME/.android/debug.keystore"
# keystore_password = "android"

View file

@ -1,52 +0,0 @@
//TODO client-side physics
//TODO move this to shared
use glam::{Mat4, Vec3};
use kubi_shared::transform::Transform;
use shipyard::{track, AllStoragesView, Component, IntoIter, Unique, UniqueView, View, ViewMut};
use crate::delta_time::DeltaTime;
#[derive(Unique)]
pub struct GlobalClPhysicsConfig {
pub gravity: Vec3,
}
#[derive(Component)]
pub struct ClPhysicsActor {
pub forces: Vec3,
pub velocity: Vec3,
pub terminal_velocity: f32,
//TODO: this should be configurable per block
pub friction_agains_ground: f32,
}
impl Default for ClPhysicsActor {
fn default() -> Self {
Self {
forces: Vec3::ZERO,
velocity: Vec3::ZERO,
terminal_velocity: 40.,
friction_agains_ground: 0.5,
}
}
}
pub fn init_client_physics(
storages: AllStoragesView,
) {
storages.add_unique(GlobalClPhysicsConfig {
gravity: Vec3::new(0., -9.8, 0.),
});
}
pub fn update_client_physics_late(
controllers: View<ClPhysicsActor>,
mut transforms: ViewMut<Transform, track::All>,
dt: UniqueView<DeltaTime>,
phy_conf: UniqueView<GlobalClPhysicsConfig>,
) {
// for (_, mut transform) in (&controllers, &mut transforms).iter() {
// let (scale, rotation, mut translation) = transform.0.to_scale_rotation_translation();
// translation.y -= dt.0.as_secs_f32() * 100.;
// transform.0 = Mat4::from_scale_rotation_translation(scale, rotation, translation);
// }
}

View file

@ -1,6 +1,6 @@
use glam::UVec2;
use shipyard::{World, Component, AllStoragesViewMut, SparseSet, NonSendSync, UniqueView};
use winit::event::{Event, DeviceEvent, DeviceId, WindowEvent, Touch};
use winit::event::{Event, DeviceEvent, DeviceId, WindowEvent, Touch, RawKeyEvent, TouchPhase};
use crate::rendering::Renderer;
pub mod player_actions;
@ -24,7 +24,7 @@ pub struct TouchEvent(pub Touch);
#[derive(Component, Clone, Copy, Debug, Default)]
pub struct WindowResizedEvent(pub UVec2);
pub fn process_winit_events(world: &mut World, event: &Event<()>) {
pub fn process_glutin_events(world: &mut World, event: &Event<()>) {
#[allow(clippy::collapsible_match, clippy::single_match)]
match event {
Event::WindowEvent { window_id: _, event } => match event {

View file

@ -45,9 +45,8 @@ fn update_movement(
let movement = inputs.movement * 30. * dt.0.as_secs_f32();
for (_, mut transform) in (&controllers, &mut transforms).iter() {
let (scale, rotation, mut translation) = transform.0.to_scale_rotation_translation();
let rotation_norm = rotation.normalize();
translation += (rotation_norm * Vec3::NEG_Z).normalize() * movement.y;
translation += (rotation_norm * Vec3::X).normalize() * movement.x;
transform.0 = Mat4::from_scale_rotation_translation(scale, rotation_norm, translation);
translation += (rotation * Vec3::NEG_Z).normalize() * movement.y;
translation += (rotation * Vec3::X).normalize() * movement.x;
transform.0 = Mat4::from_scale_rotation_translation(scale, rotation, translation);
}
}

View file

@ -37,7 +37,6 @@ pub(crate) mod loading_screen;
pub(crate) mod connecting_screen;
pub(crate) mod fixed_timestamp;
pub(crate) mod filesystem;
pub(crate) mod client_physics;
use world::{
init_game_world,
@ -52,7 +51,7 @@ use settings::{load_settings, GameSettings};
use camera::compute_cameras;
use events::{
clear_events,
process_winit_events,
process_glutin_events,
initial_resize_event,
player_actions::generate_move_events,
};
@ -82,7 +81,6 @@ use loading_screen::update_loading_screen;
use connecting_screen::switch_to_loading_if_connected;
use fixed_timestamp::init_fixed_timestamp_storage;
use filesystem::AssetManager;
use client_physics::{init_client_physics, update_client_physics_late};
/// stuff required to init the renderer and other basic systems
fn pre_startup() -> Workload {
@ -106,7 +104,6 @@ fn startup() -> Workload {
init_input,
insert_control_flow_unique,
init_delta_time,
init_client_physics,
).into_sequential_workload()
}
@ -134,7 +131,6 @@ fn update() -> Workload {
).into_sequential_workload().run_if(is_ingame_or_loading),
(
update_controllers,
update_client_physics_late,
generate_move_events,
update_raycasts,
update_block_placement,
@ -183,13 +179,9 @@ pub fn android_main(app: android_activity::AndroidApp) {
}
#[no_mangle]
pub fn kubi_main(
#[cfg(target_os = "android")]
app: android_activity::AndroidApp
) {
pub fn kubi_main(#[cfg(target_os = "android")] app: android_activity::AndroidApp) {
//Attach console on release builds on windows
#[cfg(all(windows, not(debug_assertions)))]
attach_console();
#[cfg(all(windows, not(debug_assertions)))] attach_console();
//Print version
println!("{:─^54}", format!("[ ▄▀ Kubi client v. {} ]", env!("CARGO_PKG_VERSION")));
@ -261,7 +253,7 @@ pub fn kubi_main(
window_target.set_control_flow(ControlFlow::Poll);
process_winit_events(&mut world, &event);
process_glutin_events(&mut world, &event);
#[allow(clippy::collapsible_match, clippy::single_match)]
match event {

View file

@ -10,11 +10,10 @@ use kubi_shared::{
}
};
use crate::{
camera::Camera,
client_physics::ClPhysicsActor,
fly_controller::FlyController,
transform::Transform,
world::raycast::LookingAtBlock
camera::Camera,
fly_controller::FlyController,
world::raycast::LookingAtBlock,
};
#[derive(Component)]
@ -24,7 +23,7 @@ pub fn spawn_player (
mut storages: AllStoragesViewMut,
) {
log::info!("spawning player");
storages.add_entity(((
storages.add_entity((
Player,
MainPlayer,
Entity,
@ -34,10 +33,8 @@ pub fn spawn_player (
FlyController,
LookingAtBlock::default(),
PlayerHolding(Some(Block::Cobblestone)),
Username("LocalPlayer".into()),
),(
ClPhysicsActor::default(),
)));
Username("LocalPlayer".into())
));
}
pub fn spawn_local_player_multiplayer (
@ -45,7 +42,8 @@ pub fn spawn_local_player_multiplayer (
init: ClientInitData
) {
log::info!("spawning local multiplayer player");
let entity_id = storages.add_entity(((
let entity_id = storages.add_entity((
(
Player,
Client(init.client_id),
MainPlayer,
@ -57,9 +55,9 @@ pub fn spawn_local_player_multiplayer (
LookingAtBlock::default(),
PlayerHolding::default(),
),(
Username(init.username),
ClPhysicsActor::default(),
)));
Username(init.username)
)
));
//Add ourself to the client id map
let mut client_id_map = storages.borrow::<UniqueViewMut<ClientIdMap>>().unwrap();