clean up passthrough, change hand entity behavior and add cleanup steps to some plugins
This commit is contained in:
@@ -16,10 +16,10 @@ bevy_oxr.path = "../.."
|
||||
bevy = "0.12"
|
||||
openxr = { git = "https://github.com/Ralith/openxrs", rev = "0177d2d", features = ["mint"] }
|
||||
|
||||
[profile.release]
|
||||
lto = "fat"
|
||||
codegen-units = 1
|
||||
panic = "abort"
|
||||
# [profile.release]
|
||||
# lto = "fat"
|
||||
# codegen-units = 1
|
||||
# panic = "abort"
|
||||
|
||||
# This metadata is used by `cargo-apk` - `xbuild` uses the `manifest.yaml` instead.
|
||||
[package.metadata.android]
|
||||
|
||||
@@ -3,10 +3,10 @@ use bevy::prelude::*;
|
||||
use bevy::transform::components::Transform;
|
||||
use bevy_oxr::graphics::extensions::XrExtensions;
|
||||
use bevy_oxr::graphics::XrAppInfo;
|
||||
use bevy_oxr::graphics::XrPreferdBlendMode::AlphaBlend;
|
||||
use bevy_oxr::passthrough::{passthrough_layer_pause, passthrough_layer_resume};
|
||||
use bevy_oxr::xr_init::XrRenderData;
|
||||
use bevy_oxr::passthrough::{PausePassthrough, ResumePassthrough, XrPassthroughState};
|
||||
use bevy_oxr::xr_init::xr_only;
|
||||
use bevy_oxr::xr_input::debug_gizmos::OpenXrDebugRenderer;
|
||||
use bevy_oxr::xr_input::hands::HandBone;
|
||||
use bevy_oxr::xr_input::prototype_locomotion::{proto_locomotion, PrototypeLocomotionConfig};
|
||||
use bevy_oxr::xr_input::trackers::{
|
||||
OpenXRController, OpenXRLeftController, OpenXRRightController, OpenXRTracker,
|
||||
@@ -25,16 +25,23 @@ fn main() {
|
||||
},
|
||||
prefered_blend_mode: bevy_oxr::graphics::XrPreferdBlendMode::Opaque,
|
||||
})
|
||||
.add_plugins(OpenXrDebugRenderer)
|
||||
// .add_plugins(OpenXrDebugRenderer)
|
||||
.add_plugins(LogDiagnosticsPlugin::default())
|
||||
.add_plugins(FrameTimeDiagnosticsPlugin)
|
||||
.add_systems(Startup, setup)
|
||||
.add_systems(Update, (proto_locomotion, toggle_passthrough))
|
||||
.add_systems(Update, (proto_locomotion, toggle_passthrough).run_if(xr_only()))
|
||||
.add_systems(Update, debug_hand_render.run_if(xr_only()))
|
||||
.add_systems(Startup, spawn_controllers_example)
|
||||
.insert_resource(PrototypeLocomotionConfig::default())
|
||||
.run();
|
||||
}
|
||||
|
||||
fn debug_hand_render(query: Query<&GlobalTransform, With<HandBone>>, mut gizmos: Gizmos) {
|
||||
for transform in &query {
|
||||
gizmos.sphere(transform.translation(), Quat::IDENTITY, 0.01, Color::RED);
|
||||
}
|
||||
}
|
||||
|
||||
/// set up a simple 3D scene
|
||||
fn setup(
|
||||
mut commands: Commands,
|
||||
@@ -90,15 +97,18 @@ fn spawn_controllers_example(mut commands: Commands) {
|
||||
));
|
||||
}
|
||||
|
||||
// Does this work? Not getting logs
|
||||
fn toggle_passthrough(keys: Res<Input<KeyCode>>, mut xr_data: ResMut<XrRenderData>) {
|
||||
// TODO: make this a vr button
|
||||
fn toggle_passthrough(
|
||||
keys: Res<Input<KeyCode>>,
|
||||
passthrough_state: Res<XrPassthroughState>,
|
||||
mut resume: EventWriter<ResumePassthrough>,
|
||||
mut pause: EventWriter<PausePassthrough>,
|
||||
) {
|
||||
if keys.just_pressed(KeyCode::Space) {
|
||||
if xr_data.xr_passthrough_active {
|
||||
passthrough_layer_pause(xr_data);
|
||||
bevy::log::info!("Passthrough paused");
|
||||
} else {
|
||||
passthrough_layer_resume(xr_data);
|
||||
bevy::log::info!("Passthrough resumed");
|
||||
match *passthrough_state {
|
||||
XrPassthroughState::Unsupported => {}
|
||||
XrPassthroughState::Running => pause.send_default(),
|
||||
XrPassthroughState::Paused => resume.send_default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ use bevy_oxr::{
|
||||
xr_input::{
|
||||
actions::XrActionSets,
|
||||
debug_gizmos::OpenXrDebugRenderer,
|
||||
hands::common::{HandInputDebugRenderer, HandResource, HandsResource, OpenXrHandInput},
|
||||
hands::common::{HandInputDebugRenderer, HandResource, HandsResource},
|
||||
hands::HandBone,
|
||||
interactions::{
|
||||
draw_interaction_gizmos, draw_socket_gizmos, interactions, socket_interactions,
|
||||
@@ -120,7 +120,7 @@ pub fn main() {
|
||||
//test capsule
|
||||
.add_systems(Startup, spawn_capsule)
|
||||
//physics hands
|
||||
.add_plugins(OpenXrHandInput)
|
||||
// .add_plugins(OpenXrHandInput)
|
||||
.add_plugins(HandInputDebugRenderer)
|
||||
.add_systems(Startup, spawn_physics_hands)
|
||||
.add_systems(
|
||||
|
||||
@@ -3,7 +3,7 @@ use bevy::prelude::*;
|
||||
use bevy::transform::components::Transform;
|
||||
use bevy_oxr::graphics::XrAppInfo;
|
||||
use bevy_oxr::resources::XrViews;
|
||||
use bevy_oxr::xr_input::hands::common::{HandInputDebugRenderer, OpenXrHandInput};
|
||||
use bevy_oxr::xr_input::hands::common::HandInputDebugRenderer;
|
||||
use bevy_oxr::xr_input::interactions::{
|
||||
InteractionEvent, XRDirectInteractor, XRInteractorState, XRRayInteractor, XRSocketInteractor,
|
||||
};
|
||||
@@ -31,7 +31,6 @@ fn main() {
|
||||
.add_systems(Update, (proto_locomotion, pull_to_ground).chain())
|
||||
.insert_resource(PrototypeLocomotionConfig::default())
|
||||
.add_systems(Startup, spawn_controllers_example)
|
||||
.add_plugins(OpenXrHandInput)
|
||||
.add_plugins(HandInputDebugRenderer)
|
||||
.add_event::<InteractionEvent>()
|
||||
.run();
|
||||
|
||||
@@ -7,7 +7,7 @@ use bevy_oxr::input::XrInput;
|
||||
use bevy_oxr::resources::{XrFrameState, XrSession};
|
||||
|
||||
use bevy_oxr::xr_input::actions::XrActionSets;
|
||||
use bevy_oxr::xr_input::hands::common::{HandInputDebugRenderer, OpenXrHandInput};
|
||||
use bevy_oxr::xr_input::hands::common::HandInputDebugRenderer;
|
||||
use bevy_oxr::xr_input::interactions::{
|
||||
draw_interaction_gizmos, draw_socket_gizmos, interactions, socket_interactions,
|
||||
update_interactable_states, InteractionEvent, Touched, XRDirectInteractor, XRInteractable,
|
||||
@@ -39,7 +39,6 @@ fn main() {
|
||||
.add_systems(Update, proto_locomotion)
|
||||
.insert_resource(PrototypeLocomotionConfig::default())
|
||||
.add_systems(Startup, spawn_controllers_example)
|
||||
.add_plugins(OpenXrHandInput)
|
||||
.add_plugins(HandInputDebugRenderer)
|
||||
.add_systems(
|
||||
Update,
|
||||
|
||||
Reference in New Issue
Block a user