refactor: cleanup for bevy 0.16
Signed-off-by: Schmarni <marnistromer@gmail.com>
This commit is contained in:
@@ -21,8 +21,8 @@ fn main() {
|
||||
.add_systems(Update, handle_flight_input)
|
||||
// Realtime lighting is expensive, use ambient light instead
|
||||
.insert_resource(AmbientLight {
|
||||
color: Default::default(),
|
||||
brightness: 500.0,
|
||||
..AmbientLight::default()
|
||||
})
|
||||
.run();
|
||||
}
|
||||
@@ -48,7 +48,7 @@ fn setup_scene(
|
||||
|
||||
commands.spawn((
|
||||
Camera3d::default(),
|
||||
Transform::from_xyz(-2.5, 4.5, 9.0).looking_at(Vec3::ZERO, Vec3::Y),
|
||||
Transform::from_xyz(-2.5, 4.5, 9.0).looking_at(Vec3::ZERO, Vec3::Y),
|
||||
));
|
||||
}
|
||||
|
||||
@@ -132,14 +132,15 @@ fn handle_flight_input(
|
||||
//hard code speed for now
|
||||
let speed = 5.0;
|
||||
|
||||
let root = oxr_root.get_single_mut();
|
||||
let root = oxr_root.single_mut();
|
||||
match root {
|
||||
Ok(mut root_position) => {
|
||||
//lets assume HMD based direction for now
|
||||
let view = views.first();
|
||||
match view {
|
||||
Some(v) => {
|
||||
let reference_quat = root_position.rotation * v.pose.orientation.to_quat();
|
||||
let reference_quat =
|
||||
root_position.rotation * v.pose.orientation.to_quat();
|
||||
let locomotion_vector = reference_quat.mul_vec3(input_vector);
|
||||
|
||||
root_position.translation +=
|
||||
|
||||
@@ -49,23 +49,23 @@ fn handle_input(
|
||||
) {
|
||||
if keys.just_pressed(KeyCode::KeyE) {
|
||||
info!("sending end");
|
||||
end.send_default();
|
||||
end.write_default();
|
||||
}
|
||||
if keys.just_pressed(KeyCode::KeyC) {
|
||||
info!("sending create");
|
||||
create.send_default();
|
||||
create.write_default();
|
||||
}
|
||||
if keys.just_pressed(KeyCode::KeyD) {
|
||||
info!("sending destroy");
|
||||
destroy.send_default();
|
||||
destroy.write_default();
|
||||
}
|
||||
if keys.just_pressed(KeyCode::KeyB) {
|
||||
info!("sending begin");
|
||||
begin.send_default();
|
||||
begin.write_default();
|
||||
}
|
||||
if keys.just_pressed(KeyCode::KeyR) {
|
||||
info!("sending request exit");
|
||||
request_exit.send_default();
|
||||
request_exit.write_default();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ fn main() {
|
||||
}
|
||||
|
||||
fn attach_set(actions: Res<ControllerActions>, mut attach: EventWriter<OxrAttachActionSet>) {
|
||||
attach.send(OxrAttachActionSet(actions.set.clone()));
|
||||
attach.write(OxrAttachActionSet(actions.set.clone()));
|
||||
}
|
||||
|
||||
#[derive(Resource)]
|
||||
@@ -45,7 +45,7 @@ struct ControllerActions {
|
||||
right: openxr::Action<Posef>,
|
||||
}
|
||||
fn sync_actions(actions: Res<ControllerActions>, mut sync: EventWriter<OxrSyncActionSet>) {
|
||||
sync.send(OxrSyncActionSet(actions.set.clone()));
|
||||
sync.write(OxrSyncActionSet(actions.set.clone()));
|
||||
}
|
||||
/// set up a simple 3D scene
|
||||
fn setup(
|
||||
@@ -82,12 +82,12 @@ fn suggest_action_bindings(
|
||||
actions: Res<ControllerActions>,
|
||||
mut bindings: EventWriter<OxrSuggestActionBinding>,
|
||||
) {
|
||||
bindings.send(OxrSuggestActionBinding {
|
||||
bindings.write(OxrSuggestActionBinding {
|
||||
action: actions.left.as_raw(),
|
||||
interaction_profile: "/interaction_profiles/oculus/touch_controller".into(),
|
||||
bindings: vec!["/user/hand/left/input/grip/pose".into()],
|
||||
});
|
||||
bindings.send(OxrSuggestActionBinding {
|
||||
bindings.write(OxrSuggestActionBinding {
|
||||
action: actions.right.as_raw(),
|
||||
interaction_profile: "/interaction_profiles/oculus/touch_controller".into(),
|
||||
bindings: vec!["/user/hand/right/input/grip/pose".into()],
|
||||
|
||||
@@ -32,23 +32,23 @@ fn handle_input(
|
||||
) {
|
||||
if keys.just_pressed(KeyCode::KeyE) {
|
||||
info!("sending end");
|
||||
end.send_default();
|
||||
end.write_default();
|
||||
}
|
||||
if keys.just_pressed(KeyCode::KeyC) {
|
||||
info!("sending create");
|
||||
create.send_default();
|
||||
create.write_default();
|
||||
}
|
||||
if keys.just_pressed(KeyCode::KeyD) {
|
||||
info!("sending destroy");
|
||||
destroy.send_default();
|
||||
destroy.write_default();
|
||||
}
|
||||
if keys.just_pressed(KeyCode::KeyB) {
|
||||
info!("sending begin");
|
||||
begin.send_default();
|
||||
begin.write_default();
|
||||
}
|
||||
if keys.just_pressed(KeyCode::KeyR) {
|
||||
info!("sending request exit");
|
||||
request_exit.send_default();
|
||||
request_exit.write_default();
|
||||
}
|
||||
if keys.just_pressed(KeyCode::KeyI) {
|
||||
info!("current state: {:?}", *state);
|
||||
|
||||
@@ -28,8 +28,8 @@ fn main() {
|
||||
send_recenter.after(XRUtilsActionSystemSet::SyncActionStates),
|
||||
)
|
||||
.insert_resource(AmbientLight {
|
||||
color: Default::default(),
|
||||
brightness: 500.0,
|
||||
..AmbientLight::default()
|
||||
})
|
||||
.run();
|
||||
}
|
||||
@@ -161,7 +161,7 @@ fn send_look_at_red_cube_event(
|
||||
info!("send facing");
|
||||
let quat = Transform::default()
|
||||
.looking_at(Transform::from_xyz(4.0, 0.0, 0.0).translation, Vec3::Y); //this is a transform facing the red cube from the center of the scene, you should use the HMD posision but I was lazy.
|
||||
event_writer.send(SnapToRotation(quat.rotation));
|
||||
event_writer.write(SnapToRotation(quat.rotation));
|
||||
}
|
||||
}
|
||||
XRUtilsActionState::Float(_) => (),
|
||||
@@ -185,7 +185,7 @@ fn send_recenter(
|
||||
if send {
|
||||
let center = Transform::default().translation;
|
||||
|
||||
event_writer.send(SnapToPosition(center));
|
||||
event_writer.write(SnapToPosition(center));
|
||||
}
|
||||
}
|
||||
XRUtilsActionState::Float(_) => (),
|
||||
|
||||
Reference in New Issue
Block a user