mirror of
https://github.com/griffi-gh/kubi.git
synced 2024-11-25 16:28:42 -06:00
Compare commits
8 commits
9f5b974f82
...
4948d85e05
Author | SHA1 | Date | |
---|---|---|---|
griffi-gh | 4948d85e05 | ||
griffi-gh | 47839c03aa | ||
griffi-gh | a468e764c3 | ||
griffi-gh | 5e63d1b630 | ||
griffi-gh | f00b2081e6 | ||
griffi-gh | 748f12a1ac | ||
griffi-gh | 685cd43ada | ||
griffi-gh | 3f38351356 |
633
Cargo.lock
generated
633
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
|
@ -33,3 +33,8 @@ 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
|
||||
|
|
|
@ -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 = "8ef90ea6c4d1eb6c9cb0988f0d2f873f75044d49", default-features = false, features = ["std", "proc", "thread_local"] }
|
||||
shipyard = { git = "https://github.com/leudz/shipyard", rev = "9099b990e", default-features = false, features = ["std", "proc", "thread_local"] }
|
||||
serde = { version = "1.0", default-features = false, features = ["alloc", "derive"] }
|
||||
toml = "0.8"
|
||||
glam = { version = "0.24", features = ["debug-glam-assert", "fast-math"] }
|
||||
glam = { version = "0.25", features = ["debug-glam-assert", "fast-math"] }
|
||||
hashbrown = "0.14"
|
||||
nohash-hasher = "0.2"
|
||||
anyhow = "1.0"
|
||||
|
|
|
@ -5,9 +5,9 @@ edition = "2021"
|
|||
publish = false
|
||||
|
||||
[dependencies]
|
||||
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"] }
|
||||
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"] }
|
||||
num_enum = "0.7"
|
||||
postcard = { version = "1.0", features = ["alloc"] }
|
||||
serde = { version = "1.0", default-features = false, features = ["alloc", "derive"] }
|
||||
|
|
|
@ -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 = "968fc92378caf" }
|
||||
glium = { git = "https://github.com/glium/glium", rev = "a352c667" }
|
||||
winit = "0.29"
|
||||
glam = "0.24"
|
||||
glam = "0.25"
|
||||
log = "0.4"
|
||||
|
|
|
@ -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 = "968fc92378caf" }
|
||||
glam = "0.24"
|
||||
glium = { git = "https://github.com/glium/glium", rev = "a352c667" }
|
||||
glam = "0.25"
|
||||
log = "0.4"
|
||||
|
|
|
@ -50,8 +50,8 @@ impl BufferPair {
|
|||
pub fn new<F: Facade>(facade: &F) -> Self {
|
||||
log::debug!("init ui buffers...");
|
||||
Self {
|
||||
vertex_buffer: VertexBuffer::empty_persistent(facade, 1024).unwrap(),
|
||||
index_buffer: IndexBuffer::empty_persistent(facade, PrimitiveType::TrianglesList, 1024).unwrap(),
|
||||
vertex_buffer: VertexBuffer::empty_dynamic(facade, 1024).unwrap(),
|
||||
index_buffer: IndexBuffer::empty_dynamic(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_persistent(
|
||||
self.vertex_buffer = VertexBuffer::empty_dynamic(
|
||||
self.vertex_buffer.get_context(),
|
||||
new_vtx_size
|
||||
).unwrap();
|
||||
}
|
||||
if current_idx_size != new_idx_size {
|
||||
self.index_buffer = IndexBuffer::empty_persistent(
|
||||
self.index_buffer = IndexBuffer::empty_dynamic(
|
||||
self.index_buffer.get_context(),
|
||||
PrimitiveType::TrianglesList,
|
||||
new_idx_size
|
||||
|
|
|
@ -7,7 +7,7 @@ publish = false
|
|||
[dependencies]
|
||||
hashbrown = "0.14"
|
||||
nohash-hasher = "0.2"
|
||||
glam = "0.24"
|
||||
glam = "0.25"
|
||||
fontdue = "0.8"
|
||||
rect_packer = "0.2"
|
||||
log = "0.4"
|
||||
|
|
|
@ -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 = "968fc92378caf" }
|
||||
glium = { git = "https://github.com/glium/glium", rev = "a352c667" }
|
||||
glutin = "0.31"
|
||||
winit = { version = "0.29", features = ["android-native-activity"] }
|
||||
glutin-winit = "0.4"
|
||||
raw-window-handle = "0.5"
|
||||
glam = { version = "0.24", features = ["debug-glam-assert", "fast-math"] }
|
||||
raw-window-handle = "=0.5.*"
|
||||
glam = { version = "0.25", features = ["debug-glam-assert", "fast-math"] }
|
||||
image = { version = "0.24", default_features = false, features = ["png"] }
|
||||
strum = { version = "0.25", features = ["derive"] }
|
||||
strum = { version = "0.26", features = ["derive"] }
|
||||
hashbrown = "0.14"
|
||||
nohash-hasher = "0.2"
|
||||
rayon = "1.7"
|
||||
shipyard = { git = "https://github.com/leudz/shipyard", rev = "8ef90ea6c4d1eb6c9cb0988f0d2f873f75044d49", default-features = false, features = ["std", "proc", "thread_local"] }
|
||||
shipyard = { git = "https://github.com/leudz/shipyard", rev = "9099b990e", 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"
|
||||
android-activity = "^0.5.2"
|
||||
ndk = "0.8"
|
||||
|
||||
[target.'cfg(target_os = "windows")'.dependencies]
|
||||
|
@ -59,15 +59,14 @@ 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]]
|
||||
required = true
|
||||
glEsVersion = 0x00030000
|
||||
required = true
|
||||
|
||||
[[package.metadata.android.uses_feature]]
|
||||
name = "android.hardware.touchscreen.multitouch"
|
||||
|
@ -78,6 +77,13 @@ 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"
|
||||
|
|
52
kubi/src/client_physics.rs
Normal file
52
kubi/src/client_physics.rs
Normal file
|
@ -0,0 +1,52 @@
|
|||
//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);
|
||||
// }
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
use glam::UVec2;
|
||||
use shipyard::{World, Component, AllStoragesViewMut, SparseSet, NonSendSync, UniqueView};
|
||||
use winit::event::{Event, DeviceEvent, DeviceId, WindowEvent, Touch, RawKeyEvent, TouchPhase};
|
||||
use winit::event::{Event, DeviceEvent, DeviceId, WindowEvent, Touch};
|
||||
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_glutin_events(world: &mut World, event: &Event<()>) {
|
||||
pub fn process_winit_events(world: &mut World, event: &Event<()>) {
|
||||
#[allow(clippy::collapsible_match, clippy::single_match)]
|
||||
match event {
|
||||
Event::WindowEvent { window_id: _, event } => match event {
|
||||
|
|
|
@ -45,8 +45,9 @@ 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();
|
||||
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);
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,6 +37,7 @@ 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,
|
||||
|
@ -51,7 +52,7 @@ use settings::{load_settings, GameSettings};
|
|||
use camera::compute_cameras;
|
||||
use events::{
|
||||
clear_events,
|
||||
process_glutin_events,
|
||||
process_winit_events,
|
||||
initial_resize_event,
|
||||
player_actions::generate_move_events,
|
||||
};
|
||||
|
@ -81,6 +82,7 @@ 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 {
|
||||
|
@ -104,6 +106,7 @@ fn startup() -> Workload {
|
|||
init_input,
|
||||
insert_control_flow_unique,
|
||||
init_delta_time,
|
||||
init_client_physics,
|
||||
).into_sequential_workload()
|
||||
}
|
||||
|
||||
|
@ -131,6 +134,7 @@ 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,
|
||||
|
@ -179,9 +183,13 @@ 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")));
|
||||
|
@ -253,7 +261,7 @@ pub fn kubi_main(#[cfg(target_os = "android")] app: android_activity::AndroidApp
|
|||
|
||||
window_target.set_control_flow(ControlFlow::Poll);
|
||||
|
||||
process_glutin_events(&mut world, &event);
|
||||
process_winit_events(&mut world, &event);
|
||||
|
||||
#[allow(clippy::collapsible_match, clippy::single_match)]
|
||||
match event {
|
||||
|
|
|
@ -10,10 +10,11 @@ use kubi_shared::{
|
|||
}
|
||||
};
|
||||
use crate::{
|
||||
transform::Transform,
|
||||
camera::Camera,
|
||||
client_physics::ClPhysicsActor,
|
||||
fly_controller::FlyController,
|
||||
world::raycast::LookingAtBlock,
|
||||
transform::Transform,
|
||||
world::raycast::LookingAtBlock
|
||||
};
|
||||
|
||||
#[derive(Component)]
|
||||
|
@ -23,7 +24,7 @@ pub fn spawn_player (
|
|||
mut storages: AllStoragesViewMut,
|
||||
) {
|
||||
log::info!("spawning player");
|
||||
storages.add_entity((
|
||||
storages.add_entity(((
|
||||
Player,
|
||||
MainPlayer,
|
||||
Entity,
|
||||
|
@ -33,8 +34,10 @@ pub fn spawn_player (
|
|||
FlyController,
|
||||
LookingAtBlock::default(),
|
||||
PlayerHolding(Some(Block::Cobblestone)),
|
||||
Username("LocalPlayer".into())
|
||||
));
|
||||
Username("LocalPlayer".into()),
|
||||
),(
|
||||
ClPhysicsActor::default(),
|
||||
)));
|
||||
}
|
||||
|
||||
pub fn spawn_local_player_multiplayer (
|
||||
|
@ -42,8 +45,7 @@ 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,
|
||||
|
@ -55,9 +57,9 @@ pub fn spawn_local_player_multiplayer (
|
|||
LookingAtBlock::default(),
|
||||
PlayerHolding::default(),
|
||||
),(
|
||||
Username(init.username)
|
||||
)
|
||||
));
|
||||
Username(init.username),
|
||||
ClPhysicsActor::default(),
|
||||
)));
|
||||
|
||||
//Add ourself to the client id map
|
||||
let mut client_id_map = storages.borrow::<UniqueViewMut<ClientIdMap>>().unwrap();
|
||||
|
|
Loading…
Reference in a new issue