Fixed some lints

This commit is contained in:
Ryan Butler
2024-02-23 00:58:39 -05:00
parent b4b36f9fb2
commit 0799670f73
3 changed files with 19 additions and 42 deletions

View File

@@ -55,6 +55,9 @@ openxr = { workspace = true, features = [ "mint", "static" ] }
ndk-context = "0.1" ndk-context = "0.1"
jni = "0.20" jni = "0.20"
[dev-dependencies]
color-eyre.workspace = true
[[example]] [[example]]
name = "xr" name = "xr"
path = "examples/xr.rs" path = "examples/xr.rs"

View File

@@ -1,27 +1,27 @@
use std::{f32::consts::PI, ops::Mul, time::Duration}; mod setup;
use std::time::Duration;
use bevy::{ use bevy::{
diagnostic::{FrameTimeDiagnosticsPlugin, LogDiagnosticsPlugin}, diagnostic::{FrameTimeDiagnosticsPlugin, LogDiagnosticsPlugin},
ecs::schedule::ScheduleLabel, ecs::schedule::ScheduleLabel,
input::{keyboard::KeyCode, ButtonInput},
log::info, log::info,
math::primitives::{Capsule3d, Cuboid}, math::primitives::{Capsule3d, Cuboid},
prelude::{ prelude::{
bevy_main, default, shape, App, Assets, Color, Commands, Component, Entity, Event, bevy_main, default, App, Assets, Color, Commands, Component, Entity, Event, EventReader,
EventReader, EventWriter, FixedUpdate, Gizmos, GlobalTransform, IntoSystemConfigs, EventWriter, FixedUpdate, GlobalTransform, IntoSystemConfigs, IntoSystemSetConfigs, Mesh,
IntoSystemSetConfigs, Mesh, PbrBundle, PostUpdate, Quat, Query, Res, ResMut, Resource, PbrBundle, PostUpdate, Query, Res, ResMut, Resource, Schedule, SpatialBundle,
Schedule, SpatialBundle, StandardMaterial, Startup, Transform, Update, Vec3, Vec3Swizzles, StandardMaterial, Startup, Transform, Update, Vec3, With, Without, World,
With, Without, World,
}, },
render::mesh::Meshable, render::mesh::Meshable,
time::{Fixed, Time, Timer, TimerMode}, time::{Fixed, Time, Timer, TimerMode},
transform::TransformSystem, transform::TransformSystem,
}; };
use bevy_oxr::{ use bevy_oxr::{
graphics::{extensions::XrExtensions, XrAppInfo, XrPreferdBlendMode}, graphics::{extensions::XrExtensions, XrAppInfo},
input::XrInput, input::XrInput,
resources::{XrFrameState, XrInstance, XrSession}, resources::{XrFrameState, XrSession},
xr_init::{xr_only, XrStatus}, xr_init::xr_only,
xr_input::{ xr_input::{
actions::XrActionSets, actions::XrActionSets,
debug_gizmos::OpenXrDebugRenderer, debug_gizmos::OpenXrDebugRenderer,
@@ -34,29 +34,12 @@ use bevy_oxr::{
}, },
oculus_touch::OculusController, oculus_touch::OculusController,
prototype_locomotion::{proto_locomotion, PrototypeLocomotionConfig}, prototype_locomotion::{proto_locomotion, PrototypeLocomotionConfig},
trackers::{ trackers::{OpenXRController, OpenXRLeftController, OpenXRRightController, OpenXRTracker},
OpenXRController, OpenXRLeftController, OpenXRRightController, OpenXRTracker,
OpenXRTrackingRoot,
},
Hand, Hand,
}, },
DefaultXrPlugins, DefaultXrPlugins,
}; };
// fn input_stuff(
// keys: Res<Input<KeyCode>>,
// status: Res<XrEnableStatus>,
// mut request: EventWriter<XrEnableRequest>,
// ) {
// if keys.just_pressed(KeyCode::Space) {
// match status.into_inner() {
// XrEnableStatus::Enabled => request.send(XrEnableRequest::TryDisable),
// XrEnableStatus::Disabled => request.send(XrEnableRequest::TryEnable),
// }
// }
// }
mod setup;
use crate::setup::setup_scene; use crate::setup::setup_scene;
use bevy_rapier3d::prelude::*; use bevy_rapier3d::prelude::*;
@@ -376,7 +359,6 @@ fn update_physics_hands(
)>, )>,
hand_query: Query<(&Transform, &HandBone, &Hand), Without<PhysicsHandBone>>, hand_query: Query<(&Transform, &HandBone, &Hand), Without<PhysicsHandBone>>,
time: Res<Time>, time: Res<Time>,
mut gizmos: Gizmos,
) { ) {
let matching = MatchingType::VelocityMatching; let matching = MatchingType::VelocityMatching;
//sanity check do we even have hands? //sanity check do we even have hands?
@@ -532,13 +514,6 @@ fn get_start_and_end_entities(
}; };
} }
fn get_hand_res(res: &Res<'_, HandsResource>, hand: Hand) -> HandResource {
match hand {
Hand::Left => res.left.clone(),
Hand::Right => res.right.clone(),
}
}
#[derive(Event, Default)] #[derive(Event, Default)]
pub struct SpawnCubeRequest; pub struct SpawnCubeRequest;
@@ -549,7 +524,6 @@ fn request_cube_spawn(
oculus_controller: Res<OculusController>, oculus_controller: Res<OculusController>,
frame_state: Res<XrFrameState>, frame_state: Res<XrFrameState>,
xr_input: Res<XrInput>, xr_input: Res<XrInput>,
instance: Res<XrInstance>,
session: Res<XrSession>, session: Res<XrSession>,
mut writer: EventWriter<SpawnCubeRequest>, mut writer: EventWriter<SpawnCubeRequest>,
time: Res<Time>, time: Res<Time>,
@@ -580,7 +554,7 @@ fn cube_spawner(
mut materials: ResMut<Assets<StandardMaterial>>, mut materials: ResMut<Assets<StandardMaterial>>,
mut events: EventReader<SpawnCubeRequest>, mut events: EventReader<SpawnCubeRequest>,
) { ) {
for request in events.read() { for _request in events.read() {
// cube // cube
commands.spawn(( commands.spawn((
PbrBundle { PbrBundle {
@@ -607,7 +581,7 @@ fn prototype_interaction_input(
xr_input: Res<XrInput>, xr_input: Res<XrInput>,
session: Res<XrSession>, session: Res<XrSession>,
mut right_interactor_query: Query< mut right_interactor_query: Query<
(&mut XRInteractorState), &mut XRInteractorState,
( (
With<XRDirectInteractor>, With<XRDirectInteractor>,
With<OpenXRRightController>, With<OpenXRRightController>,
@@ -615,7 +589,7 @@ fn prototype_interaction_input(
), ),
>, >,
mut left_interactor_query: Query< mut left_interactor_query: Query<
(&mut XRInteractorState), &mut XRInteractorState,
( (
With<XRDirectInteractor>, With<XRDirectInteractor>,
With<OpenXRLeftController>, With<OpenXRLeftController>,

View File

@@ -190,7 +190,7 @@ pub enum Backend {
#[derive(Resource)] #[derive(Resource)]
struct DoPipelinedRendering; struct DoPipelinedRendering;
fn clean_resources_render(mut cmds: &mut World) { fn clean_resources_render(cmds: &mut World) {
// let session = cmds.remove_resource::<XrSession>().unwrap(); // let session = cmds.remove_resource::<XrSession>().unwrap();
cmds.remove_resource::<XrSession>(); cmds.remove_resource::<XrSession>();
cmds.remove_resource::<XrResolution>(); cmds.remove_resource::<XrResolution>();
@@ -207,7 +207,7 @@ fn clean_resources_render(mut cmds: &mut World) {
// } // }
warn!("Cleanup Resources Render"); warn!("Cleanup Resources Render");
} }
fn clean_resources(mut cmds: &mut World) { fn clean_resources(cmds: &mut World) {
cmds.remove_resource::<XrSession>(); cmds.remove_resource::<XrSession>();
cmds.remove_resource::<XrResolution>(); cmds.remove_resource::<XrResolution>();
cmds.remove_resource::<XrFormat>(); cmds.remove_resource::<XrFormat>();