diff --git a/Cargo.lock b/Cargo.lock index 79ba49f..661c372 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1020,6 +1020,34 @@ dependencies = [ "winit", ] +[[package]] +name = "bevy_xpbd_3d" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0425ea7361b9b27c2a382e0663deb42f41147eee60fb2b3d5fa7e42d363ea848" +dependencies = [ + "bevy", + "bevy_math", + "bevy_xpbd_derive", + "derive_more", + "fxhash", + "indexmap", + "itertools", + "nalgebra", + "parry3d", + "parry3d-f64", +] + +[[package]] +name = "bevy_xpbd_derive" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3e1ef1d5e328abe1b76df974245f78e17fd17867583883d5e77444c6a8223a64" +dependencies = [ + "quote", + "syn 2.0.52", +] + [[package]] name = "bindgen" version = "0.69.4" @@ -1358,6 +1386,12 @@ dependencies = [ "const_soft_float", ] +[[package]] +name = "convert_case" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" + [[package]] name = "core-foundation" version = "0.9.4" @@ -1459,6 +1493,25 @@ dependencies = [ "crossbeam-utils", ] +[[package]] +name = "crossbeam-deque" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "613f8cc01fe9cf1a3eb3d7f488fd2fa8388403e97039e2f73692932e291a770d" +dependencies = [ + "crossbeam-epoch", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-epoch" +version = "0.9.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b82ac4a3c2ca9c3460964f020e1402edd5753411d7737aa39c3714ad1b5420e" +dependencies = [ + "crossbeam-utils", +] + [[package]] name = "crossbeam-utils" version = "0.8.19" @@ -1500,8 +1553,10 @@ version = "0.99.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321" dependencies = [ + "convert_case", "proc-macro2", "quote", + "rustc_version", "syn 1.0.109", ] @@ -1729,6 +1784,15 @@ dependencies = [ "pin-project-lite", ] +[[package]] +name = "fxhash" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c31b6d751ae2c7f11320402d34e41349dd1016f8d5d45e48c4312bc8625af50c" +dependencies = [ + "byteorder", +] + [[package]] name = "gethostname" version = "0.4.3" @@ -2134,6 +2198,12 @@ dependencies = [ "windows-targets 0.52.4", ] +[[package]] +name = "libm" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" + [[package]] name = "libredox" version = "0.0.2" @@ -2194,6 +2264,16 @@ dependencies = [ "regex-automata 0.1.10", ] +[[package]] +name = "matrixmultiply" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7574c1cf36da4798ab73da5b215bbf444f50718207754cb522201d78d1cd0ff2" +dependencies = [ + "autocfg", + "rawpointer", +] + [[package]] name = "memchr" version = "2.7.1" @@ -2272,6 +2352,34 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "nalgebra" +version = "0.32.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ea4908d4f23254adda3daa60ffef0f1ac7b8c3e9a864cf3cc154b251908a2ef" +dependencies = [ + "approx", + "glam", + "matrixmultiply", + "nalgebra-macros", + "num-complex", + "num-rational", + "num-traits", + "simba", + "typenum", +] + +[[package]] +name = "nalgebra-macros" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91761aed67d03ad966ef783ae962ef9bbaca728d2dd7ceb7939ec110fffad998" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + [[package]] name = "ndk" version = "0.8.0" @@ -2337,6 +2445,15 @@ dependencies = [ "winapi", ] +[[package]] +name = "num-complex" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23c6602fda94a57c990fe0df199a035d83576b496aa29f4e634a8ac6004e68a6" +dependencies = [ + "num-traits", +] + [[package]] name = "num-derive" version = "0.4.2" @@ -2348,6 +2465,26 @@ dependencies = [ "syn 2.0.52", ] +[[package]] +name = "num-integer" +version = "0.1.46" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f" +dependencies = [ + "num-traits", +] + +[[package]] +name = "num-rational" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0638a1c9d0a3c0914158145bc76cff373a75a627e6ecbfb71cbe6f453a5a19b0" +dependencies = [ + "autocfg", + "num-integer", + "num-traits", +] + [[package]] name = "num-traits" version = "0.2.18" @@ -2355,6 +2492,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "da0df0e5185db44f69b44f26786fe401b6c293d1907744beaa7fa62b2e5a517a" dependencies = [ "autocfg", + "libm", ] [[package]] @@ -2498,6 +2636,7 @@ version = "0.3.0" dependencies = [ "bevy", "bevy_embedded_assets", + "bevy_xpbd_3d", "regex", ] @@ -2545,6 +2684,50 @@ dependencies = [ "windows-targets 0.48.5", ] +[[package]] +name = "parry3d" +version = "0.13.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ccba18a65dba56c08dadfa936e0c9efbc883b3a26dc77d2685f78be10f7667c" +dependencies = [ + "approx", + "arrayvec", + "bitflags 1.3.2", + "downcast-rs", + "either", + "nalgebra", + "num-derive", + "num-traits", + "rayon", + "rustc-hash", + "simba", + "slab", + "smallvec", + "spade", +] + +[[package]] +name = "parry3d-f64" +version = "0.13.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d259245abcc09379798e4d373d9019e0df4dc6f7f128ecd68700a5927dc32034" +dependencies = [ + "approx", + "arrayvec", + "bitflags 1.3.2", + "downcast-rs", + "either", + "nalgebra", + "num-derive", + "num-traits", + "rayon", + "rustc-hash", + "simba", + "slab", + "smallvec", + "spade", +] + [[package]] name = "paste" version = "1.0.14" @@ -2683,6 +2866,32 @@ version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "42a9830a0e1b9fb145ebb365b8bc4ccd75f290f98c0247deafbbe2c75cefb544" +[[package]] +name = "rawpointer" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60a357793950651c4ed0f3f52338f53b2f809f32d83a07f72909fa13e4c6c1e3" + +[[package]] +name = "rayon" +version = "1.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b418a60154510ca1a002a752ca9714984e21e4241e804d32555251faf8b78ffa" +dependencies = [ + "either", + "rayon-core", +] + +[[package]] +name = "rayon-core" +version = "1.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1465873a3dfdaa8ae7cb14b4383657caab0b3e8a0aa9ae8e04b044854c8dfce2" +dependencies = [ + "crossbeam-deque", + "crossbeam-utils", +] + [[package]] name = "rectangle-pack" version = "0.4.2" @@ -2757,6 +2966,12 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "19b30a45b0cd0bcca8037f3d0dc3421eaf95327a17cad11964fb8179b4fc4832" +[[package]] +name = "robust" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cbf4a6aa5f6d6888f39e980649f3ad6b666acdce1d78e95b8a2cb076e687ae30" + [[package]] name = "rodio" version = "0.17.3" @@ -2785,6 +3000,15 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" +[[package]] +name = "rustc_version" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" +dependencies = [ + "semver", +] + [[package]] name = "rustix" version = "0.38.31" @@ -2815,6 +3039,15 @@ version = "1.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e86697c916019a8588c99b5fac3cead74ec0b4b819707a682fd4d23fa0ce1ba1" +[[package]] +name = "safe_arch" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f398075ce1e6a179b46f51bd88d0598b92b00d3551f1a2d4ac49e771b56ac354" +dependencies = [ + "bytemuck", +] + [[package]] name = "same-file" version = "1.0.6" @@ -2830,6 +3063,12 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" +[[package]] +name = "semver" +version = "1.0.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92d43fe69e652f3df9bdc2b85b2854a0825b86e4fb76bc44d945137d053639ca" + [[package]] name = "serde" version = "1.0.197" @@ -2876,6 +3115,19 @@ version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" +[[package]] +name = "simba" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "061507c94fc6ab4ba1c9a0305018408e312e17c041eb63bef8aa726fa33aceae" +dependencies = [ + "approx", + "num-complex", + "num-traits", + "paste", + "wide", +] + [[package]] name = "simd-adler32" version = "0.3.7" @@ -2918,6 +3170,18 @@ dependencies = [ "serde", ] +[[package]] +name = "spade" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61addf9117b11d1f5b4bf6fe94242ba25f59d2d4b2080544b771bd647024fd00" +dependencies = [ + "hashbrown", + "num-traits", + "robust", + "smallvec", +] + [[package]] name = "spirv" version = "0.3.0+sdk-1.3.268.0" @@ -3157,6 +3421,12 @@ dependencies = [ "static_assertions", ] +[[package]] +name = "typenum" +version = "1.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" + [[package]] name = "unicode-ident" version = "1.0.12" @@ -3412,6 +3682,16 @@ dependencies = [ "web-sys", ] +[[package]] +name = "wide" +version = "0.7.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "89beec544f246e679fc25490e3f8e08003bc4bf612068f325120dad4cea02c1c" +dependencies = [ + "bytemuck", + "safe_arch", +] + [[package]] name = "widestring" version = "1.0.2" diff --git a/Cargo.toml b/Cargo.toml index caf4b62..64b18a2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,8 +11,9 @@ rust-version = "1.76.0" [dependencies] regex = "1" -bevy_embedded_assets = "0.10.2" bevy = { version = "0.13.0", default-features = false, features = ["jpeg", "bevy_asset", "bevy_audio", "bevy_scene", "bevy_winit", "bevy_core_pipeline", "bevy_pbr", "bevy_gltf", "bevy_render", "bevy_text", "bevy_ui", "multi-threaded", "png", "vorbis", "x11", "tonemapping_luts"]} +bevy_xpbd_3d = { version = "0.4", default-features = false, features = ["3d", "f32", "parry-f32", "parallel"] } +bevy_embedded_assets = "0.10.2" [features] dev = ["bevy/dynamic_linking"] diff --git a/README.md b/README.md index e93125c..83316a7 100644 --- a/README.md +++ b/README.md @@ -24,6 +24,7 @@ Key features: - t: toggle music (NOTE: currently no music is included in the git repo) - m: mute sound effects - q: enter/exit vehicle +- f: toggle 3rd person view - TAB: toggle augmented reality overlay (HUD, low-light amplifier) # System Requirements @@ -113,6 +114,7 @@ cargo run --release - https://pixabay.com/sound-effects/electricity-6353 - https://pixabay.com/sound-effects/ducati-696-monster-33217 - https://pixabay.com/sound-effects/high-energy-humming-195612 +- https://pixabay.com/sound-effects/box-crash-106687 - Music: [Dead Space Style Ambient Music](https://pixabay.com/music/ambient-dead-space-style-ambient-music-184793) by [Sharvarian](https://www.fiverr.com/sharvarian) - Star chart based on the [HYG Stellar database](https://github.com/astronexus/HYG-Database) - Custom font Yupiter is based on: diff --git a/assets/models/MeteorAceGT.glb b/assets/models/MeteorAceGT.glb index 50575db..b313f91 100644 Binary files a/assets/models/MeteorAceGT.glb and b/assets/models/MeteorAceGT.glb differ diff --git a/assets/sounds/crash.ogg b/assets/sounds/crash.ogg new file mode 100644 index 0000000..378c8af Binary files /dev/null and b/assets/sounds/crash.ogg differ diff --git a/src/actor.rs b/src/actor.rs index 80e8823..53cba23 100644 --- a/src/actor.rs +++ b/src/actor.rs @@ -1,4 +1,6 @@ use bevy::prelude::*; +use bevy::transform::TransformSystem; +use bevy_xpbd_3d::prelude::*; use crate::{nature, settings, actor, audio, hud}; pub const ENGINE_SPEED_FACTOR: f32 = 30.0; @@ -11,7 +13,6 @@ impl Plugin for ActorPlugin { app.register_type::(); app.add_systems(FixedUpdate, ( update_physics_lifeforms, - update_physics_actors, )); app.add_systems(Update, ( handle_new_conversations, @@ -19,7 +20,8 @@ impl Plugin for ActorPlugin { handle_conversations, handle_input, handle_chat_scripts, - handle_vehicle_enter_exit, + handle_vehicle_enter_exit.after(PhysicsSet::Sync).before(TransformSystem::TransformPropagate), + handle_collisions, )); app.add_event::(); app.add_event::(); @@ -63,6 +65,7 @@ pub struct Actor { pub v: Vec3, // velocity pub angular_momentum: Quat, pub inside_entity: u32, + pub camdistance: f32, } impl Default for Actor { @@ -74,12 +77,14 @@ impl Default for Actor { v: Vec3::ZERO, inside_entity: NO_RIDE, angular_momentum: Quat::from_euler(EulerRot::XYZ, 0.001, 0.01, 0.003), + camdistance: 15.0, } } } -#[derive(Component)] pub struct Player; -#[derive(Component)] pub struct PlayerDrivesThis; +#[derive(Component)] pub struct Player; // Attached to the suit of the player +#[derive(Component)] pub struct PlayerDrivesThis; // Attached to the entered vehicle +#[derive(Component)] pub struct PlayerCamera; // Attached to the actor to use as point of view #[derive(Component)] pub struct PlayerInConversation; #[derive(Component)] pub struct InConversationWithPlayer; #[derive(Component)] pub struct ActorEnteringVehicle; @@ -187,19 +192,6 @@ const SUIT_SIMPLE: Suit = Suit { integrity: 1e5, }; -pub fn update_physics_actors( - time: Res