From ec16d9a254ca07a16da5f900367a4283ac22f483 Mon Sep 17 00:00:00 2001 From: MalekiRe Date: Wed, 29 May 2024 16:30:15 -0700 Subject: [PATCH] cargo fmt and removed the unessecary examples. --- crates/bevy_openxr/examples/3d_scene.rs | 3 +- .../src/openxr/action_set_attaching.rs | 8 +++- crates/bevy_openxr/src/openxr/features/mod.rs | 2 +- crates/bevy_openxr/src/openxr/mod.rs | 2 +- crates/bevy_openxr/src/openxr/render.rs | 7 ++- crates/bevy_webxr/src/webxr/mod.rs | 1 + crates/bevy_xr/macros/src/lib.rs | 43 ++++++++++++----- crates/bevy_xr/src/hands.rs | 8 +++- crates/bevy_xr/src/lib.rs | 2 +- crates/bevy_xr/src/session.rs | 4 +- crates/bevy_xr/src/types.rs | 4 +- crates/bevy_xr_utils/src/lib.rs | 1 - examples/3d_scene.rs | 46 ------------------- 13 files changed, 59 insertions(+), 72 deletions(-) delete mode 100644 examples/3d_scene.rs diff --git a/crates/bevy_openxr/examples/3d_scene.rs b/crates/bevy_openxr/examples/3d_scene.rs index 65e778a..dfc60a7 100644 --- a/crates/bevy_openxr/examples/3d_scene.rs +++ b/crates/bevy_openxr/examples/3d_scene.rs @@ -39,7 +39,8 @@ fn setup( }, transform: Transform::from_xyz(4.0, 8.0, 4.0), ..default() - }); commands.spawn(Camera3dBundle { + }); + commands.spawn(Camera3dBundle { transform: Transform::from_xyz(-2.5, 4.5, 9.0).looking_at(Vec3::ZERO, Vec3::Y), ..default() }); diff --git a/crates/bevy_openxr/src/openxr/action_set_attaching.rs b/crates/bevy_openxr/src/openxr/action_set_attaching.rs index b788458..d8a04f8 100644 --- a/crates/bevy_openxr/src/openxr/action_set_attaching.rs +++ b/crates/bevy_openxr/src/openxr/action_set_attaching.rs @@ -14,10 +14,14 @@ impl Plugin for OxrActionAttachingPlugin { fn attach_sets(session: Res, mut events: EventReader) { let sets = events.read().map(|v| &v.0).collect::>(); - if sets.is_empty() {return;} + if sets.is_empty() { + return; + } info!("attaching {} sessions", sets.len()); match session.attach_action_sets(&sets) { - Ok(_) => {info!("attached sessions!")} + Ok(_) => { + info!("attached sessions!") + } Err(openxr::sys::Result::ERROR_ACTIONSETS_ALREADY_ATTACHED) => { error!("Action Sets Already attached!"); } diff --git a/crates/bevy_openxr/src/openxr/features/mod.rs b/crates/bevy_openxr/src/openxr/features/mod.rs index f68b573..ce58e91 100644 --- a/crates/bevy_openxr/src/openxr/features/mod.rs +++ b/crates/bevy_openxr/src/openxr/features/mod.rs @@ -1,3 +1,3 @@ +pub mod handtracking; #[cfg(feature = "passthrough")] pub mod passthrough; -pub mod handtracking; diff --git a/crates/bevy_openxr/src/openxr/mod.rs b/crates/bevy_openxr/src/openxr/mod.rs index c36acff..b4428e2 100644 --- a/crates/bevy_openxr/src/openxr/mod.rs +++ b/crates/bevy_openxr/src/openxr/mod.rs @@ -17,6 +17,7 @@ use self::{ pub mod action_binding; pub mod action_set_attaching; +pub mod action_set_syncing; pub mod error; mod exts; pub mod features; @@ -28,7 +29,6 @@ pub mod reference_space; pub mod render; pub mod resources; pub mod types; -pub mod action_set_syncing; pub fn add_xr_plugins(plugins: G) -> PluginGroupBuilder { plugins diff --git a/crates/bevy_openxr/src/openxr/render.rs b/crates/bevy_openxr/src/openxr/render.rs index a07f2e5..317ad69 100644 --- a/crates/bevy_openxr/src/openxr/render.rs +++ b/crates/bevy_openxr/src/openxr/render.rs @@ -10,14 +10,17 @@ use bevy::{ }, transform::TransformSystem, }; -use bevy_xr::{camera::{XrCamera, XrCameraBundle, XrProjection}, session::session_running}; +use bevy_xr::{ + camera::{XrCamera, XrCameraBundle, XrProjection}, + session::session_running, +}; use openxr::ViewStateFlags; -use crate::{reference_space::OxrPrimaryReferenceSpace, resources::*}; use crate::{ init::{session_started, OxrPreUpdateSet, OxrTrackingRoot}, layer_builder::ProjectionLayer, }; +use crate::{reference_space::OxrPrimaryReferenceSpace, resources::*}; pub struct OxrRenderPlugin; diff --git a/crates/bevy_webxr/src/webxr/mod.rs b/crates/bevy_webxr/src/webxr/mod.rs index e69de29..8b13789 100644 --- a/crates/bevy_webxr/src/webxr/mod.rs +++ b/crates/bevy_webxr/src/webxr/mod.rs @@ -0,0 +1 @@ + diff --git a/crates/bevy_xr/macros/src/lib.rs b/crates/bevy_xr/macros/src/lib.rs index a51475d..927b6da 100644 --- a/crates/bevy_xr/macros/src/lib.rs +++ b/crates/bevy_xr/macros/src/lib.rs @@ -1,11 +1,11 @@ use proc_macro::TokenStream; use proc_macro2::Span; use quote::quote; +use syn::parse::{Parse, ParseStream}; use syn::punctuated::Punctuated; use syn::spanned::Spanned; use syn::token::{Comma, Eq}; use syn::{parse_macro_input, parse_quote, AttrStyle, DeriveInput, Expr, Type}; -use syn::parse::{Parse, ParseStream}; mod kw { syn::custom_keyword!(action_type); @@ -36,7 +36,6 @@ impl Parse for AttributeInput { } } - #[proc_macro_derive(Action, attributes(action))] pub fn derive_action(input: TokenStream) -> TokenStream { let input = parse_macro_input!(input as DeriveInput); @@ -44,9 +43,17 @@ pub fn derive_action(input: TokenStream) -> TokenStream { let mut attributes = vec![]; for attribute in input.attrs { if let AttrStyle::Inner(token) = attribute.style { - return TokenStream::from(syn::Error::new(token.span, "This derive macro does not accept inner attributes").to_compile_error()); + return TokenStream::from( + syn::Error::new( + token.span, + "This derive macro does not accept inner attributes", + ) + .to_compile_error(), + ); }; - let parsed_attributes = match attribute.parse_args_with(Punctuated::::parse_terminated) { + let parsed_attributes = match attribute + .parse_args_with(Punctuated::::parse_terminated) + { Ok(inner) => inner, Err(e) => return TokenStream::from(e.to_compile_error()), }; @@ -61,27 +68,39 @@ pub fn derive_action(input: TokenStream) -> TokenStream { match attribute { AttributeInput::Kind(ty, span) => { if kind.is_some() { - return syn::Error::new(span, "attribute 'action_type' is defined more than once").to_compile_error().into(); + return syn::Error::new( + span, + "attribute 'action_type' is defined more than once", + ) + .to_compile_error() + .into(); } kind = Some(ty); - }, + } AttributeInput::Name(expr, span) => { if name.is_some() { - return syn::Error::new(span, "attribute 'name' is defined more than once").to_compile_error().into(); + return syn::Error::new(span, "attribute 'name' is defined more than once") + .to_compile_error() + .into(); } name = Some(expr); - }, + } AttributeInput::PrettyName(expr, span) => { if pretty_name.is_some() { - return syn::Error::new(span, "attribute 'pretty_name' is defined more than once").to_compile_error().into(); + return syn::Error::new( + span, + "attribute 'pretty_name' is defined more than once", + ) + .to_compile_error() + .into(); } pretty_name = Some(expr); - }, + } } - }; + } if kind.is_none() { panic!("action_type isn't specified") @@ -114,4 +133,4 @@ pub fn derive_action(input: TokenStream) -> TokenStream { }; TokenStream::from(expanded) -} \ No newline at end of file +} diff --git a/crates/bevy_xr/src/hands.rs b/crates/bevy_xr/src/hands.rs index b74f7cd..ebb9f3b 100644 --- a/crates/bevy_xr/src/hands.rs +++ b/crates/bevy_xr/src/hands.rs @@ -1,7 +1,11 @@ -use bevy::{ecs::component::Component, math::bool, prelude::{Deref, DerefMut}}; +use bevy::{ + ecs::component::Component, + math::bool, + prelude::{Deref, DerefMut}, +}; #[repr(transparent)] -#[derive(Clone, Copy, Component, Debug,DerefMut,Deref)] +#[derive(Clone, Copy, Component, Debug, DerefMut, Deref)] pub struct HandBoneRadius(pub f32); #[repr(u8)] diff --git a/crates/bevy_xr/src/lib.rs b/crates/bevy_xr/src/lib.rs index b415641..de0bfef 100644 --- a/crates/bevy_xr/src/lib.rs +++ b/crates/bevy_xr/src/lib.rs @@ -1,5 +1,5 @@ pub mod actions; pub mod camera; +pub mod hands; pub mod session; pub mod types; -pub mod hands; diff --git a/crates/bevy_xr/src/session.rs b/crates/bevy_xr/src/session.rs index f9dfba6..7783f94 100644 --- a/crates/bevy_xr/src/session.rs +++ b/crates/bevy_xr/src/session.rs @@ -89,7 +89,9 @@ pub fn handle_session( } /// A [`Condition`](bevy::ecs::schedule::Condition) that allows the system to run when the xr status changed to a specific [`XrStatus`]. -pub fn status_changed_to(status: XrStatus) -> impl FnMut(EventReader) -> bool + Clone { +pub fn status_changed_to( + status: XrStatus, +) -> impl FnMut(EventReader) -> bool + Clone { move |mut reader: EventReader| { reader.read().any(|new_status| new_status.0 == status) } diff --git a/crates/bevy_xr/src/types.rs b/crates/bevy_xr/src/types.rs index 4241ae8..7cedb64 100644 --- a/crates/bevy_xr/src/types.rs +++ b/crates/bevy_xr/src/types.rs @@ -2,5 +2,5 @@ use bevy::math::{Quat, Vec3}; pub struct Pose { pub position: Vec3, - pub orientation: Quat -} \ No newline at end of file + pub orientation: Quat, +} diff --git a/crates/bevy_xr_utils/src/lib.rs b/crates/bevy_xr_utils/src/lib.rs index 5c9d6f8..a90007b 100644 --- a/crates/bevy_xr_utils/src/lib.rs +++ b/crates/bevy_xr_utils/src/lib.rs @@ -1,3 +1,2 @@ // use bevy::prelude::*; pub mod hand_gizmos; - diff --git a/examples/3d_scene.rs b/examples/3d_scene.rs deleted file mode 100644 index 560f7c2..0000000 --- a/examples/3d_scene.rs +++ /dev/null @@ -1,46 +0,0 @@ -//! A simple 3D scene with light shining over a cube sitting on a plane. - -use bevy::prelude::*; - -fn main() { - App::new() - .add_plugins(DefaultPlugins) - .add_systems(Startup, setup) - .run(); -} - -/// set up a simple 3D scene -fn setup( - mut commands: Commands, - mut meshes: ResMut>, - mut materials: ResMut>, -) { - // circular base - commands.spawn(PbrBundle { - mesh: meshes.add(Circle::new(4.0)), - material: materials.add(Color::WHITE), - transform: Transform::from_rotation(Quat::from_rotation_x(-std::f32::consts::FRAC_PI_2)), - ..default() - }); - // cube - commands.spawn(PbrBundle { - mesh: meshes.add(Cuboid::new(1.0, 1.0, 1.0)), - material: materials.add(Color::rgb_u8(124, 144, 255)), - transform: Transform::from_xyz(0.0, 0.5, 0.0), - ..default() - }); - // light - commands.spawn(PointLightBundle { - point_light: PointLight { - shadows_enabled: true, - ..default() - }, - transform: Transform::from_xyz(4.0, 8.0, 4.0), - ..default() - }); - // camera - commands.spawn(Camera3dBundle { - transform: Transform::from_xyz(-2.5, 4.5, 9.0).looking_at(Vec3::ZERO, Vec3::Y), - ..default() - }); -} \ No newline at end of file