diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index d18f1ad..fd934a0 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -23,9 +23,12 @@ jobs: runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v4 + - name: Install bevy dependencies + run: | + sudo apt-get update && sudo apt-get install -y \ + g++ pkg-config libx11-dev libasound2-dev libudev-dev libopenxr-loader1 libopenxr-dev - name: Cache cargo dependencies uses: Swatinem/rust-cache@v2 - - name: Clippy lints run: cargo clippy --all --all-features --all-targets --no-deps -- -D warnings @@ -37,6 +40,10 @@ jobs: runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v4 + - name: Install bevy dependencies + run: | + sudo apt-get update && sudo apt-get install -y \ + g++ pkg-config libx11-dev libasound2-dev libudev-dev libopenxr-loader1 libopenxr-dev - name: Cache cargo dependencies uses: Swatinem/rust-cache@v2 diff --git a/Cargo.lock b/Cargo.lock index 5dc484e..36865f7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -708,7 +708,7 @@ dependencies = [ [[package]] name = "bevy-suis" version = "0.1.0" -source = "git+https://github.com/Schmarni-Dev/bevy-suis?branch=further_work#d94ae5b0989732b7b840e8744af02c5bf233c0d2" +source = "git+https://github.com/Schmarni-Dev/bevy-suis?branch=further_work#f25918db5b12f1457fd8379f34bf79c8fbcb841c" dependencies = [ "bevy", "bevy_mod_openxr", @@ -1472,6 +1472,7 @@ dependencies = [ [[package]] name = "bevy_spatial_egui" version = "0.1.0" +source = "git+https://github.com/Schmarni-Dev/bevy_spatial_egui#bf9f5f28b6cda207cd3baf8895573e0a4d64b3dd" dependencies = [ "bevy", "bevy-suis", @@ -1665,6 +1666,7 @@ dependencies = [ [[package]] name = "bevy_vr_controller" version = "0.1.1" +source = "git+https://github.com/unavi-xyz/bevy_vr_controller?rev=4a5cc73#4a5cc73956cb23b9a1ff7a261f8964c3d0cfd3ce" dependencies = [ "avian3d", "bevy", diff --git a/Cargo.toml b/Cargo.toml index d61aa6a..9d7dd5e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,6 +8,9 @@ repository.workspace = true edition.workspace = true rust-version.workspace = true +[lints] +workspace = true + [workspace] resolver = "2" @@ -20,6 +23,11 @@ license = "MIT-0 OR Apache-2.0" repository = "https://github.com/NexusSocial/nexus-vr" rust-version = "1.81.0" +[workspace.lints.clippy] +too_many_arguments = "allow" +type_complexity = "allow" + + [workspace.dependencies] @@ -34,15 +42,17 @@ bincode = "1.3.3" avian3d = { version = "0.1.2", features = ["serialize"] } bevy_embedded_assets = "0.11.0" bevy_web_file_drop = "0.0.6" -bevy_vr_controller = { path = "../bevy_vr_controller" } +bevy_vr_controller = { git = "https://github.com/unavi-xyz/bevy_vr_controller", rev = "4a5cc73" } bevy_mod_openxr = { git = "https://github.com/awtterpip/bevy_oxr" } bevy_xr_utils = { git = "https://github.com/awtterpip/bevy_oxr" } -bevy_spatial_egui = { path = "../bevy_spatial_egui" } +bevy_spatial_egui = { git = "https://github.com/Schmarni-Dev/bevy_spatial_egui" } bevy_egui = "0.29.0" bevy-suis = { git = "https://github.com/Schmarni-Dev/bevy-suis", branch = "further_work" } bevy_vrm = "0.0.12" egui-aesthetix = { version = "0.2.4", features = ["tokyo_night", "default"] } -bevy_suis_lasers = { path = "./crates/bevy_suis_lasers"} +bevy_suis_lasers = { path = "./crates/bevy_suis_lasers" } + + [profile.release] lto = true codegen-units = 1 diff --git a/crates/bevy_suis_lasers/Cargo.toml b/crates/bevy_suis_lasers/Cargo.toml index 02b1682..1daca0d 100644 --- a/crates/bevy_suis_lasers/Cargo.toml +++ b/crates/bevy_suis_lasers/Cargo.toml @@ -11,6 +11,9 @@ rust-version.workspace = true bevy-suis = { git = "https://github.com/Schmarni-Dev/bevy-suis", branch = "further_work" } bevy = { version = "0.14", default-features = false } +[lints] +workspace = true + [dev-dependencies] bevy = { version = "0.14", default-features = true } bevy_mod_openxr.git = "https://github.com/awtterpip/bevy_oxr" diff --git a/crates/bevy_suis_lasers/examples/test.rs b/crates/bevy_suis_lasers/examples/test.rs index 1e7a2e5..75180ec 100644 --- a/crates/bevy_suis_lasers/examples/test.rs +++ b/crates/bevy_suis_lasers/examples/test.rs @@ -6,8 +6,7 @@ use bevy_suis::{ SuisCorePlugin, }; use bevy_suis_lasers::{ - draw_lasers::{Laser, LaserPlugin}, - laser_input_methods::LaserInputMethodPlugin, + draw_lasers::LaserPlugin, laser_input_methods::LaserInputMethodPlugin, }; fn main() -> AppExit { App::new() diff --git a/crates/bevy_suis_lasers/src/draw_lasers.rs b/crates/bevy_suis_lasers/src/draw_lasers.rs index 0b018dc..70c7cc5 100644 --- a/crates/bevy_suis_lasers/src/draw_lasers.rs +++ b/crates/bevy_suis_lasers/src/draw_lasers.rs @@ -34,7 +34,11 @@ impl Laser { } } -const TOTAL_LENGTH: f32 = SEGMENT_LENGTH + GAP_LENGTH; +impl Default for Laser { + fn default() -> Self { + Self::new() + } +} const SEGMENT_LENGTH: f32 = 0.05; const GAP_LENGTH: f32 = 0.03; @@ -103,14 +107,12 @@ fn update_laser( let mut position_along = 0.0; let mut segment_count = 0; - let mut level = 0; let mut segment_length = SEGMENT_LENGTH; let mut gap_length = GAP_LENGTH; while position_along < length { // Adjust segment length and gap length every K segments if segment_count > 0 && segment_count % K == 0 { - level += 1; segment_length *= 2.0; gap_length *= 2.0; } @@ -128,11 +130,10 @@ fn update_laser( let rotation = Quat::from_rotation_arc(Vec3::Y, laser_direction); // Scale the segment mesh along Y to represent the new length - let mut transform = Transform { + let transform = Transform { translation: segment_position, rotation, scale: Vec3::new(1.0, segment_length / SEGMENT_LENGTH, 1.0), - ..Default::default() }; let bundle = PbrBundle { diff --git a/deny.toml b/deny.toml index b91a6f0..878fb80 100644 --- a/deny.toml +++ b/deny.toml @@ -3,8 +3,7 @@ all-features = true [advisories] version = 2 -ignore = [ -] +ignore = [] [licenses] version = 2 @@ -25,6 +24,23 @@ allow = [ "LicenseRef-ring", ] +[[licenses.exceptions]] +name = "unicode-ident" +allow = ["Unicode-DFS-2016"] + +[[licenses.exceptions]] +# https://github.com/emilk/egui/issues/2321 +name = "epaint" +allow = ["OFL-1.1", "LicenseRef-UFL-1.0"] + +[[licenses.clarify]] +name = "ring" +expression = "LicenseRef-ring" +license-files = [ + { path = "LICENSE", hash = 0xbd0eed23 }, +] + + [bans] multiple-versions = "warn" # Certain crates that we don't want multiple versions of in the dependency tree @@ -38,4 +54,10 @@ unknown-registry = "deny" unknown-git = "deny" allow-registry = ["https://github.com/rust-lang/crates.io-index"] # please don't make this list any longer qwq -allow-git = [] +allow-git = [ + "https://github.com/Schmarni-Dev/bevy-suis", + "https://github.com/awtterpip/bevy_oxr", + "https://github.com/unavi-xyz/bevy_vr_controller", + "https://github.com/Schmarni-Dev/bevy_spatial_egui", + "https://github.com/Schmarni-Dev/schminput" +] diff --git a/src/file_import.rs b/src/file_import.rs index 9ea0316..719a7ac 100644 --- a/src/file_import.rs +++ b/src/file_import.rs @@ -1,12 +1,10 @@ -use crate::MainWindow; use bevy::log::info; use bevy::math::EulerRot::XYZ; use bevy::prelude::*; use bevy_egui::{egui, EguiContext}; use bevy_spatial_egui::SpawnSpatialEguiWindowCommand; use egui_aesthetix::Aesthetix; -use std::ops::{Add, Sub}; -use std::path::Path; +use std::ops::Add; use std::sync::Arc; pub struct FileImportPlugin; @@ -16,6 +14,7 @@ impl Plugin for FileImportPlugin { } } +#[allow(dead_code)] #[derive(Copy, Clone, Component, Debug)] pub enum FileType { Vrm, @@ -37,21 +36,16 @@ fn draw_ui( ctx.get_mut().set_style( Arc::new(egui_aesthetix::themes::TokyoNightStorm).custom_style(), ); + #[allow(clippy::needless_if)] egui::panel::CentralPanel::default().show(ctx.get_mut(), |ui| { ui.heading(format!("Path: {}", file_import_window.path)); - if ui.button("png").clicked() { - - } - if ui.button("worldspace model").clicked() { - - } - if ui.button("switch avatar").clicked() { - - } - ui.add_space(10.0); - if ui.button("cancel").clicked() { - commands.entity(entity).despawn_recursive(); - } + if ui.button("png").clicked() {} + if ui.button("worldspace model").clicked() {} + if ui.button("switch avatar").clicked() {} + ui.add_space(10.0); + if ui.button("cancel").clicked() { + commands.entity(entity).despawn_recursive(); + } }); } } diff --git a/src/file_sharing.rs b/src/file_sharing.rs index 734249e..8981bfb 100644 --- a/src/file_sharing.rs +++ b/src/file_sharing.rs @@ -2,7 +2,7 @@ use crate::networking::{Connection, ConnectionTrait, ReliableMessage}; use bevy::prelude::*; use bevy_matchbox::prelude::MultipleChannels; use bevy_matchbox::MatchboxSocket; -use futures_channel::mpsc::{channel, Receiver, SendError, Sender}; +use futures_channel::mpsc::{channel, Receiver, Sender}; use serde::{Deserialize, Serialize}; use std::collections::HashMap; use uuid::Uuid; @@ -24,6 +24,7 @@ impl FilePart { } } +#[allow(dead_code)] #[derive(Component)] pub struct InProgressFile { len: usize, @@ -56,6 +57,7 @@ impl Plugin for FileSharingPlugin { #[derive(Resource)] struct P2pFileRx(Receiver<(Uuid, Vec)>); +#[allow(dead_code)] #[derive(Resource)] pub struct P2pFileSender(Sender<(Uuid, Vec)>); @@ -70,7 +72,7 @@ fn send_parts_of_file( for chunk in bytes.chunks(256) { chunks.push(chunk.to_vec()); } - local.insert(uuid.clone(), chunks); + local.insert(uuid, chunks); while let Err(e) = connection .send_all(&ReliableMessage::FilePart(FilePart::Start { uuid, len })) { @@ -82,17 +84,16 @@ fn send_parts_of_file( let mut list_of_empty = vec![]; - for (uuid, mut chunks) in local.iter_mut() { + for (uuid, chunks) in local.iter_mut() { if let Some(chunk) = chunks.pop() { - let message = - ReliableMessage::FilePart(FilePart::Part(uuid.clone(), chunk)); + let message = ReliableMessage::FilePart(FilePart::Part(*uuid, chunk)); while let Err(e) = connection.send_all(&message) { if e.first().unwrap().1.is_disconnected() { return; } } } else { - list_of_empty.push(uuid.clone()); + list_of_empty.push(*uuid); } } diff --git a/src/main.rs b/src/main.rs index de4a741..f35ee2a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,11 +1,9 @@ use crate::file_import::FileImportPlugin; use crate::file_sharing::FileSharingPlugin; -use crate::networking::{ConnectToRoom, LocalPlayer, NetworkingPlugin, SpawnPlayer}; +use crate::networking::{ConnectToRoom, LocalPlayer, NetworkingPlugin}; use crate::physics_sync::PhysicsSyncNetworkingPlugin; use crate::player_networking::PlayerNetworking; -use avian3d::prelude::{ - Collider, CollisionLayers, GravityScale, LockedAxes, RigidBody, -}; +use avian3d::prelude::{Collider, GravityScale, LockedAxes, RigidBody}; use avian3d::PhysicsPlugins; use bevy::app::App; use bevy::asset::{AssetMetaCheck, AssetServer, Assets, Handle}; @@ -23,10 +21,8 @@ use bevy_suis::debug::SuisDebugGizmosPlugin; use bevy_suis::window_pointers::SuisWindowPointerPlugin; use bevy_suis::SuisCorePlugin; use bevy_vr_controller::animation::defaults::default_character_animations; -use bevy_vr_controller::movement::PlayerInputState; use bevy_vr_controller::player::{ - PlayerAvatar, PlayerBody, PlayerHeight, PlayerJumpHeight, PlayerSettings, - PlayerSpawn, PlayerSpeed, SpawnedPlayer, VoidTeleport, + PlayerAvatar, PlayerBody, PlayerSettings, PlayerSpawn, VoidTeleport, }; use bevy_vr_controller::velocity::AverageVelocity; use bevy_vr_controller::VrControllerPlugin; @@ -118,6 +114,7 @@ fn setup_main_window(mut cmds: Commands) { }); } +#[allow(dead_code)] #[derive(Resource)] pub struct FloorMaterial((Handle, Handle)); diff --git a/src/networking.rs b/src/networking.rs index 1a6b54b..3925daf 100644 --- a/src/networking.rs +++ b/src/networking.rs @@ -1,8 +1,6 @@ use crate::file_sharing::FileParts; use avian3d::prelude::{AngularVelocity, LinearVelocity, Position}; -use bevy::app::App; -use bevy::ecs::system::{EntityCommand, SystemParam}; -use bevy::ecs::world::Command; +use bevy::ecs::system::SystemParam; use bevy::prelude::*; use bevy_derive::{Deref, DerefMut}; use bevy_matchbox::prelude::{ @@ -19,6 +17,8 @@ pub enum ReliableMessage { FilePart(crate::file_sharing::FilePart), } +// should this used Boxed values for a smaller base size? +#[allow(clippy::large_enum_variant)] #[derive(Clone, Debug, Serialize, Deserialize)] pub enum UnreliableMessage { UpdatePhysicsPosition(UpdatePhysicsPosition), diff --git a/src/physics_sync.rs b/src/physics_sync.rs index be028fe..f88fdc3 100644 --- a/src/physics_sync.rs +++ b/src/physics_sync.rs @@ -1,5 +1,4 @@ use crate::networking::{RemotePlayer, UpdatePhysicsPosition}; -use avian3d::math::AsF32; use avian3d::prelude::{AngularVelocity, LinearVelocity, Position, Rotation}; use bevy::prelude::*; @@ -22,19 +21,20 @@ fn sync_positions( )>, ) { for update in event_reader.read() { - for (uuid, mut pos, mut rot, mut lin, mut ang) in players.iter_mut() { + for (uuid, mut pos, mut rot, mut lin, _) in players.iter_mut() { if uuid.0 != update.uuid { continue; } - if pos.distance(*update.position) <= 0.01 { - if rot.0.angle_between(update.rotation.0).abs() <= 0.01 { - continue; - } + // This position check is one centimeter?! that's a little big no? + if pos.distance(*update.position) <= 0.01 + && rot.0.angle_between(update.rotation.0).abs() <= 0.01 + { + continue; } - *pos = update.position.clone(); - *rot = update.rotation.clone(); - *lin = update.linear_velocity.clone(); + *pos = update.position; + *rot = update.rotation; + *lin = update.linear_velocity; //*ang = update.angular_velocity.clone(); } } diff --git a/src/player_networking.rs b/src/player_networking.rs index eb9e470..8f8a410 100644 --- a/src/player_networking.rs +++ b/src/player_networking.rs @@ -48,10 +48,9 @@ fn when_spawn_player( }, &mut commands, ); - commands.entity(id).insert(RemotePlayer( - player.uuid.clone(), - player.peer_id.as_ref().unwrap().clone(), - )); + commands + .entity(id) + .insert(RemotePlayer(player.uuid, player.peer_id.unwrap())); } } @@ -82,7 +81,7 @@ fn send_players_when_connected( let _ = connection.send( new_player.0, &ReliableMessage::SpawnPlayer(SpawnPlayer { - uuid: local_player.0.clone(), + uuid: local_player.0, peer_id: None, }), ); @@ -120,10 +119,10 @@ fn update_player_position( let message = UnreliableMessage::UpdatePhysicsPosition(UpdatePhysicsPosition { authority: 0, uuid: local_player.0, - position: position.clone(), - rotation: rotation.clone(), - linear_velocity: lin_vel.clone(), - angular_velocity: ang_vel.clone(), + position: *position, + rotation: *rotation, + linear_velocity: *lin_vel, + angular_velocity: *ang_vel, }); let _ = connection.send_all(&message); @@ -133,7 +132,7 @@ fn update_player_position( }*/ let mut player_position_update = PlayerPositionUpdate { - uuid: local_player.0.clone(), + uuid: local_player.0, head: Default::default(), left_shoulder: Default::default(), right_shoulder: Default::default(), @@ -145,32 +144,32 @@ fn update_player_position( right_hand: Default::default(), }; for children in children.iter_descendants(entity) { - for (bone_name, transform) in transforms.get(children) { + if let Ok((bone_name, transform)) = transforms.get(children) { match bone_name { - BoneName::Head => player_position_update.head = transform.clone(), + BoneName::Head => player_position_update.head = *transform, BoneName::LeftShoulder => { - player_position_update.left_shoulder = transform.clone() + player_position_update.left_shoulder = *transform; } BoneName::RightShoulder => { - player_position_update.right_shoulder = transform.clone() + player_position_update.right_shoulder = *transform; } BoneName::LeftUpperArm => { - player_position_update.left_upper_arm = transform.clone() + player_position_update.left_upper_arm = *transform; } BoneName::RightUpperArm => { - player_position_update.right_upper_arm = transform.clone() + player_position_update.right_upper_arm = *transform; } BoneName::LeftLowerArm => { - player_position_update.left_lower_arm = transform.clone() + player_position_update.left_lower_arm = *transform; } BoneName::RightLowerArm => { - player_position_update.right_lower_arm = transform.clone() + player_position_update.right_lower_arm = *transform; } BoneName::LeftHand => { - player_position_update.left_hand = transform.clone() + player_position_update.left_hand = *transform; } BoneName::RightHand => { - player_position_update.right_hand = transform.clone() + player_position_update.right_hand = *transform; } _ => {} }