Skip to content

Commit

Permalink
Migrate to bevy 0.12 and bevy_oxr (#40)
Browse files Browse the repository at this point in the history
* Migrate to bevy 0.12 and bevy_oxr

* Use default oxr features

* Flake is cross platform

* Fix clippy

* use alsa-lib.dev
  • Loading branch information
TheButlah authored Nov 18, 2023
1 parent 360b04e commit 11b60b4
Show file tree
Hide file tree
Showing 11 changed files with 757 additions and 2,420 deletions.
3,077 changes: 704 additions & 2,373 deletions Cargo.lock

Large diffs are not rendered by default.

19 changes: 11 additions & 8 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,20 @@ edition = "2021"
rust-version = "1.73.0"

[workspace.dependencies]
bevy = "0.11.2"
bevy_mod_picking = "0.15.0"
bevy = "0.12.0"
bevy_mod_picking = "0.17.0"
color-eyre = "0.6"
eyre = "0.6"
tracing = "0.1"
bevy_egui = "0.21"
egui-wgpu = "0.22"
egui = "0.22"
bevy-inspector-egui = "0.19"
wgpu = "0.16"
bevy_flycam = { git = "https://github.com/sburris0/bevy_flycam", branch = "bevy_0.11" }
bevy_egui = "0.23"
egui-wgpu = "0.23"
egui = "0.23"
bevy-inspector-egui = "0.21.0"
wgpu = "0.17"
bevy_flycam = "0.12"
bevy_oxr = "0.1"
openxr = "0.17.1"
bevy_mod_inverse_kinematics = "0.5"

# Enable a small amount of optimization in debug mode
[profile.dev]
Expand Down
24 changes: 12 additions & 12 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 7 additions & 5 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -40,22 +40,24 @@
nativeBuildInputs = [
rustToolchain
pkgs.pkg-config
pkgs.androidenv.androidPkgs_9_0.androidsdk

# Common cargo tools we often use
pkgs.cargo-deny
pkgs.cargo-expand
pkgs.cargo-binutils
pkgs.cargo-apk
pkgs.cargo-apk
# cmake for openxr
pkgs.cmake
];
] ++ pkgs.lib.optionals (!pkgs.stdenv.isDarwin) (with pkgs; [
androidenv.androidPkgs_9_0.androidsdk
]);

# see https://github.com/NixOS/nixpkgs/blob/95b81c96f863ca8911dffcda45d1937efcd66a4b/pkgs/games/jumpy/default.nix#L60C5-L60C38
buildInputs = [
pkgs.zstd
rustPlatform.bindgenHook
] ++ pkgs.lib.optionals pkgs.stdenv.isLinux (with pkgs; [
alsa-lib
alsa-lib.dev
libxkbcommon
udev
vulkan-loader
Expand All @@ -64,9 +66,9 @@
xorg.libXcursor
xorg.libXi
xorg.libXrandr
openxr-loader
]) ++ pkgs.lib.optionals pkgs.stdenv.isDarwin [
pkgs.darwin.apple_sdk.frameworks.Cocoa
rustPlatform.bindgenHook
# # This is missing on mac m1 nix, for some reason.
# # see https://stackoverflow.com/a/69732679
pkgs.libiconv
Expand Down
2 changes: 1 addition & 1 deletion skills/cube/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ fn main() -> Result<()> {

App::new()
.add_plugins(DefaultPlugins.set(AssetPlugin {
asset_folder: ASSET_FOLDER.to_string(),
file_path: ASSET_FOLDER.to_string(),
..Default::default()
}))
.add_systems(Startup, setup)
Expand Down
2 changes: 1 addition & 1 deletion skills/ik/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ rust-version.workspace = true

[dependencies]
bevy.workspace = true
bevy_mod_inverse_kinematics = "0.4.0"
bevy_mod_inverse_kinematics.workspace = true
4 changes: 2 additions & 2 deletions skills/ik/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ fn main() {
})
.insert_resource(DirectionalLightShadowMap { size: 4096 })
.add_plugins(DefaultPlugins.set(AssetPlugin {
asset_folder: ASSET_FOLDER.to_string(),
file_path: ASSET_FOLDER.to_string(),
..Default::default()
}))
.add_plugins(InverseKinematicsPlugin)
Expand Down Expand Up @@ -181,7 +181,7 @@ fn manually_target(
) {
let (camera, transform) = camera_query.single();

if let Some(event) = cursor.iter().last() {
if let Some(event) = cursor.read().last() {
let view = transform.compute_matrix();
let viewport_rect = camera.logical_viewport_rect().unwrap();
let viewport_size = viewport_rect.size();
Expand Down
9 changes: 5 additions & 4 deletions skills/manipulation-flatscreen/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
use bevy::ecs::system::EntityCommands;
use bevy::{pbr::DirectionalLightShadowMap, prelude::*};
use bevy_mod_picking::backends::raycast::RaycastPickable;
use bevy_mod_picking::events::Drag;
use bevy_mod_picking::pointer::PointerButton;
use bevy_mod_picking::prelude::{On, Pointer, RaycastPickCamera, RaycastPickTarget};
use bevy_mod_picking::prelude::{On, Pointer};
use bevy_mod_picking::{DefaultPickingPlugins, PickableBundle};
use color_eyre::eyre::Result;
use tracing::info;
Expand All @@ -17,7 +18,7 @@ fn main() -> Result<()> {

App::new()
.add_plugins(DefaultPlugins.set(AssetPlugin {
asset_folder: ASSET_FOLDER.to_string(),
file_path: ASSET_FOLDER.to_string(),
..Default::default()
}))
.add_plugins(DefaultPickingPlugins)
Expand Down Expand Up @@ -60,7 +61,7 @@ pub fn add_events(entity_commands: &mut EntityCommands) {
}
}),
PickableBundle::default(), // Makes the entity pickable
RaycastPickTarget::default(),
RaycastPickable,
));
}

Expand Down Expand Up @@ -103,7 +104,7 @@ fn setup(
.looking_at(Vec3::new(0., 1., 0.), Vec3::Y),
..default()
},
RaycastPickCamera::default(),
RaycastPickable,
));
commands.spawn(PbrBundle {
mesh: meshes.add(
Expand Down
8 changes: 4 additions & 4 deletions skills/openxr-6dof/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ edition.workspace = true
rust-version.workspace = true

[lib]
crate-type = ["staticlib", "cdylib", "rlib"]
crate-type = ["cdylib", "rlib"]

[dependencies]
openxr = { version = "0.17.1" }
bevy = "0.12"
bevy_oxr = { version = "0.1", default-features = false }
openxr.workspace = true
bevy.workspace = true
bevy_oxr.workspace = true
color-eyre.workspace = true
6 changes: 3 additions & 3 deletions skills/xr-ik-mirror/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ rust-version.workspace = true
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
bevy = { git = "https://github.com/awtterpip/bevy" }
bevy_openxr = { git = "https://github.com/awtterpip/bevy_openxr", features = ["linked"] }
bevy.workspace = true
bevy_oxr.workspace = true
color-eyre.workspace = true
bevy_mod_inverse_kinematics = { git = "https://github.com/MalekiRe/bevy_mod_inverse_kinematics"}
bevy_mod_inverse_kinematics.workspace = true
14 changes: 7 additions & 7 deletions skills/xr-ik-mirror/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ use bevy::render::render_resource::{
};
use bevy::transform::components::Transform;

use bevy_openxr::input::XrInput;
use bevy_openxr::resources::XrFrameState;
use bevy_openxr::xr_input::oculus_touch::OculusController;
use bevy_openxr::xr_input::{QuatConv, Vec3Conv};
use bevy_openxr::DefaultXrPlugins;
use bevy_oxr::input::XrInput;
use bevy_oxr::resources::XrFrameState;
use bevy_oxr::xr_input::oculus_touch::OculusController;
use bevy_oxr::xr_input::{QuatConv, Vec3Conv};
use bevy_oxr::DefaultXrPlugins;

const ASSET_FOLDER: &str = concat!(env!("CARGO_MANIFEST_DIR"), "/../../assets/");

Expand Down Expand Up @@ -46,7 +46,7 @@ fn setup(
mut materials: ResMut<Assets<StandardMaterial>>,
) {
let bevy_mirror_dwelling_img: Handle<Image> =
assets.load(&(ASSET_FOLDER.to_string() + "bevy_mirror_dwelling.png"));
assets.load(ASSET_FOLDER.to_string() + "bevy_mirror_dwelling.png");
commands.spawn(PbrBundle {
mesh: meshes.add(shape::Cube::default().into()),
material: materials.add(StandardMaterial {
Expand Down Expand Up @@ -164,7 +164,7 @@ fn setup(
},));
commands.spawn((
SceneBundle {
scene: assets.load(&(ASSET_FOLDER.to_string() + "/malek.gltf#Scene0")),
scene: assets.load(ASSET_FOLDER.to_string() + "/malek.gltf#Scene0"),
transform: Transform::from_xyz(0.0, 0.0, 0.0).with_rotation(
Quat::from_euler(EulerRot::XYZ, 0.0, 0.0_f32.to_radians(), 0.0),
),
Expand Down

0 comments on commit 11b60b4

Please sign in to comment.