diff --git a/Cargo.toml b/Cargo.toml index f2f2a8d..5ffbed4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "bevy_oxr" +name = "bevy_mod_xr_backends" version = "0.1.0" edition = "2021" description = "Community crate for OpenXR in Bevy" @@ -7,9 +7,9 @@ repository = "https://github.com/awtterpip/bevy_oxr" license = "MIT/Apache-2.0" [dependencies] -bevy_openxr.path = "./crates/bevy_openxr" -bevy_xr.path = "./crates/bevy_xr" -bevy = "0.13.0" +bevy_mod_openxr.path = "./crates/bevy_openxr" +bevy_mod_xr.path = "./crates/bevy_xr" +bevy.workspace = true [workspace] members = ["crates/*", "crates/bevy_openxr/examples/android"] diff --git a/crates/bevy_openxr/Cargo.toml b/crates/bevy_openxr/Cargo.toml index fa09d98..fa0c017 100644 --- a/crates/bevy_openxr/Cargo.toml +++ b/crates/bevy_openxr/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "bevy_openxr" +name = "bevy_mod_openxr" version = "0.1.0" edition = "2021" @@ -26,7 +26,7 @@ openxr = "0.18.0" thiserror = "1.0.57" wgpu = "0.19.3" wgpu-hal = "0.19.3" -bevy_xr.path = "../bevy_xr" +bevy_mod_xr.path = "../bevy_xr" ash = { version = "0.37.3", optional = true } diff --git a/crates/bevy_openxr/examples/3d_scene.rs b/crates/bevy_openxr/examples/3d_scene.rs index dfc60a7..e216cd3 100644 --- a/crates/bevy_openxr/examples/3d_scene.rs +++ b/crates/bevy_openxr/examples/3d_scene.rs @@ -1,7 +1,7 @@ //! A simple 3D scene with light shining over a cube sitting on a plane. use bevy::prelude::*; -use bevy_openxr::add_xr_plugins; +use bevy_mod_openxr::add_xr_plugins; fn main() { App::new() diff --git a/crates/bevy_openxr/examples/actions.rs b/crates/bevy_openxr/examples/actions.rs index 9ba6916..a98d444 100644 --- a/crates/bevy_openxr/examples/actions.rs +++ b/crates/bevy_openxr/examples/actions.rs @@ -1,7 +1,7 @@ // a simple example showing basic actions using the xr utils actions use bevy::{math::vec3, prelude::*}; -use bevy_openxr::{add_xr_plugins, helper_traits::ToQuat, resources::OxrViews}; -use bevy_xr::session::XrTrackingRoot; +use bevy_mod_openxr::{add_xr_plugins, helper_traits::ToQuat, resources::OxrViews}; +use bevy_mod_xr::session::XrTrackingRoot; use bevy_xr_utils::xr_utils_actions::{ ActiveSet, XRUtilsAction, XRUtilsActionSet, XRUtilsActionState, XRUtilsActionSystemSet, XRUtilsActionsPlugin, XRUtilsBinding, @@ -75,7 +75,7 @@ fn create_action_entities(mut commands: Commands) { XRUtilsAction { action_name: "flight_input".into(), localized_name: "flight_input_localized".into(), - action_type: bevy_xr::actions::ActionType::Vector, + action_type: bevy_mod_xr::actions::ActionType::Vector, }, FlightActionMarker, //lets try a marker component )) diff --git a/crates/bevy_openxr/examples/android/Cargo.toml b/crates/bevy_openxr/examples/android/Cargo.toml index 24f89a6..dbfe3a3 100644 --- a/crates/bevy_openxr/examples/android/Cargo.toml +++ b/crates/bevy_openxr/examples/android/Cargo.toml @@ -6,7 +6,7 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -bevy_openxr.path = "../.." +bevy_mod_openxr.path = "../.." bevy.workspace = true bevy_xr_utils.path = "../../../bevy_xr_utils" diff --git a/crates/bevy_openxr/examples/android/src/lib.rs b/crates/bevy_openxr/examples/android/src/lib.rs index 9866566..490970e 100644 --- a/crates/bevy_openxr/examples/android/src/lib.rs +++ b/crates/bevy_openxr/examples/android/src/lib.rs @@ -1,7 +1,7 @@ //! A simple 3D scene with light shining over a cube sitting on a plane. use bevy::prelude::*; -use bevy_openxr::{add_xr_plugins, init::OxrInitPlugin, types::OxrExtensions}; +use bevy_mod_openxr::{add_xr_plugins, init::OxrInitPlugin, types::OxrExtensions}; #[bevy_main] fn main() { diff --git a/crates/bevy_openxr/examples/overlay.rs b/crates/bevy_openxr/examples/overlay.rs index 8821026..f6fcb61 100644 --- a/crates/bevy_openxr/examples/overlay.rs +++ b/crates/bevy_openxr/examples/overlay.rs @@ -1,8 +1,8 @@ //! A simple 3D scene with light shining over a cube sitting on a plane. use bevy::prelude::*; -use bevy_openxr::{add_xr_plugins, init::OxrInitPlugin, types::OxrExtensions}; -use bevy_xr::session::XrState; +use bevy_mod_openxr::{add_xr_plugins, init::OxrInitPlugin, types::OxrExtensions}; +use bevy_mod_xr::session::XrState; // use openxr::EnvironmentBlendMode; // use wgpu::TextureFormat; @@ -40,11 +40,11 @@ fn main() { fn handle_input( keys: Res>, - mut end: EventWriter, - mut destroy: EventWriter, - mut begin: EventWriter, - mut create: EventWriter, - mut request_exit: EventWriter, + mut end: EventWriter, + mut destroy: EventWriter, + mut begin: EventWriter, + mut create: EventWriter, + mut request_exit: EventWriter, state: Res, ) { if keys.just_pressed(KeyCode::KeyE) { diff --git a/crates/bevy_openxr/examples/raw_actions.rs b/crates/bevy_openxr/examples/raw_actions.rs index aa6a71e..a34d1f8 100644 --- a/crates/bevy_openxr/examples/raw_actions.rs +++ b/crates/bevy_openxr/examples/raw_actions.rs @@ -1,7 +1,7 @@ use std::ops::Deref; use bevy::prelude::*; -use bevy_openxr::{ +use bevy_mod_openxr::{ action_binding::{OxrSendActionBindings, OxrSuggestActionBinding}, action_set_attaching::OxrAttachActionSet, action_set_syncing::{OxrActionSetSyncSet, OxrSyncActionSet}, @@ -11,7 +11,7 @@ use bevy_openxr::{ session::OxrSession, spaces::OxrSpaceExt, }; -use bevy_xr::{ +use bevy_mod_xr::{ session::{session_available, XrCreateSession, XrTrackingRoot}, spaces::XrSpace, types::XrPose, diff --git a/crates/bevy_openxr/examples/sessions.rs b/crates/bevy_openxr/examples/sessions.rs index 4371043..9dbbbc1 100644 --- a/crates/bevy_openxr/examples/sessions.rs +++ b/crates/bevy_openxr/examples/sessions.rs @@ -1,8 +1,8 @@ //! A simple 3D scene with light shining over a cube sitting on a plane. use bevy::prelude::*; -use bevy_openxr::add_xr_plugins; -use bevy_xr::session::{XrSessionPlugin, XrState}; +use bevy_mod_openxr::add_xr_plugins; +use bevy_mod_xr::session::{XrSessionPlugin, XrState}; fn main() { App::new() @@ -16,11 +16,11 @@ fn main() { fn handle_input( keys: Res>, - mut end: EventWriter, - mut destroy: EventWriter, - mut begin: EventWriter, - mut create: EventWriter, - mut request_exit: EventWriter, + mut end: EventWriter, + mut destroy: EventWriter, + mut begin: EventWriter, + mut create: EventWriter, + mut request_exit: EventWriter, state: Res, ) { if keys.just_pressed(KeyCode::KeyE) { diff --git a/crates/bevy_openxr/examples/transform_utils.rs b/crates/bevy_openxr/examples/transform_utils.rs index 04db5b6..4275c0d 100644 --- a/crates/bevy_openxr/examples/transform_utils.rs +++ b/crates/bevy_openxr/examples/transform_utils.rs @@ -1,7 +1,7 @@ //! A simple example of how to use the transform utils to set the players position and orientation use bevy::prelude::*; -use bevy_openxr::add_xr_plugins; +use bevy_mod_openxr::add_xr_plugins; use bevy_xr_utils::transform_utils::{self, SnapToPosition, SnapToRotation}; use bevy_xr_utils::xr_utils_actions::{ ActiveSet, XRUtilsAction, XRUtilsActionSet, XRUtilsActionState, XRUtilsActionSystemSet, @@ -110,7 +110,7 @@ fn create_action_entities(mut commands: Commands) { XRUtilsAction { action_name: "face_red".into(), localized_name: "face_red_localized".into(), - action_type: bevy_xr::actions::ActionType::Bool, + action_type: bevy_mod_xr::actions::ActionType::Bool, }, FaceRedAction, //lets try a marker component )) @@ -134,7 +134,7 @@ fn create_action_entities(mut commands: Commands) { XRUtilsAction { action_name: "center".into(), localized_name: "center_localized".into(), - action_type: bevy_xr::actions::ActionType::Bool, + action_type: bevy_mod_xr::actions::ActionType::Bool, }, Center, //lets try a marker component )) diff --git a/crates/bevy_openxr/src/openxr/action_binding.rs b/crates/bevy_openxr/src/openxr/action_binding.rs index 723680d..fb53eee 100644 --- a/crates/bevy_openxr/src/openxr/action_binding.rs +++ b/crates/bevy_openxr/src/openxr/action_binding.rs @@ -5,7 +5,7 @@ use bevy::ecs::schedule::ScheduleLabel; use bevy::ecs::system::RunSystemOnce; use bevy::prelude::*; use bevy::utils::HashMap; -use bevy_xr::session::XrSessionCreatedEvent; +use bevy_mod_xr::session::XrSessionCreatedEvent; use openxr::sys::ActionSuggestedBinding; use crate::resources::OxrInstance; diff --git a/crates/bevy_openxr/src/openxr/action_set_attaching.rs b/crates/bevy_openxr/src/openxr/action_set_attaching.rs index ce07ba8..f8c1618 100644 --- a/crates/bevy_openxr/src/openxr/action_set_attaching.rs +++ b/crates/bevy_openxr/src/openxr/action_set_attaching.rs @@ -1,6 +1,6 @@ use crate::{action_binding::run_action_binding_sugestion, session::OxrSession}; use bevy::prelude::*; -use bevy_xr::session::XrSessionCreatedEvent; +use bevy_mod_xr::session::XrSessionCreatedEvent; impl Plugin for OxrActionAttachingPlugin { fn build(&self, app: &mut App) { diff --git a/crates/bevy_openxr/src/openxr/action_set_syncing.rs b/crates/bevy_openxr/src/openxr/action_set_syncing.rs index 77d9b60..53f5930 100644 --- a/crates/bevy_openxr/src/openxr/action_set_syncing.rs +++ b/crates/bevy_openxr/src/openxr/action_set_syncing.rs @@ -1,6 +1,6 @@ use crate::session::OxrSession; use bevy::prelude::*; -use bevy_xr::session::session_running; +use bevy_mod_xr::session::session_running; #[derive(SystemSet, Debug, Hash, PartialEq, Eq, Clone, Copy)] pub struct OxrActionSetSyncSet; diff --git a/crates/bevy_openxr/src/openxr/features/handtracking.rs b/crates/bevy_openxr/src/openxr/features/handtracking.rs index b8ce037..ff4beee 100644 --- a/crates/bevy_openxr/src/openxr/features/handtracking.rs +++ b/crates/bevy_openxr/src/openxr/features/handtracking.rs @@ -1,8 +1,8 @@ use bevy::prelude::*; -use bevy_xr::hands::{LeftHand, RightHand}; -use bevy_xr::session::{XrCreateSession, XrDestroySession, XrTrackingRoot}; -use bevy_xr::spaces::{XrPrimaryReferenceSpace, XrReferenceSpace}; -use bevy_xr::{ +use bevy_mod_xr::hands::{LeftHand, RightHand, XrHandBoneEntities, HAND_JOINT_COUNT}; +use bevy_mod_xr::session::{XrCreateSession, XrDestroySession, XrTrackingRoot}; +use bevy_mod_xr::spaces::{XrPrimaryReferenceSpace, XrReferenceSpace}; +use bevy_mod_xr::{ hands::{HandBone, HandBoneRadius}, session::session_running, }; @@ -39,6 +39,22 @@ impl Plugin for HandTrackingPlugin { } } +pub fn spawn_hand_bones( + cmds: &mut Commands, + bundle: T, +) -> [Entity; HAND_JOINT_COUNT] { + let mut bones: [Entity; HAND_JOINT_COUNT] = [Entity::PLACEHOLDER; HAND_JOINT_COUNT]; + // screw you clippy, i don't see a better way to init this array + #[allow(clippy::needless_range_loop)] + for bone in HandBone::get_all_bones().into_iter() { + bones[bone as usize] = cmds + .spawn((SpatialBundle::default(), bone, HandBoneRadius(0.0))) + .insert(bundle.clone()) + .id(); + } + bones +} + fn spawn_default_hands( mut cmds: Commands, session: Res, @@ -71,49 +87,27 @@ fn spawn_default_hands( return; } }; - let mut left_bones = [Entity::PLACEHOLDER; 26]; - let mut right_bones = [Entity::PLACEHOLDER; 26]; - for bone in HandBone::get_all_bones() { - let bone_left = cmds - .spawn(( - DefaultHandBone, - SpatialBundle::default(), - bone, - HandBoneRadius(0.0), - LeftHand, - )) - .id(); - let bone_right = cmds - .spawn(( - DefaultHandBone, - SpatialBundle::default(), - bone, - HandBoneRadius(0.0), - RightHand, - )) - .id(); - cmds.entity(root).push_children(&[bone_left]); - cmds.entity(root).push_children(&[bone_right]); - left_bones[bone as usize] = bone_left; - right_bones[bone as usize] = bone_right; - } + let left_bones = spawn_hand_bones(&mut cmds, (DefaultHandBone, LeftHand)); + let right_bones = spawn_hand_bones(&mut cmds, (DefaultHandBone, RightHand)); + cmds.entity(root).push_children(&left_bones); + cmds.entity(root).push_children(&right_bones); cmds.spawn(( DefaultHandTracker, OxrHandTracker(tracker_left), - OxrHandBoneEntities(left_bones), + XrHandBoneEntities(left_bones), LeftHand, )); cmds.spawn(( DefaultHandTracker, OxrHandTracker(tracker_right), - OxrHandBoneEntities(right_bones), + XrHandBoneEntities(right_bones), RightHand, )); } -#[derive(Component)] +#[derive(Component, Clone, Copy)] struct DefaultHandTracker; -#[derive(Component)] +#[derive(Component, Clone, Copy)] struct DefaultHandBone; #[allow(clippy::type_complexity)] @@ -127,9 +121,6 @@ fn clean_up_default_hands( } } -#[derive(Deref, DerefMut, Component, Clone, Copy)] -pub struct OxrHandBoneEntities(pub [Entity; 26]); - #[derive(Deref, DerefMut, Component)] pub struct OxrHandTracker(pub openxr::HandTracker); @@ -139,7 +130,7 @@ fn locate_hands( tracker_query: Query<( &OxrHandTracker, Option<&XrReferenceSpace>, - &OxrHandBoneEntities, + &XrHandBoneEntities, )>, session: Res, mut bone_query: Query<(&HandBone, &mut HandBoneRadius, &mut Transform)>, diff --git a/crates/bevy_openxr/src/openxr/features/overlay.rs b/crates/bevy_openxr/src/openxr/features/overlay.rs index 6924436..107048b 100644 --- a/crates/bevy_openxr/src/openxr/features/overlay.rs +++ b/crates/bevy_openxr/src/openxr/features/overlay.rs @@ -1,7 +1,7 @@ use std::{mem, ptr}; use bevy::prelude::*; -use bevy_xr::session::session_available; +use bevy_mod_xr::session::session_available; use openxr::sys; use crate::{ diff --git a/crates/bevy_openxr/src/openxr/helper_traits.rs b/crates/bevy_openxr/src/openxr/helper_traits.rs index 96df775..996f5a4 100644 --- a/crates/bevy_openxr/src/openxr/helper_traits.rs +++ b/crates/bevy_openxr/src/openxr/helper_traits.rs @@ -1,5 +1,5 @@ use bevy::prelude::*; -use bevy_xr::types::XrPose; +use bevy_mod_xr::types::XrPose; pub trait ToPosef { fn to_posef(&self) -> openxr::Posef; diff --git a/crates/bevy_openxr/src/openxr/init.rs b/crates/bevy_openxr/src/openxr/init.rs index 0093a65..84faa9b 100644 --- a/crates/bevy_openxr/src/openxr/init.rs +++ b/crates/bevy_openxr/src/openxr/init.rs @@ -11,7 +11,7 @@ use bevy::render::RenderApp; use bevy::render::RenderPlugin; use bevy::winit::UpdateMode; use bevy::winit::WinitSettings; -use bevy_xr::session::*; +use bevy_mod_xr::session::*; use crate::error::OxrError; use crate::features::overlay::OxrOverlaySessionEvent; diff --git a/crates/bevy_openxr/src/openxr/layer_builder.rs b/crates/bevy_openxr/src/openxr/layer_builder.rs index a8ae794..7bab5d4 100644 --- a/crates/bevy_openxr/src/openxr/layer_builder.rs +++ b/crates/bevy_openxr/src/openxr/layer_builder.rs @@ -1,7 +1,7 @@ use std::mem; use bevy::ecs::world::World; -use bevy_xr::spaces::{XrPrimaryReferenceSpace, XrSpace}; +use bevy_mod_xr::spaces::{XrPrimaryReferenceSpace, XrSpace}; use openxr::{sys, CompositionLayerFlags, Fovf, Posef, Rect2Di}; use crate::graphics::graphics_match; diff --git a/crates/bevy_openxr/src/openxr/mod.rs b/crates/bevy_openxr/src/openxr/mod.rs index ed8e9ce..3e6bc36 100644 --- a/crates/bevy_openxr/src/openxr/mod.rs +++ b/crates/bevy_openxr/src/openxr/mod.rs @@ -5,8 +5,8 @@ use bevy::{ utils::default, window::{PresentMode, Window, WindowPlugin}, }; -use bevy_xr::camera::XrCameraPlugin; -use bevy_xr::session::XrSessionPlugin; +use bevy_mod_xr::camera::XrCameraPlugin; +use bevy_mod_xr::session::XrSessionPlugin; use init::OxrInitPlugin; use render::OxrRenderPlugin; diff --git a/crates/bevy_openxr/src/openxr/reference_space.rs b/crates/bevy_openxr/src/openxr/reference_space.rs index 6c63386..e6321c8 100644 --- a/crates/bevy_openxr/src/openxr/reference_space.rs +++ b/crates/bevy_openxr/src/openxr/reference_space.rs @@ -2,7 +2,7 @@ use bevy::{ prelude::*, render::{extract_resource::ExtractResourcePlugin, RenderApp}, }; -use bevy_xr::{ +use bevy_mod_xr::{ session::{XrCreateSession, XrDestroySession}, spaces::{XrPrimaryReferenceSpace, XrReferenceSpace}, }; diff --git a/crates/bevy_openxr/src/openxr/render.rs b/crates/bevy_openxr/src/openxr/render.rs index e890c6a..9c832e3 100644 --- a/crates/bevy_openxr/src/openxr/render.rs +++ b/crates/bevy_openxr/src/openxr/render.rs @@ -10,7 +10,7 @@ use bevy::{ }, transform::TransformSystem, }; -use bevy_xr::{ +use bevy_mod_xr::{ camera::{XrCamera, XrCameraBundle, XrProjection}, session::{ XrDestroySession, XrFirst, XrHandleEvents, XrRenderSet, XrRootTransform, XrTrackingRoot, diff --git a/crates/bevy_openxr/src/openxr/spaces.rs b/crates/bevy_openxr/src/openxr/spaces.rs index 86d9e9f..0a6e60e 100644 --- a/crates/bevy_openxr/src/openxr/spaces.rs +++ b/crates/bevy_openxr/src/openxr/spaces.rs @@ -1,7 +1,7 @@ use std::{mem::MaybeUninit, ptr, sync::Mutex}; use bevy::{prelude::*, utils::hashbrown::HashSet}; -use bevy_xr::{ +use bevy_mod_xr::{ session::{session_available, session_running, XrFirst, XrHandleEvents}, spaces::{XrDestroySpace, XrPrimaryReferenceSpace, XrReferenceSpace, XrSpace, XrSpatialOffset}, types::XrPose, diff --git a/crates/bevy_webxr/Cargo.toml b/crates/bevy_webxr/Cargo.toml index 199548b..55e1cb2 100644 --- a/crates/bevy_webxr/Cargo.toml +++ b/crates/bevy_webxr/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "bevy_webxr" +name = "bevy_mod_webxr" version = "0.1.0" edition = "2021" @@ -13,4 +13,4 @@ thiserror = "1.0.57" wgpu = "0.19.3" wgpu-hal = "0.19.3" -bevy_xr.path = "../bevy_xr" +bevy_mod_xr.path = "../bevy_xr" diff --git a/crates/bevy_webxr/README.md b/crates/bevy_webxr/README.md new file mode 100644 index 0000000..4acdf44 --- /dev/null +++ b/crates/bevy_webxr/README.md @@ -0,0 +1,2 @@ +# Bevy WebXR +currently not yet in a working state diff --git a/crates/bevy_xr/Cargo.toml b/crates/bevy_xr/Cargo.toml index 25ca19b..71977bf 100644 --- a/crates/bevy_xr/Cargo.toml +++ b/crates/bevy_xr/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "bevy_xr" +name = "bevy_mod_xr" version = "0.1.0" edition = "2021" @@ -7,4 +7,3 @@ edition = "2021" [dependencies] bevy.workspace = true -bevy_xr_macros.path = "macros" diff --git a/crates/bevy_xr/macros/Cargo.toml b/crates/bevy_xr/macros/Cargo.toml deleted file mode 100644 index 38074e9..0000000 --- a/crates/bevy_xr/macros/Cargo.toml +++ /dev/null @@ -1,12 +0,0 @@ -[package] -name = "bevy_xr_macros" -version = "0.1.0" -edition = "2021" - -[lib] -proc-macro = true - -[dependencies] -proc-macro2 = "1.0" -quote = "1.0" -syn = "2.0" diff --git a/crates/bevy_xr/macros/src/lib.rs b/crates/bevy_xr/macros/src/lib.rs deleted file mode 100644 index 927b6da..0000000 --- a/crates/bevy_xr/macros/src/lib.rs +++ /dev/null @@ -1,136 +0,0 @@ -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}; - -mod kw { - syn::custom_keyword!(action_type); - syn::custom_keyword!(name); - syn::custom_keyword!(pretty_name); -} - -enum AttributeInput { - Kind(Type, Span), - Name(Expr, Span), - PrettyName(Expr, Span), -} - -impl Parse for AttributeInput { - fn parse(input: ParseStream) -> syn::Result { - if let Ok(field) = input.parse::() { - input.parse::()?; - Ok(Self::Kind(input.parse()?, field.span())) - } else if let Ok(field) = input.parse::() { - input.parse::()?; - Ok(Self::Name(input.parse()?, field.span())) - } else if let Ok(field) = input.parse::() { - input.parse::()?; - Ok(Self::PrettyName(input.parse()?, field.span())) - } else { - Err(input.error("expected 'action_type', 'name' or 'pretty_name'")) - } - } -} - -#[proc_macro_derive(Action, attributes(action))] -pub fn derive_action(input: TokenStream) -> TokenStream { - let input = parse_macro_input!(input as DeriveInput); - let item = input.ident; - 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(), - ); - }; - let parsed_attributes = match attribute - .parse_args_with(Punctuated::::parse_terminated) - { - Ok(inner) => inner, - Err(e) => return TokenStream::from(e.to_compile_error()), - }; - for attr in parsed_attributes { - attributes.push(attr); - } - } - let mut kind: Option = None; - let mut name: Option = None; - let mut pretty_name: Option = None; - for attribute in attributes { - 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(); - } - - 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(); - } - - 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(); - } - - pretty_name = Some(expr); - } - } - } - - if kind.is_none() { - panic!("action_type isn't specified") - } - if name.is_none() { - name = Some(parse_quote! { - std::stringify!(#item) - }); - } - if pretty_name.is_none() { - pretty_name = name.clone(); - } - let kind = kind.unwrap(); - let name = name.unwrap(); - let pretty_name = pretty_name.unwrap(); - - let expanded = quote! { - impl bevy_xr::actions::Action for #item { - type ActionType = #kind; - - fn info() -> bevy_xr::actions::ActionInfo { - bevy_xr::actions::ActionInfo { - pretty_name: #pretty_name, - name: #name, - action_type: ::TYPE, - type_id: std::any::TypeId::of::(), - } - } - } - }; - - TokenStream::from(expanded) -} diff --git a/crates/bevy_xr/src/actions.rs b/crates/bevy_xr/src/actions.rs index 7234392..b7034f3 100644 --- a/crates/bevy_xr/src/actions.rs +++ b/crates/bevy_xr/src/actions.rs @@ -3,7 +3,6 @@ use std::{any::TypeId, marker::PhantomData}; use bevy::app::{App, Plugin}; use bevy::ecs::system::Resource; use bevy::math::Vec2; -pub use bevy_xr_macros::Action; pub struct ActionPlugin(PhantomData); diff --git a/crates/bevy_xr/src/hands.rs b/crates/bevy_xr/src/hands.rs index 37571b4..82e400a 100644 --- a/crates/bevy_xr/src/hands.rs +++ b/crates/bevy_xr/src/hands.rs @@ -1,8 +1,9 @@ use bevy::{ - ecs::component::Component, + ecs::{component::Component, entity::Entity}, math::bool, prelude::{Deref, DerefMut}, }; +pub const HAND_JOINT_COUNT: usize = 26; #[derive(Clone, Copy, Component, Debug)] pub struct LeftHand; @@ -10,6 +11,9 @@ pub struct LeftHand; #[derive(Clone, Copy, Component, Debug)] pub struct RightHand; +#[derive(Deref, DerefMut, Component, Clone, Copy)] +pub struct XrHandBoneEntities(pub [Entity; HAND_JOINT_COUNT]); + #[repr(transparent)] #[derive(Clone, Copy, Component, Debug, DerefMut, Deref)] pub struct HandBoneRadius(pub f32); diff --git a/crates/bevy_xr_utils/Cargo.toml b/crates/bevy_xr_utils/Cargo.toml index 3b622ac..3e200ec 100644 --- a/crates/bevy_xr_utils/Cargo.toml +++ b/crates/bevy_xr_utils/Cargo.toml @@ -7,6 +7,8 @@ edition = "2021" [dependencies] bevy.workspace = true -bevy_xr.path = "../bevy_xr" +bevy_mod_xr.path = "../bevy_xr" +bevy_mod_openxr.path = "../bevy_openxr" + +[target.'cfg(not(target_family = "wasm"))'.dependencies] openxr = "0.18.0" -bevy_openxr.path = "../bevy_openxr" diff --git a/crates/bevy_xr_utils/src/hand_gizmos.rs b/crates/bevy_xr_utils/src/hand_gizmos.rs index f284480..88230e7 100644 --- a/crates/bevy_xr_utils/src/hand_gizmos.rs +++ b/crates/bevy_xr_utils/src/hand_gizmos.rs @@ -1,5 +1,5 @@ use bevy::{prelude::*, transform::TransformSystem}; -use bevy_xr::hands::{HandBone, HandBoneRadius}; +use bevy_mod_xr::hands::{HandBone, HandBoneRadius}; pub struct HandGizmosPlugin; impl Plugin for HandGizmosPlugin { fn build(&self, app: &mut App) { diff --git a/crates/bevy_xr_utils/src/lib.rs b/crates/bevy_xr_utils/src/lib.rs index 6db8e46..df9edfd 100644 --- a/crates/bevy_xr_utils/src/lib.rs +++ b/crates/bevy_xr_utils/src/lib.rs @@ -1,4 +1,6 @@ // use bevy::prelude::*; pub mod hand_gizmos; +#[cfg(not(target_family = "wasm"))] pub mod xr_utils_actions; +#[cfg(not(target_family = "wasm"))] pub mod transform_utils; diff --git a/crates/bevy_xr_utils/src/transform_utils.rs b/crates/bevy_xr_utils/src/transform_utils.rs index e992395..61d16de 100644 --- a/crates/bevy_xr_utils/src/transform_utils.rs +++ b/crates/bevy_xr_utils/src/transform_utils.rs @@ -1,9 +1,9 @@ use bevy::prelude::*; -use bevy_openxr::{ +use bevy_mod_openxr::{ helper_traits::{ToQuat, ToVec3}, resources::OxrViews, }; -use bevy_xr::session::XrTrackingRoot; +use bevy_mod_xr::session::XrTrackingRoot; pub struct TransformUtilitiesPlugin; diff --git a/crates/bevy_xr_utils/src/xr_utils_actions.rs b/crates/bevy_xr_utils/src/xr_utils_actions.rs index b89c422..0919567 100644 --- a/crates/bevy_xr_utils/src/xr_utils_actions.rs +++ b/crates/bevy_xr_utils/src/xr_utils_actions.rs @@ -21,7 +21,7 @@ //! XRUtilsAction { //! action_name: "flight_input".into(), //! localized_name: "flight_input_localized".into(), -//! action_type: bevy_xr::actions::ActionType::Vector, +//! action_type: bevy_mod_xr::actions::ActionType::Vector, //! }, //! FlightActionMarker, //lets try a marker component //! )) @@ -54,12 +54,12 @@ //! //! use bevy::prelude::*; -use bevy_openxr::{ +use bevy_mod_openxr::{ action_binding::OxrSuggestActionBinding, action_set_attaching::OxrAttachActionSet, action_set_syncing::OxrActionSetSyncSet, action_set_syncing::OxrSyncActionSet, resources::OxrInstance, session::OxrSession, }; -use bevy_xr::session::{session_available, session_running}; +use bevy_mod_xr::session::{session_available, session_running}; use openxr::{Path, Vector2f}; use std::borrow::Cow; @@ -131,7 +131,7 @@ fn create_openxr_events( let (create_action, bindings) = actions_query.get(child).unwrap(); //lets create dat action match create_action.action_type { - bevy_xr::actions::ActionType::Bool => { + bevy_mod_xr::actions::ActionType::Bool => { let action: openxr::Action = action_set .create_action::( &create_action.action_name, @@ -169,7 +169,7 @@ fn create_openxr_events( binding_writer.send(sugestion); } } - bevy_xr::actions::ActionType::Float => { + bevy_mod_xr::actions::ActionType::Float => { let action: openxr::Action = action_set .create_action::( &create_action.action_name, @@ -208,7 +208,7 @@ fn create_openxr_events( binding_writer.send(sugestion); } } - bevy_xr::actions::ActionType::Vector => { + bevy_mod_xr::actions::ActionType::Vector => { let action: openxr::Action = action_set .create_action::( &create_action.action_name, @@ -368,7 +368,7 @@ pub struct ActiveSet; pub struct XRUtilsAction { pub action_name: Cow<'static, str>, pub localized_name: Cow<'static, str>, - pub action_type: bevy_xr::actions::ActionType, + pub action_type: bevy_mod_xr::actions::ActionType, } #[derive(Component)] diff --git a/src/lib.rs b/src/lib.rs index 646e102..bcb4fdf 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,2 +1,2 @@ -pub use bevy_openxr; -pub use bevy_xr; +pub use bevy_mod_openxr; +pub use bevy_mod_xr;