diff --git a/Cargo.lock b/Cargo.lock index 8e0f10d..7d1ae97 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -328,6 +328,39 @@ version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" +[[package]] +name = "avian3d" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d587e38c23e9a624f89c7981a5dc7440b48b0510d76d0d10929e7fd70987de93" +dependencies = [ + "avian_derive", + "bevy", + "bevy_heavy", + "bevy_math", + "bevy_transform_interpolation", + "bitflags 2.8.0", + "derive_more 1.0.0", + "fxhash", + "indexmap", + "itertools 0.13.0", + "nalgebra", + "parry3d", + "parry3d-f64", +] + +[[package]] +name = "avian_derive" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "12b257f601a1535e0d4a7a7796f535e3a13de62fd422b16dff7c14d27f0d4048" +dependencies = [ + "proc-macro-error2", + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "base64" version = "0.21.7" @@ -782,6 +815,16 @@ dependencies = [ "smallvec", ] +[[package]] +name = "bevy_heavy" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f85619a206875db57b0213dc5242b51f1be748663cd5f8f99f78d2a6a108dabf" +dependencies = [ + "bevy_math", + "bevy_reflect", +] + [[package]] name = "bevy_hierarchy" version = "0.15.3" @@ -1265,12 +1308,22 @@ dependencies = [ "derive_more 1.0.0", ] +[[package]] +name = "bevy_transform_interpolation" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fcad6974fb74cab07425c4f3d3af78876966b4525c3aec5c0d56ae8511a946a" +dependencies = [ + "bevy", +] + [[package]] name = "bevy_trenchbroom" version = "0.6.2" source = "git+https://github.com/Noxmore/bevy_trenchbroom.git?rev=7038e61#7038e616ba81ec9d8a42ea86818ca4ad5ea40472" dependencies = [ "anyhow", + "avian3d", "bevy", "bevy_materialize", "bevy_reflect", @@ -1428,7 +1481,7 @@ dependencies = [ "proc-macro2", "quote", "regex", - "rustc-hash", + "rustc-hash 1.1.0", "shlex", "syn", ] @@ -1827,7 +1880,7 @@ dependencies = [ "log", "rangemap", "rayon", - "rustc-hash", + "rustc-hash 1.1.0", "rustybuzz", "self_cell", "swash", @@ -2113,6 +2166,15 @@ dependencies = [ "bytemuck", ] +[[package]] +name = "ena" +version = "0.14.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d248bdd43ce613d87415282f69b9bb99d947d290b10962dd6c56233312c2ad5" +dependencies = [ + "log", +] + [[package]] name = "encase" version = "0.10.0" @@ -2413,6 +2475,15 @@ dependencies = [ "thread_local", ] +[[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" @@ -2622,6 +2693,15 @@ dependencies = [ "svg_fmt", ] +[[package]] +name = "hash32" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47d60b12902ba28e2730cd37e95b8c9223af2808df9e902d4df49588d1470606" +dependencies = [ + "byteorder", +] + [[package]] name = "hashbrown" version = "0.14.5" @@ -2642,6 +2722,16 @@ dependencies = [ "foldhash", ] +[[package]] +name = "heapless" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0bfb9eb618601c89945a70e254898da93b13be0388091d42117462b265bb3fad" +dependencies = [ + "hash32", + "stable_deref_trait", +] + [[package]] name = "heck" version = "0.5.0" @@ -2652,6 +2742,7 @@ checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" name = "hedz_reloaded" version = "0.1.0" dependencies = [ + "avian3d", "bevy", "bevy-inspector-egui", "bevy_flycam", @@ -2983,6 +3074,16 @@ dependencies = [ "regex-automata 0.1.10", ] +[[package]] +name = "matrixmultiply" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9380b911e3e96d10c1f415da0876389aaf1b56759054eeb0de7df940c456ba1a" +dependencies = [ + "autocfg", + "rawpointer", +] + [[package]] name = "memchr" version = "2.7.4" @@ -3044,7 +3145,7 @@ dependencies = [ "indexmap", "log", "pp-rs", - "rustc-hash", + "rustc-hash 1.1.0", "spirv", "termcolor", "thiserror 1.0.69", @@ -3065,12 +3166,40 @@ dependencies = [ "once_cell", "regex", "regex-syntax 0.8.5", - "rustc-hash", + "rustc-hash 1.1.0", "thiserror 1.0.69", "tracing", "unicode-ident", ] +[[package]] +name = "nalgebra" +version = "0.33.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26aecdf64b707efd1310e3544d709c5c0ac61c13756046aaaba41be5c4f66a3b" +dependencies = [ + "approx", + "glam", + "matrixmultiply", + "nalgebra-macros", + "num-complex", + "num-rational", + "num-traits", + "simba", + "typenum", +] + +[[package]] +name = "nalgebra-macros" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "254a5372af8fc138e36684761d3c0cdb758a4410e938babcff1c860ce14ddbfc" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "ndk" version = "0.8.0" @@ -3197,6 +3326,25 @@ dependencies = [ "winapi", ] +[[package]] +name = "num-bigint" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a5e44f723f1133c9deac646763579fdb3ac745e418f2a7af9cd0c431da1f20b9" +dependencies = [ + "num-integer", + "num-traits", +] + +[[package]] +name = "num-complex" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73f88a1307638156682bada9d7604135552957b7818057dcef22705b4d509495" +dependencies = [ + "num-traits", +] + [[package]] name = "num-derive" version = "0.4.2" @@ -3208,6 +3356,26 @@ dependencies = [ "syn", ] +[[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.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f83d14da390562dca69fc84082e73e548e1ad308d24accdedd2720017cb37824" +dependencies = [ + "num-bigint", + "num-integer", + "num-traits", +] + [[package]] name = "num-traits" version = "0.2.19" @@ -3508,6 +3676,15 @@ dependencies = [ "libredox", ] +[[package]] +name = "ordered-float" +version = "4.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7bb71e1b3fa6ca1c61f383464aaf2bb0e2f8e772a1f01d486832464de363b951" +dependencies = [ + "num-traits", +] + [[package]] name = "overload" version = "0.1.1" @@ -3552,6 +3729,60 @@ dependencies = [ "windows-targets 0.52.6", ] +[[package]] +name = "parry3d" +version = "0.17.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5d6c81f7d291d5ba572951242779a672f73ed605fe5520045c0bccdb381e913" +dependencies = [ + "approx", + "arrayvec", + "bitflags 2.8.0", + "downcast-rs", + "either", + "ena", + "log", + "nalgebra", + "num-derive", + "num-traits", + "ordered-float", + "rayon", + "rstar", + "rustc-hash 2.1.1", + "simba", + "slab", + "smallvec", + "spade", + "thiserror 1.0.69", +] + +[[package]] +name = "parry3d-f64" +version = "0.17.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50e1531bc225c14f553f570655ad2d974053343446e88584f1d6416f21cf29e8" +dependencies = [ + "approx", + "arrayvec", + "bitflags 2.8.0", + "downcast-rs", + "either", + "ena", + "log", + "nalgebra", + "num-derive", + "num-traits", + "ordered-float", + "rayon", + "rstar", + "rustc-hash 2.1.1", + "simba", + "slab", + "smallvec", + "spade", + "thiserror 1.0.69", +] + [[package]] name = "paste" version = "1.0.15" @@ -3690,6 +3921,28 @@ dependencies = [ "toml_edit", ] +[[package]] +name = "proc-macro-error-attr2" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96de42df36bb9bba5542fe9f1a054b8cc87e172759a1868aa05c1f3acc89dfc5" +dependencies = [ + "proc-macro2", + "quote", +] + +[[package]] +name = "proc-macro-error2" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "11ec05c52be0a07b08061f7dd003e7d7092e0472bc731b4af7bb1ef876109802" +dependencies = [ + "proc-macro-error-attr2", + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "proc-macro2" version = "1.0.93" @@ -3825,6 +4078,12 @@ version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "20675572f6f24e9e76ef639bc5552774ed45f1c30e2951e1e99c59888861c539" +[[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" @@ -3929,6 +4188,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.19.0" @@ -3958,12 +4223,29 @@ version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6c20b6793b5c2fa6553b250154b78d6d0db37e72700ae35fad9387a46f487c97" +[[package]] +name = "rstar" +version = "0.12.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "421400d13ccfd26dfa5858199c30a5d76f9c54e0dba7575273025b43c5175dbb" +dependencies = [ + "heapless", + "num-traits", + "smallvec", +] + [[package]] name = "rustc-hash" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" +[[package]] +name = "rustc-hash" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "357703d41365b4b27c590e3ed91eabb1b663f07c4c084095e60cbed4362dff0d" + [[package]] name = "rustix" version = "0.38.44" @@ -4015,6 +4297,15 @@ version = "1.0.19" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6ea1a2d0a644769cc99faa24c3ad26b379b786fe7c36fd3c546254801650e6dd" +[[package]] +name = "safe_arch" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96b02de82ddbe1b636e6170c21be622223aea188ef2e139be0a5b219ec215323" +dependencies = [ + "bytemuck", +] + [[package]] name = "same-file" version = "1.0.6" @@ -4117,6 +4408,19 @@ version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" +[[package]] +name = "simba" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b3a386a501cd104797982c15ae17aafe8b9261315b5d07e3ec803f2ea26be0fa" +dependencies = [ + "approx", + "num-complex", + "num-traits", + "paste", + "wide", +] + [[package]] name = "simd-adler32" version = "0.3.7" @@ -4205,6 +4509,18 @@ dependencies = [ "serde", ] +[[package]] +name = "spade" +version = "2.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a7f89cb9a80ac939dedb9ad42720cbe112424b6f6597a2a2e9c5e5b684cd4f7" +dependencies = [ + "hashbrown 0.14.5", + "num-traits", + "robust", + "smallvec", +] + [[package]] name = "spirv" version = "0.3.0+sdk-1.3.268.0" @@ -4214,6 +4530,12 @@ dependencies = [ "bitflags 2.8.0", ] +[[package]] +name = "stable_deref_trait" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" + [[package]] name = "stackfuture" version = "0.3.0" @@ -4606,6 +4928,12 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0e13db2e0ccd5e14a544e8a246ba2312cd25223f616442d7f2cb0e3db614236e" +[[package]] +name = "typenum" +version = "1.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1dccffe3ce07af9386bfd29e80c0ab1a8205a2fc34e4bcd40364df902cfa8f3f" + [[package]] name = "unicode-bidi" version = "0.3.18" @@ -4959,7 +5287,7 @@ dependencies = [ "parking_lot", "profiling", "raw-window-handle", - "rustc-hash", + "rustc-hash 1.1.0", "smallvec", "thiserror 1.0.69", "wgpu-hal", @@ -5001,7 +5329,7 @@ dependencies = [ "range-alloc", "raw-window-handle", "renderdoc-sys", - "rustc-hash", + "rustc-hash 1.1.0", "smallvec", "thiserror 1.0.69", "wasm-bindgen", @@ -5022,6 +5350,16 @@ dependencies = [ "web-sys", ] +[[package]] +name = "wide" +version = "0.7.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41b5576b9a81633f3e8df296ce0063042a73507636cbe956c61133dd7034ab22" +dependencies = [ + "bytemuck", + "safe_arch", +] + [[package]] name = "winapi" version = "0.3.9" diff --git a/Cargo.toml b/Cargo.toml index 7b6cfed..adbb69a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,9 +3,13 @@ name = "hedz_reloaded" version = "0.1.0" edition = "2024" +[profile.dev.package."*"] +opt-level = 3 + [dependencies] +avian3d = "0.2" bevy = "0.15.3" -bevy_trenchbroom = { version = "0.6.2", features = ["auto_register"] } +bevy_trenchbroom = { version = "0.6.2", features = ["auto_register", "avian"] } bevy_flycam = "0.15.0" nil = "0.14.0" bevy-inspector-egui = "0.29.1" diff --git a/src/main.rs b/src/main.rs index 2a6c77c..208e625 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,3 +1,5 @@ +use avian3d::PhysicsPlugins; +use avian3d::prelude::*; use bevy::core_pipeline::tonemapping::Tonemapping; use bevy::ecs::component::ComponentId; use bevy::ecs::world::DeferredWorld; @@ -9,17 +11,9 @@ use bevy_trenchbroom::prelude::*; #[derive(SolidClass, Component, Reflect)] #[reflect(Component)] -#[geometry(GeometryProvider::new().smooth_by_default_angle().render())] +#[geometry(GeometryProvider::new().convex_collider().smooth_by_default_angle().render())] pub struct Worldspawn; -#[derive(SolidClass, Component, Reflect, Default)] -#[reflect(Component)] -#[geometry(GeometryProvider::new().smooth_by_default_angle().render())] -pub struct MyBaseClass { - /// MY AWESOME VALUE!! - pub my_value: u32, -} - #[derive(Resource, Reflect, Debug)] #[reflect(Resource)] struct DebugVisuals { @@ -51,10 +45,13 @@ impl SpawnPoint { let mesh = asset_server.load(GltfAssetLabel::Scene(0).from_asset("models/spawn.glb")); - world - .commands() - .entity(entity) - .insert((Name::new("spawn"), SceneRoot(mesh), t)); + world.commands().entity(entity).insert(( + Name::new("spawn"), + SceneRoot(mesh), + t, + RigidBody::Static, + ColliderConstructorHierarchy::new(ColliderConstructor::TrimeshFromMesh), + )); } } @@ -73,6 +70,8 @@ fn main() { default_sampler: repeating_image_sampler(false), })); + app.add_plugins(PhysicsPlugins::default()); + // bevy_flycam setup so we can get a closer look at the scene, mainly for debugging app.add_plugins(PlayerPlugin); @@ -90,7 +89,10 @@ fn main() { app.add_systems(Startup, write_trenchbroom_config); app.add_systems(PostStartup, setup_scene); - app.add_systems(Update, (set_materials_unlit, set_tonemapping, set_shadows)); + app.add_systems( + Update, + (set_materials_unlit, set_tonemapping, set_shadows, spawn_box), + ); app.run(); } @@ -116,6 +118,24 @@ fn setup_scene(mut commands: Commands, asset_server: Res) { ),)); } +fn spawn_box( + mut commands: Commands, + mut meshes: ResMut>, + mut materials: ResMut>, + keys: Res>, +) { + if keys.just_pressed(KeyCode::Enter) { + commands.spawn(( + RigidBody::Dynamic, + Collider::cuboid(1.0, 1.0, 1.0), + AngularVelocity(Vec3::new(2.5, 3.5, 1.5)), + Mesh3d(meshes.add(Cuboid::from_length(1.0))), + MeshMaterial3d(materials.add(Color::srgb_u8(124, 144, 255))), + Transform::from_xyz(0.0, 4.0, 0.0), + )); + } +} + fn write_trenchbroom_config(server: Res) { server.config.write_folder("trenchbroom/hedz").unwrap() } diff --git a/trenchbroom/hedz/hedz.fgd b/trenchbroom/hedz/hedz.fgd index 7a54f70..48bb293 100644 --- a/trenchbroom/hedz/hedz.fgd +++ b/trenchbroom/hedz/hedz.fgd @@ -56,11 +56,6 @@ NOTE: Changing to 2, for example, will cause the bmodel to initially be solid black. You’ll need to add minlight or lights with _light_channel_mask 2." ] -@SolidClass = my_base_class -[ - my_value(integer) : "my_value" : 0 : "MY AWESOME VALUE!!" -] - @PointClass base(transform) model({ "path": "models/spawn.glb", "scale": scale }) = spawn_point [ scale(float) : "scale" : "0" : ""