tiny clean up
This commit is contained in:
@@ -54,7 +54,7 @@ pub fn main() {
|
|||||||
.add_plugins(OpenXrDebugRenderer)
|
.add_plugins(OpenXrDebugRenderer)
|
||||||
//rapier goes here
|
//rapier goes here
|
||||||
.add_plugins(RapierPhysicsPlugin::<NoUserData>::default().with_default_system_setup(false))
|
.add_plugins(RapierPhysicsPlugin::<NoUserData>::default().with_default_system_setup(false))
|
||||||
.add_plugins(RapierDebugRenderPlugin::default())
|
// .add_plugins(RapierDebugRenderPlugin::default())
|
||||||
//lets setup the starting scene
|
//lets setup the starting scene
|
||||||
.add_systems(Startup, setup_scene)
|
.add_systems(Startup, setup_scene)
|
||||||
.add_systems(Startup, spawn_controllers_example) //you need to spawn controllers or it crashes TODO:: Fix this
|
.add_systems(Startup, spawn_controllers_example) //you need to spawn controllers or it crashes TODO:: Fix this
|
||||||
@@ -618,11 +618,11 @@ fn prototype_interaction_input(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//this terribly named event is for transitioning the physics hand in an out of existent so we can drop things better
|
//this event is for transitioning the physics hand in an out of existent so we can drop things better
|
||||||
#[derive(Event)]
|
#[derive(Event)]
|
||||||
pub struct GhostHandEvent {
|
pub struct GhostHandEvent {
|
||||||
pub hand: Hand,
|
pub hand: Hand,
|
||||||
pub desired_state: bool,
|
pub desired_state: bool, //true for no interactions, false for normal interactions
|
||||||
}
|
}
|
||||||
#[derive(Resource)]
|
#[derive(Resource)]
|
||||||
pub struct GhostTimers {
|
pub struct GhostTimers {
|
||||||
@@ -635,10 +635,10 @@ pub fn handle_ghost_hand_events(
|
|||||||
mut bones: Query<(&Hand, &mut CollisionGroups, With<PhysicsHandBone>)>,
|
mut bones: Query<(&Hand, &mut CollisionGroups, With<PhysicsHandBone>)>,
|
||||||
) {
|
) {
|
||||||
for event in events.read() {
|
for event in events.read() {
|
||||||
info!(
|
// info!(
|
||||||
"Ghost hand Event: {:?}, {:?}",
|
// "Ghost hand Event: {:?}, {:?}",
|
||||||
event.hand, event.desired_state
|
// event.hand, event.desired_state
|
||||||
);
|
// );
|
||||||
//do work
|
//do work
|
||||||
for mut bone in bones.iter_mut() {
|
for mut bone in bones.iter_mut() {
|
||||||
match *bone.0 == event.hand {
|
match *bone.0 == event.hand {
|
||||||
@@ -657,19 +657,17 @@ pub fn watch_ghost_timers(
|
|||||||
mut writer: EventWriter<GhostHandEvent>,
|
mut writer: EventWriter<GhostHandEvent>,
|
||||||
time: Res<Time>,
|
time: Res<Time>,
|
||||||
) {
|
) {
|
||||||
|
//tick both timers
|
||||||
timers.left.tick(time.delta());
|
timers.left.tick(time.delta());
|
||||||
timers.right.tick(time.delta());
|
timers.right.tick(time.delta());
|
||||||
|
//if they finish send events to make the hands physical again
|
||||||
if timers.left.just_finished() {
|
if timers.left.just_finished() {
|
||||||
info!("hey");
|
|
||||||
writer.send(GhostHandEvent {
|
writer.send(GhostHandEvent {
|
||||||
hand: Hand::Left,
|
hand: Hand::Left,
|
||||||
desired_state: false,
|
desired_state: false,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if timers.right.just_finished() {
|
if timers.right.just_finished() {
|
||||||
info!("hey");
|
|
||||||
|
|
||||||
writer.send(GhostHandEvent {
|
writer.send(GhostHandEvent {
|
||||||
hand: Hand::Right,
|
hand: Hand::Right,
|
||||||
desired_state: false,
|
desired_state: false,
|
||||||
@@ -750,7 +748,7 @@ pub fn update_grabbables(
|
|||||||
match interactor_transform.1 {
|
match interactor_transform.1 {
|
||||||
XRInteractorState::Idle => {
|
XRInteractorState::Idle => {
|
||||||
*interactor_transform.2 = XRSelection::Empty;
|
*interactor_transform.2 = XRSelection::Empty;
|
||||||
//raise leave ghost hand event
|
//reset timers to make hands physical again
|
||||||
match *interactor_transform.3 {
|
match *interactor_transform.3 {
|
||||||
Hand::Left => timers.left.reset(),
|
Hand::Left => timers.left.reset(),
|
||||||
Hand::Right => timers.right.reset(),
|
Hand::Right => timers.right.reset(),
|
||||||
|
|||||||
Reference in New Issue
Block a user