more required components and other stuff

Signed-off-by: Schmarni <marnistromer@gmail.com>
This commit is contained in:
Schmarni
2024-11-26 23:03:57 +01:00
parent a04ebb8426
commit 307bba3323
4 changed files with 20 additions and 12 deletions

View File

@@ -2,17 +2,11 @@ use std::ops::Deref;
use bevy::prelude::*;
use bevy_mod_openxr::{
action_binding::{OxrSendActionBindings, OxrSuggestActionBinding},
action_set_attaching::OxrAttachActionSet,
action_set_syncing::{OxrActionSetSyncSet, OxrSyncActionSet},
add_xr_plugins,
resources::OxrInstance,
session::OxrSession,
spaces::OxrSpaceExt,
action_binding::{OxrSendActionBindings, OxrSuggestActionBinding}, action_set_attaching::OxrAttachActionSet, action_set_syncing::{OxrActionSetSyncSet, OxrSyncActionSet}, add_xr_plugins, openxr_session_running, resources::OxrInstance, session::OxrSession, spaces::OxrSpaceExt
};
use bevy_mod_xr::{
session::{session_available, session_running, XrSessionCreated},
spaces::XrSpace,
spaces::{XrSpace, XrSpaceLocationFlags},
};
use openxr::Posef;
@@ -25,7 +19,7 @@ fn main() {
PreUpdate,
sync_actions
.before(OxrActionSetSyncSet)
.run_if(session_running),
.run_if(openxr_session_running),
);
app.add_systems(OxrSendActionBindings, suggest_action_bindings);
app.add_systems(Startup, create_actions.run_if(session_available));
@@ -131,12 +125,16 @@ fn spawn_hands(
Mesh3d(meshes.add(Cuboid::new(0.1, 0.1, 0.05))),
MeshMaterial3d(materials.add(Color::srgb_u8(124, 144, 255))),
left_space,
// runtime required components are not inserted for non runrime required components, should
// be fixed in the final bevy 0.15 release
XrSpaceLocationFlags::default(),
Controller,
));
cmds.spawn((
Mesh3d(meshes.add(Cuboid::new(0.1, 0.1, 0.05))),
MeshMaterial3d(materials.add(Color::srgb_u8(124, 144, 255))),
right_space,
XrSpaceLocationFlags::default(),
Controller,
));
}

View File

@@ -1,12 +1,19 @@
//! A simple 3D scene with light shining over a cube sitting on a plane.
use bevy::prelude::*;
use bevy_mod_openxr::add_xr_plugins;
use bevy_mod_openxr::{add_xr_plugins, init::OxrInitPlugin};
use bevy_mod_xr::session::{XrSessionPlugin, XrState};
fn main() {
App::new()
.add_plugins(add_xr_plugins(DefaultPlugins).set(XrSessionPlugin { auto_handle: true }))
.add_plugins(
add_xr_plugins(DefaultPlugins)
.set(XrSessionPlugin { auto_handle: true })
.set(OxrInitPlugin {
blend_modes: Some(vec![openxr::EnvironmentBlendMode::OPAQUE]),
..Default::default()
}),
)
.add_plugins(bevy_xr_utils::hand_gizmos::HandGizmosPlugin)
.add_systems(Startup, setup)
.add_systems(Update, handle_input)

View File

@@ -22,7 +22,6 @@ fn sync_sets(session: Res<OxrSession>, mut events: EventReader<OxrSyncActionSet>
.map(|v| &v.0)
.map(openxr::ActiveActionSet::new)
.collect::<Vec<_>>();
if sets.is_empty() {
return;
}

View File

@@ -29,6 +29,10 @@ impl OxrExtensions {
self.0.ext_hand_tracking = false;
self
}
pub fn enable_extx_overlay(&mut self) -> &mut Self {
self.0.extx_overlay = true;
self
}
/// returns true if all of the extensions enabled are also available in `available_exts`
pub fn is_available(&self, available_exts: &OxrExtensions) -> bool {
self.clone() & available_exts.clone() == *self