upgrade all code except d3d12 and upgrade all examples except demo
Signed-off-by: Schmarni <marnistromer@gmail.com>
This commit is contained in:
2538
Cargo.lock
generated
2538
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
10
Cargo.toml
10
Cargo.toml
@@ -12,7 +12,7 @@ repository = "https://github.com/awtterpip/bevy_oxr"
|
|||||||
|
|
||||||
[workspace.dependencies]
|
[workspace.dependencies]
|
||||||
eyre = "0.6.2"
|
eyre = "0.6.2"
|
||||||
bevy = "0.13"
|
bevy = "0.14.0-rc.3"
|
||||||
openxr = "0.18"
|
openxr = "0.18"
|
||||||
color-eyre = "0.6.2"
|
color-eyre = "0.6.2"
|
||||||
|
|
||||||
@@ -36,9 +36,9 @@ bevy.workspace = true
|
|||||||
eyre.workspace = true
|
eyre.workspace = true
|
||||||
futures-lite = "2.0.1"
|
futures-lite = "2.0.1"
|
||||||
mint = "0.5.9"
|
mint = "0.5.9"
|
||||||
wgpu = "0.19"
|
wgpu = "0.20"
|
||||||
wgpu-core = { version = "0.19" }
|
wgpu-core = "0.21"
|
||||||
wgpu-hal = "0.19"
|
wgpu-hal = "0.21"
|
||||||
|
|
||||||
[target.'cfg(windows)'.dependencies]
|
[target.'cfg(windows)'.dependencies]
|
||||||
openxr = { workspace = true, features = [ "linked", "static", "mint" ] }
|
openxr = { workspace = true, features = [ "linked", "static", "mint" ] }
|
||||||
@@ -68,4 +68,4 @@ debug = true
|
|||||||
[package.metadata.docs.rs]
|
[package.metadata.docs.rs]
|
||||||
rustdoc-args = ["-Zunstable-options", "--cfg", "docsrs"]
|
rustdoc-args = ["-Zunstable-options", "--cfg", "docsrs"]
|
||||||
all-features = true
|
all-features = true
|
||||||
cargo-args = ["-Zunstable-options", "-Zrustdoc-scrape-examples"]
|
cargo-args = ["-Zunstable-options", "-Zrustdoc-scrape-examples"]
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ crate-type = ["rlib", "cdylib"]
|
|||||||
|
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
bevy = "0.13"
|
bevy.workspace = true
|
||||||
bevy_oxr.path = "../.."
|
bevy_oxr.path = "../.."
|
||||||
openxr = { workspace = true, features = ["mint"] }
|
openxr = { workspace = true, features = ["mint"] }
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
use bevy::color::palettes;
|
||||||
use bevy::diagnostic::{FrameTimeDiagnosticsPlugin, LogDiagnosticsPlugin};
|
use bevy::diagnostic::{FrameTimeDiagnosticsPlugin, LogDiagnosticsPlugin};
|
||||||
use bevy::prelude::*;
|
use bevy::prelude::*;
|
||||||
use bevy::transform::components::Transform;
|
use bevy::transform::components::Transform;
|
||||||
@@ -44,7 +45,7 @@ fn main() {
|
|||||||
|
|
||||||
fn debug_hand_render(query: Query<&GlobalTransform, With<HandBone>>, mut gizmos: Gizmos) {
|
fn debug_hand_render(query: Query<&GlobalTransform, With<HandBone>>, mut gizmos: Gizmos) {
|
||||||
for transform in &query {
|
for transform in &query {
|
||||||
gizmos.sphere(transform.translation(), Quat::IDENTITY, 0.01, Color::RED);
|
gizmos.sphere(transform.translation(), Quat::IDENTITY, 0.01, palettes::css::RED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -56,21 +57,21 @@ fn setup(
|
|||||||
) {
|
) {
|
||||||
// plane
|
// plane
|
||||||
commands.spawn(PbrBundle {
|
commands.spawn(PbrBundle {
|
||||||
mesh: meshes.add(Plane3d::new(Vec3::Y)),
|
mesh: meshes.add(Plane3d::new(Vec3::Y,Vec2::splat(2.5))),
|
||||||
material: materials.add(StandardMaterial::from(Color::rgb(0.3, 0.5, 0.3))),
|
material: materials.add(StandardMaterial::from(Color::srgb(0.3, 0.5, 0.3))),
|
||||||
..default()
|
..default()
|
||||||
});
|
});
|
||||||
// cube
|
// cube
|
||||||
commands.spawn(PbrBundle {
|
commands.spawn(PbrBundle {
|
||||||
mesh: meshes.add(Cuboid::from_size(Vec3::splat(0.1)).mesh()),
|
mesh: meshes.add(Cuboid::from_size(Vec3::splat(0.1)).mesh()),
|
||||||
material: materials.add(StandardMaterial::from(Color::rgb(0.8, 0.7, 0.6))),
|
material: materials.add(StandardMaterial::from(Color::srgb(0.8, 0.7, 0.6))),
|
||||||
transform: Transform::from_xyz(0.0, 0.5, 0.0),
|
transform: Transform::from_xyz(0.0, 0.5, 0.0),
|
||||||
..default()
|
..default()
|
||||||
});
|
});
|
||||||
// cube
|
// cube
|
||||||
commands.spawn(PbrBundle {
|
commands.spawn(PbrBundle {
|
||||||
mesh: meshes.add(Mesh::from(Cuboid::from_size(Vec3::splat(0.1)))),
|
mesh: meshes.add(Mesh::from(Cuboid::from_size(Vec3::splat(0.1)))),
|
||||||
material: materials.add(StandardMaterial::from(Color::rgb(0.8, 0.0, 0.0))),
|
material: materials.add(StandardMaterial::from(Color::srgb(0.8, 0.0, 0.0))),
|
||||||
transform: Transform::from_xyz(0.0, 0.5, 1.0),
|
transform: Transform::from_xyz(0.0, 0.5, 1.0),
|
||||||
..default()
|
..default()
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ fn setup(
|
|||||||
// cube
|
// cube
|
||||||
commands.spawn(PbrBundle {
|
commands.spawn(PbrBundle {
|
||||||
mesh: meshes.add(Cuboid::from_size(Vec3::splat(0.1)).mesh()),
|
mesh: meshes.add(Cuboid::from_size(Vec3::splat(0.1)).mesh()),
|
||||||
material: materials.add(StandardMaterial::from(Color::rgb(0.8, 0.7, 0.6))),
|
material: materials.add(StandardMaterial::from(Color::srgb(0.8, 0.7, 0.6))),
|
||||||
transform: Transform::from_xyz(0.0, 0.5, 0.0),
|
transform: Transform::from_xyz(0.0, 0.5, 0.0),
|
||||||
..default()
|
..default()
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -92,14 +92,14 @@ fn setup(
|
|||||||
) {
|
) {
|
||||||
// plane
|
// plane
|
||||||
commands.spawn(PbrBundle {
|
commands.spawn(PbrBundle {
|
||||||
mesh: meshes.add(Plane3d::new(Vec3::Y).mesh()),
|
mesh: meshes.add(Plane3d::new(Vec3::Y, Vec2::splat(2.5)).mesh()),
|
||||||
material: materials.add(StandardMaterial::from(Color::rgb(0.3, 0.5, 0.3))),
|
material: materials.add(StandardMaterial::from(Color::srgb(0.3, 0.5, 0.3))),
|
||||||
..default()
|
..default()
|
||||||
});
|
});
|
||||||
// cube
|
// cube
|
||||||
commands.spawn(PbrBundle {
|
commands.spawn(PbrBundle {
|
||||||
mesh: meshes.add(Cuboid::from_size(Vec3::splat(0.1)).mesh()),
|
mesh: meshes.add(Cuboid::from_size(Vec3::splat(0.1)).mesh()),
|
||||||
material: materials.add(StandardMaterial::from(Color::rgb(0.8, 0.7, 0.6))),
|
material: materials.add(StandardMaterial::from(Color::srgb(0.8, 0.7, 0.6))),
|
||||||
transform: Transform::from_xyz(0.0, 0.5, 0.0),
|
transform: Transform::from_xyz(0.0, 0.5, 0.0),
|
||||||
..default()
|
..default()
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -5,11 +5,13 @@ mod d3d12;
|
|||||||
#[cfg(feature = "vulkan")]
|
#[cfg(feature = "vulkan")]
|
||||||
mod vulkan;
|
mod vulkan;
|
||||||
|
|
||||||
|
use std::sync::Arc;
|
||||||
|
|
||||||
use bevy::ecs::query::With;
|
use bevy::ecs::query::With;
|
||||||
use bevy::ecs::system::{Query, SystemState};
|
use bevy::ecs::system::{Query, SystemState};
|
||||||
use bevy::ecs::world::World;
|
use bevy::ecs::world::World;
|
||||||
use bevy::render::renderer::{
|
use bevy::render::renderer::{
|
||||||
RenderAdapter, RenderAdapterInfo, RenderDevice, RenderInstance, RenderQueue,
|
RenderAdapter, RenderAdapterInfo, RenderDevice, RenderInstance, RenderQueue, WgpuWrapper,
|
||||||
};
|
};
|
||||||
use bevy::window::{PrimaryWindow, RawHandleWrapper};
|
use bevy::window::{PrimaryWindow, RawHandleWrapper};
|
||||||
use wgpu::Instance;
|
use wgpu::Instance;
|
||||||
@@ -228,7 +230,7 @@ pub fn try_full_init(
|
|||||||
render_queue,
|
render_queue,
|
||||||
render_adapter_info,
|
render_adapter_info,
|
||||||
render_adapter,
|
render_adapter,
|
||||||
RenderInstance(wgpu_instance.into()),
|
RenderInstance(Arc::new(WgpuWrapper::new(wgpu_instance))),
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,9 @@ use std::sync::{Arc, Mutex};
|
|||||||
use ash::vk::{self, Handle};
|
use ash::vk::{self, Handle};
|
||||||
use bevy::math::uvec2;
|
use bevy::math::uvec2;
|
||||||
use bevy::prelude::*;
|
use bevy::prelude::*;
|
||||||
use bevy::render::renderer::{RenderAdapter, RenderAdapterInfo, RenderDevice, RenderQueue};
|
use bevy::render::renderer::{
|
||||||
|
RenderAdapter, RenderAdapterInfo, RenderDevice, RenderQueue, WgpuWrapper,
|
||||||
|
};
|
||||||
use bevy::window::RawHandleWrapper;
|
use bevy::window::RawHandleWrapper;
|
||||||
use eyre::{Context, ContextCompat};
|
use eyre::{Context, ContextCompat};
|
||||||
use openxr as xr;
|
use openxr as xr;
|
||||||
@@ -304,9 +306,9 @@ pub fn initialize_xr_instance(
|
|||||||
}),
|
}),
|
||||||
blend_mode.into(),
|
blend_mode.into(),
|
||||||
wgpu_device.into(),
|
wgpu_device.into(),
|
||||||
RenderQueue(wgpu_queue.into()),
|
RenderQueue(Arc::new(WgpuWrapper::new(wgpu_queue))),
|
||||||
RenderAdapterInfo(wgpu_adapter.get_info()),
|
RenderAdapterInfo(WgpuWrapper::new(wgpu_adapter.get_info())),
|
||||||
RenderAdapter(wgpu_adapter.into()),
|
RenderAdapter(Arc::new(WgpuWrapper::new(wgpu_adapter))),
|
||||||
wgpu_instance.into(),
|
wgpu_instance.into(),
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ pub mod xr_init;
|
|||||||
pub mod xr_input;
|
pub mod xr_input;
|
||||||
|
|
||||||
use std::sync::atomic::AtomicBool;
|
use std::sync::atomic::AtomicBool;
|
||||||
|
use std::sync::Arc;
|
||||||
|
|
||||||
use crate::xr_init::{StartXrSession, XrInitPlugin};
|
use crate::xr_init::{StartXrSession, XrInitPlugin};
|
||||||
use crate::xr_input::oculus_touch::ActionSets;
|
use crate::xr_input::oculus_touch::ActionSets;
|
||||||
@@ -18,7 +19,7 @@ use bevy::ecs::system::SystemState;
|
|||||||
use bevy::prelude::*;
|
use bevy::prelude::*;
|
||||||
use bevy::render::camera::{ManualTextureView, ManualTextureViewHandle, ManualTextureViews};
|
use bevy::render::camera::{ManualTextureView, ManualTextureViewHandle, ManualTextureViews};
|
||||||
use bevy::render::pipelined_rendering::PipelinedRenderingPlugin;
|
use bevy::render::pipelined_rendering::PipelinedRenderingPlugin;
|
||||||
use bevy::render::renderer::{render_system, RenderInstance};
|
use bevy::render::renderer::{render_system, RenderInstance, WgpuWrapper};
|
||||||
use bevy::render::settings::RenderCreation;
|
use bevy::render::settings::RenderCreation;
|
||||||
use bevy::render::{Render, RenderApp, RenderPlugin, RenderSet};
|
use bevy::render::{Render, RenderApp, RenderPlugin, RenderSet};
|
||||||
use bevy::window::{PresentMode, PrimaryWindow, RawHandleWrapper};
|
use bevy::window::{PresentMode, PrimaryWindow, RawHandleWrapper};
|
||||||
@@ -61,8 +62,8 @@ impl Plugin for OpenXrPlugin {
|
|||||||
#[cfg(not(target_arch = "wasm32"))]
|
#[cfg(not(target_arch = "wasm32"))]
|
||||||
match graphics::initialize_xr_instance(
|
match graphics::initialize_xr_instance(
|
||||||
&self.backend_preference,
|
&self.backend_preference,
|
||||||
SystemState::<Query<&RawHandleWrapper, With<PrimaryWindow>>>::new(&mut app.world)
|
SystemState::<Query<&RawHandleWrapper, With<PrimaryWindow>>>::new(app.world_mut())
|
||||||
.get(&app.world)
|
.get(&app.world())
|
||||||
.get_single()
|
.get_single()
|
||||||
.ok()
|
.ok()
|
||||||
.cloned(),
|
.cloned(),
|
||||||
@@ -89,7 +90,7 @@ impl Plugin for OpenXrPlugin {
|
|||||||
app.insert_resource(xr_instance);
|
app.insert_resource(xr_instance);
|
||||||
app.insert_resource(blend_mode);
|
app.insert_resource(blend_mode);
|
||||||
app.insert_non_send_resource(oxr_session_setup_info);
|
app.insert_non_send_resource(oxr_session_setup_info);
|
||||||
let render_instance = RenderInstance(instance.into());
|
let render_instance = RenderInstance(Arc::new(WgpuWrapper::new(instance)));
|
||||||
app.insert_resource(render_instance.clone());
|
app.insert_resource(render_instance.clone());
|
||||||
app.add_plugins(RenderPlugin {
|
app.add_plugins(RenderPlugin {
|
||||||
render_creation: RenderCreation::Manual(
|
render_creation: RenderCreation::Manual(
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
use bevy::color::palettes;
|
||||||
use bevy::render::extract_resource::ExtractResource;
|
use bevy::render::extract_resource::ExtractResource;
|
||||||
use bevy::{prelude::*, render::extract_resource::ExtractResourcePlugin};
|
use bevy::{prelude::*, render::extract_resource::ExtractResourcePlugin};
|
||||||
use std::{marker::PhantomData, mem, ptr};
|
use std::{marker::PhantomData, mem, ptr};
|
||||||
@@ -88,10 +89,7 @@ fn resume_passthrough(
|
|||||||
warn!("Unable to resume Passthrough: {}", e);
|
warn!("Unable to resume Passthrough: {}", e);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
clear_color.set_a(0.0);
|
**clear_color = Srgba::NONE.into();
|
||||||
clear_color.set_r(0.0);
|
|
||||||
clear_color.set_g(0.0);
|
|
||||||
clear_color.set_b(0.0);
|
|
||||||
*state = XrPassthroughState::Running;
|
*state = XrPassthroughState::Running;
|
||||||
}
|
}
|
||||||
fn pause_passthrough(
|
fn pause_passthrough(
|
||||||
@@ -103,7 +101,7 @@ fn pause_passthrough(
|
|||||||
warn!("Unable to resume Passthrough: {}", e);
|
warn!("Unable to resume Passthrough: {}", e);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
clear_color.set_a(1.0);
|
clear_color.set_alpha(1.0);
|
||||||
*state = XrPassthroughState::Paused;
|
*state = XrPassthroughState::Paused;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
|
use bevy::color::palettes;
|
||||||
use bevy::ecs::schedule::IntoSystemConfigs;
|
use bevy::ecs::schedule::IntoSystemConfigs;
|
||||||
use bevy::log::{debug, info};
|
use bevy::log::{debug, info};
|
||||||
use bevy::math::primitives::Direction3d;
|
use bevy::math::Dir3;
|
||||||
use bevy::prelude::{
|
use bevy::prelude::{
|
||||||
Color, Gizmos, GlobalTransform, Plugin, Quat, Query, Res, Transform, Update, Vec2, Vec3, With,
|
Gizmos, GlobalTransform, Plugin, Quat, Query, Res, Transform, Update, Vec2, Vec3, With, Without,
|
||||||
Without,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::xr_init::xr_only;
|
use crate::xr_init::xr_only;
|
||||||
@@ -74,7 +74,7 @@ pub fn draw_gizmos(
|
|||||||
// joint.position,
|
// joint.position,
|
||||||
// trans.forward(),
|
// trans.forward(),
|
||||||
// joint.radius,
|
// joint.radius,
|
||||||
// Color::ORANGE_RED,
|
// palettes::css::ORANGE_RED,
|
||||||
// );
|
// );
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
@@ -85,7 +85,7 @@ pub fn draw_gizmos(
|
|||||||
// joint.position,
|
// joint.position,
|
||||||
// trans.forward(),
|
// trans.forward(),
|
||||||
// joint.radius,
|
// joint.radius,
|
||||||
// Color::LIME_GREEN,
|
// palettes::css::LIME_GREEN,
|
||||||
// );
|
// );
|
||||||
// }
|
// }
|
||||||
// return;
|
// return;
|
||||||
@@ -105,9 +105,9 @@ pub fn draw_gizmos(
|
|||||||
y: 0.01,
|
y: 0.01,
|
||||||
z: 0.0,
|
z: 0.0,
|
||||||
},
|
},
|
||||||
Direction3d::Y,
|
Dir3::Y,
|
||||||
0.2,
|
0.2,
|
||||||
Color::RED,
|
palettes::css::RED,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
Err(_) => info!("too many tracking roots"),
|
Err(_) => info!("too many tracking roots"),
|
||||||
@@ -139,10 +139,10 @@ fn draw_hand_gizmo(
|
|||||||
) {
|
) {
|
||||||
match hand {
|
match hand {
|
||||||
Hand::Left => {
|
Hand::Left => {
|
||||||
let left_color = Color::YELLOW_GREEN;
|
let left_color = palettes::css::YELLOW_GREEN;
|
||||||
let off_color = Color::BLUE;
|
let off_color = palettes::css::BLUE;
|
||||||
let touch_color = Color::GREEN;
|
let touch_color = palettes::css::GREEN;
|
||||||
let pressed_color = Color::RED;
|
let pressed_color = palettes::css::RED;
|
||||||
|
|
||||||
let grip_quat_offset = Quat::from_rotation_x(-1.4);
|
let grip_quat_offset = Quat::from_rotation_x(-1.4);
|
||||||
let face_quat_offset = Quat::from_rotation_x(1.05);
|
let face_quat_offset = Quat::from_rotation_x(1.05);
|
||||||
@@ -169,9 +169,9 @@ fn draw_hand_gizmo(
|
|||||||
//draw face
|
//draw face
|
||||||
gizmos.circle(
|
gizmos.circle(
|
||||||
face_translation_vec3,
|
face_translation_vec3,
|
||||||
Direction3d::new_unchecked(face_quat_normal),
|
Dir3::new_unchecked(face_quat_normal),
|
||||||
0.04,
|
0.04,
|
||||||
Color::YELLOW_GREEN,
|
palettes::css::YELLOW_GREEN,
|
||||||
);
|
);
|
||||||
|
|
||||||
//button b
|
//button b
|
||||||
@@ -188,7 +188,7 @@ fn draw_hand_gizmo(
|
|||||||
face_translation_vec3 + b_offset_quat.mul_vec3(Vec3::new(0.025, -0.01, 0.0));
|
face_translation_vec3 + b_offset_quat.mul_vec3(Vec3::new(0.025, -0.01, 0.0));
|
||||||
gizmos.circle(
|
gizmos.circle(
|
||||||
b_translation_vec3,
|
b_translation_vec3,
|
||||||
Direction3d::new_unchecked(face_quat_normal),
|
Dir3::new_unchecked(face_quat_normal),
|
||||||
0.0075,
|
0.0075,
|
||||||
b_color,
|
b_color,
|
||||||
);
|
);
|
||||||
@@ -207,7 +207,7 @@ fn draw_hand_gizmo(
|
|||||||
face_translation_vec3 + a_offset_quat.mul_vec3(Vec3::new(0.025, 0.01, 0.0));
|
face_translation_vec3 + a_offset_quat.mul_vec3(Vec3::new(0.025, 0.01, 0.0));
|
||||||
gizmos.circle(
|
gizmos.circle(
|
||||||
a_translation_vec3,
|
a_translation_vec3,
|
||||||
Direction3d::new_unchecked(face_quat_normal),
|
Dir3::new_unchecked(face_quat_normal),
|
||||||
0.0075,
|
0.0075,
|
||||||
a_color,
|
a_color,
|
||||||
);
|
);
|
||||||
@@ -224,7 +224,7 @@ fn draw_hand_gizmo(
|
|||||||
//base
|
//base
|
||||||
gizmos.circle(
|
gizmos.circle(
|
||||||
joystick_base_vec,
|
joystick_base_vec,
|
||||||
Direction3d::new_unchecked(face_quat_normal),
|
Dir3::new_unchecked(face_quat_normal),
|
||||||
0.014,
|
0.014,
|
||||||
joystick_color,
|
joystick_color,
|
||||||
);
|
);
|
||||||
@@ -237,7 +237,7 @@ fn draw_hand_gizmo(
|
|||||||
//top
|
//top
|
||||||
gizmos.circle(
|
gizmos.circle(
|
||||||
joystick_top_vec,
|
joystick_top_vec,
|
||||||
Direction3d::new_unchecked(face_quat_normal),
|
Dir3::new_unchecked(face_quat_normal),
|
||||||
0.005,
|
0.005,
|
||||||
joystick_color,
|
joystick_color,
|
||||||
);
|
);
|
||||||
@@ -265,10 +265,10 @@ fn draw_hand_gizmo(
|
|||||||
}
|
}
|
||||||
Hand::Right => {
|
Hand::Right => {
|
||||||
//get right controller
|
//get right controller
|
||||||
let right_color = Color::YELLOW_GREEN;
|
let right_color = palettes::css::YELLOW_GREEN;
|
||||||
let off_color = Color::BLUE;
|
let off_color = palettes::css::BLUE;
|
||||||
let touch_color = Color::GREEN;
|
let touch_color = palettes::css::GREEN;
|
||||||
let pressed_color = Color::RED;
|
let pressed_color = palettes::css::RED;
|
||||||
|
|
||||||
let grip_quat_offset = Quat::from_rotation_x(-1.4);
|
let grip_quat_offset = Quat::from_rotation_x(-1.4);
|
||||||
let face_quat_offset = Quat::from_rotation_x(1.05);
|
let face_quat_offset = Quat::from_rotation_x(1.05);
|
||||||
@@ -298,9 +298,9 @@ fn draw_hand_gizmo(
|
|||||||
//draw face
|
//draw face
|
||||||
gizmos.circle(
|
gizmos.circle(
|
||||||
face_translation_vec3,
|
face_translation_vec3,
|
||||||
Direction3d::new_unchecked(face_quat_normal),
|
Dir3::new_unchecked(face_quat_normal),
|
||||||
0.04,
|
0.04,
|
||||||
Color::YELLOW_GREEN,
|
palettes::css::YELLOW_GREEN,
|
||||||
);
|
);
|
||||||
|
|
||||||
//button b
|
//button b
|
||||||
@@ -317,7 +317,7 @@ fn draw_hand_gizmo(
|
|||||||
face_translation_vec3 + b_offset_quat.mul_vec3(Vec3::new(-0.025, -0.01, 0.0));
|
face_translation_vec3 + b_offset_quat.mul_vec3(Vec3::new(-0.025, -0.01, 0.0));
|
||||||
gizmos.circle(
|
gizmos.circle(
|
||||||
b_translation_vec3,
|
b_translation_vec3,
|
||||||
Direction3d::new_unchecked(face_quat_normal),
|
Dir3::new_unchecked(face_quat_normal),
|
||||||
0.0075,
|
0.0075,
|
||||||
b_color,
|
b_color,
|
||||||
);
|
);
|
||||||
@@ -336,7 +336,7 @@ fn draw_hand_gizmo(
|
|||||||
face_translation_vec3 + a_offset_quat.mul_vec3(Vec3::new(-0.025, 0.01, 0.0));
|
face_translation_vec3 + a_offset_quat.mul_vec3(Vec3::new(-0.025, 0.01, 0.0));
|
||||||
gizmos.circle(
|
gizmos.circle(
|
||||||
a_translation_vec3,
|
a_translation_vec3,
|
||||||
Direction3d::new_unchecked(face_quat_normal),
|
Dir3::new_unchecked(face_quat_normal),
|
||||||
0.0075,
|
0.0075,
|
||||||
a_color,
|
a_color,
|
||||||
);
|
);
|
||||||
@@ -353,7 +353,7 @@ fn draw_hand_gizmo(
|
|||||||
//base
|
//base
|
||||||
gizmos.circle(
|
gizmos.circle(
|
||||||
joystick_base_vec,
|
joystick_base_vec,
|
||||||
Direction3d::new_unchecked(face_quat_normal),
|
Dir3::new_unchecked(face_quat_normal),
|
||||||
0.014,
|
0.014,
|
||||||
joystick_color,
|
joystick_color,
|
||||||
);
|
);
|
||||||
@@ -366,7 +366,7 @@ fn draw_hand_gizmo(
|
|||||||
//top
|
//top
|
||||||
gizmos.circle(
|
gizmos.circle(
|
||||||
joystick_top_vec,
|
joystick_top_vec,
|
||||||
Direction3d::new_unchecked(face_quat_normal),
|
Dir3::new_unchecked(face_quat_normal),
|
||||||
0.005,
|
0.005,
|
||||||
joystick_color,
|
joystick_color,
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,10 +1,8 @@
|
|||||||
use bevy::{
|
use bevy::{
|
||||||
core::Name,
|
color::{palettes, Srgba}, core::Name, prelude::{
|
||||||
prelude::{
|
|
||||||
default, Color, Commands, Component, Deref, DerefMut, Entity, Gizmos, Plugin, PostUpdate,
|
default, Color, Commands, Component, Deref, DerefMut, Entity, Gizmos, Plugin, PostUpdate,
|
||||||
Query, Resource, SpatialBundle, Startup, Transform,
|
Query, Resource, SpatialBundle, Startup, Transform,
|
||||||
},
|
}, transform::components::GlobalTransform
|
||||||
transform::components::GlobalTransform,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::xr_input::{trackers::OpenXRTracker, Hand};
|
use crate::xr_input::{trackers::OpenXRTracker, Hand};
|
||||||
@@ -225,33 +223,33 @@ pub fn draw_hand_entities(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn get_bone_gizmo_style(hand_bone: &HandBone) -> (f32, Color) {
|
pub(crate) fn get_bone_gizmo_style(hand_bone: &HandBone) -> (f32, Srgba) {
|
||||||
match hand_bone {
|
match hand_bone {
|
||||||
HandBone::Palm => (0.01, Color::WHITE),
|
HandBone::Palm => (0.01, palettes::css::WHITE),
|
||||||
HandBone::Wrist => (0.01, Color::GRAY),
|
HandBone::Wrist => (0.01, palettes::css::GRAY),
|
||||||
HandBone::ThumbMetacarpal => (0.01, Color::RED),
|
HandBone::ThumbMetacarpal => (0.01, palettes::css::RED),
|
||||||
HandBone::ThumbProximal => (0.008, Color::RED),
|
HandBone::ThumbProximal => (0.008, palettes::css::RED),
|
||||||
HandBone::ThumbDistal => (0.006, Color::RED),
|
HandBone::ThumbDistal => (0.006, palettes::css::RED),
|
||||||
HandBone::ThumbTip => (0.004, Color::RED),
|
HandBone::ThumbTip => (0.004, palettes::css::RED),
|
||||||
HandBone::IndexMetacarpal => (0.01, Color::ORANGE),
|
HandBone::IndexMetacarpal => (0.01, palettes::css::ORANGE),
|
||||||
HandBone::IndexProximal => (0.008, Color::ORANGE),
|
HandBone::IndexProximal => (0.008, palettes::css::ORANGE),
|
||||||
HandBone::IndexIntermediate => (0.006, Color::ORANGE),
|
HandBone::IndexIntermediate => (0.006, palettes::css::ORANGE),
|
||||||
HandBone::IndexDistal => (0.004, Color::ORANGE),
|
HandBone::IndexDistal => (0.004, palettes::css::ORANGE),
|
||||||
HandBone::IndexTip => (0.002, Color::ORANGE),
|
HandBone::IndexTip => (0.002, palettes::css::ORANGE),
|
||||||
HandBone::MiddleMetacarpal => (0.01, Color::YELLOW),
|
HandBone::MiddleMetacarpal => (0.01, palettes::css::YELLOW),
|
||||||
HandBone::MiddleProximal => (0.008, Color::YELLOW),
|
HandBone::MiddleProximal => (0.008, palettes::css::YELLOW),
|
||||||
HandBone::MiddleIntermediate => (0.006, Color::YELLOW),
|
HandBone::MiddleIntermediate => (0.006, palettes::css::YELLOW),
|
||||||
HandBone::MiddleDistal => (0.004, Color::YELLOW),
|
HandBone::MiddleDistal => (0.004, palettes::css::YELLOW),
|
||||||
HandBone::MiddleTip => (0.002, Color::YELLOW),
|
HandBone::MiddleTip => (0.002, palettes::css::YELLOW),
|
||||||
HandBone::RingMetacarpal => (0.01, Color::GREEN),
|
HandBone::RingMetacarpal => (0.01, palettes::css::GREEN),
|
||||||
HandBone::RingProximal => (0.008, Color::GREEN),
|
HandBone::RingProximal => (0.008, palettes::css::GREEN),
|
||||||
HandBone::RingIntermediate => (0.006, Color::GREEN),
|
HandBone::RingIntermediate => (0.006, palettes::css::GREEN),
|
||||||
HandBone::RingDistal => (0.004, Color::GREEN),
|
HandBone::RingDistal => (0.004, palettes::css::GREEN),
|
||||||
HandBone::RingTip => (0.002, Color::GREEN),
|
HandBone::RingTip => (0.002, palettes::css::GREEN),
|
||||||
HandBone::LittleMetacarpal => (0.01, Color::BLUE),
|
HandBone::LittleMetacarpal => (0.01, palettes::css::BLUE),
|
||||||
HandBone::LittleProximal => (0.008, Color::BLUE),
|
HandBone::LittleProximal => (0.008, palettes::css::BLUE),
|
||||||
HandBone::LittleIntermediate => (0.006, Color::BLUE),
|
HandBone::LittleIntermediate => (0.006, palettes::css::BLUE),
|
||||||
HandBone::LittleDistal => (0.004, Color::BLUE),
|
HandBone::LittleDistal => (0.004, palettes::css::BLUE),
|
||||||
HandBone::LittleTip => (0.002, Color::BLUE),
|
HandBone::LittleTip => (0.002, palettes::css::BLUE),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
use std::f32::consts::PI;
|
use std::f32::consts::PI;
|
||||||
|
|
||||||
|
use bevy::color::palettes;
|
||||||
use bevy::log::{info, warn};
|
use bevy::log::{info, warn};
|
||||||
use bevy::prelude::{
|
use bevy::prelude::{
|
||||||
Color, Component, Entity, Event, EventReader, EventWriter, Gizmos, GlobalTransform, Quat,
|
Color, Component, Entity, Event, EventReader, EventWriter, Gizmos, GlobalTransform, Quat,
|
||||||
@@ -70,8 +71,8 @@ pub fn draw_socket_gizmos(
|
|||||||
let mut transform = global.compute_transform().clone();
|
let mut transform = global.compute_transform().clone();
|
||||||
transform.scale = Vec3::splat(0.1);
|
transform.scale = Vec3::splat(0.1);
|
||||||
let color = match state {
|
let color = match state {
|
||||||
XRInteractorState::Idle => Color::BLUE,
|
XRInteractorState::Idle => palettes::css::BLUE,
|
||||||
XRInteractorState::Selecting => Color::PURPLE,
|
XRInteractorState::Selecting => palettes::css::PURPLE,
|
||||||
};
|
};
|
||||||
gizmos.cuboid(transform, color)
|
gizmos.cuboid(transform, color)
|
||||||
}
|
}
|
||||||
@@ -102,9 +103,9 @@ pub fn draw_interaction_gizmos(
|
|||||||
for (global_transform, interactable_state) in interactable_query.iter() {
|
for (global_transform, interactable_state) in interactable_query.iter() {
|
||||||
let transform = global_transform.compute_transform();
|
let transform = global_transform.compute_transform();
|
||||||
let color = match interactable_state {
|
let color = match interactable_state {
|
||||||
XRInteractableState::Idle => Color::RED,
|
XRInteractableState::Idle => palettes::css::RED,
|
||||||
XRInteractableState::Hover => Color::YELLOW,
|
XRInteractableState::Hover => palettes::css::YELLOW,
|
||||||
XRInteractableState::Select => Color::GREEN,
|
XRInteractableState::Select => palettes::css::GREEN,
|
||||||
};
|
};
|
||||||
gizmos.sphere(transform.translation, transform.rotation, 0.1, color);
|
gizmos.sphere(transform.translation, transform.rotation, 0.1, color);
|
||||||
}
|
}
|
||||||
@@ -124,8 +125,8 @@ pub fn draw_interaction_gizmos(
|
|||||||
);
|
);
|
||||||
local.rotation = quat;
|
local.rotation = quat;
|
||||||
let color = match interactor_state {
|
let color = match interactor_state {
|
||||||
XRInteractorState::Idle => Color::BLUE,
|
XRInteractorState::Idle => palettes::css::BLUE,
|
||||||
XRInteractorState::Selecting => Color::PURPLE,
|
XRInteractorState::Selecting => palettes::css::PURPLE,
|
||||||
};
|
};
|
||||||
gizmos.cuboid(local, color);
|
gizmos.cuboid(local, color);
|
||||||
}
|
}
|
||||||
@@ -135,8 +136,8 @@ pub fn draw_interaction_gizmos(
|
|||||||
Some(_) => match aim {
|
Some(_) => match aim {
|
||||||
Some(aim) => {
|
Some(aim) => {
|
||||||
let color = match interactor_state {
|
let color = match interactor_state {
|
||||||
XRInteractorState::Idle => Color::BLUE,
|
XRInteractorState::Idle => palettes::css::BLUE,
|
||||||
XRInteractorState::Selecting => Color::PURPLE,
|
XRInteractorState::Selecting => palettes::css::PURPLE,
|
||||||
};
|
};
|
||||||
gizmos.ray(
|
gizmos.ray(
|
||||||
root.translation + root.rotation.mul_vec3(aim.0.translation),
|
root.translation + root.rotation.mul_vec3(aim.0.translation),
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
use std::f32::consts::PI;
|
use std::f32::consts::PI;
|
||||||
|
|
||||||
use bevy::{
|
use bevy::{
|
||||||
prelude::*,
|
color::palettes, prelude::*, time::{Time, Timer, TimerMode}
|
||||||
time::{Time, Timer, TimerMode},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
@@ -127,7 +126,7 @@ pub fn proto_locomotion(
|
|||||||
hmd_translation.y = 0.0;
|
hmd_translation.y = 0.0;
|
||||||
let local = position.translation;
|
let local = position.translation;
|
||||||
let global = position.rotation.mul_vec3(hmd_translation) + local;
|
let global = position.rotation.mul_vec3(hmd_translation) + local;
|
||||||
gizmos.circle(global, position.up(), 0.1, Color::GREEN);
|
gizmos.circle(global, position.up(), 0.1, palettes::css::GREEN);
|
||||||
position.rotate_around(global, smoth_rot);
|
position.rotate_around(global, smoth_rot);
|
||||||
}
|
}
|
||||||
None => return,
|
None => return,
|
||||||
@@ -159,7 +158,7 @@ pub fn proto_locomotion(
|
|||||||
hmd_translation.y = 0.0;
|
hmd_translation.y = 0.0;
|
||||||
let local = position.translation;
|
let local = position.translation;
|
||||||
let global = position.rotation.mul_vec3(hmd_translation) + local;
|
let global = position.rotation.mul_vec3(hmd_translation) + local;
|
||||||
gizmos.circle(global, position.up(), 0.1, Color::GREEN);
|
gizmos.circle(global, position.up(), 0.1, palettes::css::GREEN);
|
||||||
position.rotate_around(global, smoth_rot);
|
position.rotate_around(global, smoth_rot);
|
||||||
}
|
}
|
||||||
None => return,
|
None => return,
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ use crate::xr_input::{QuatConv, Vec3Conv};
|
|||||||
use crate::{locate_views, xr_wait_frame, LEFT_XR_TEXTURE_HANDLE, RIGHT_XR_TEXTURE_HANDLE};
|
use crate::{locate_views, xr_wait_frame, LEFT_XR_TEXTURE_HANDLE, RIGHT_XR_TEXTURE_HANDLE};
|
||||||
use bevy::core_pipeline::core_3d::graph::Core3d;
|
use bevy::core_pipeline::core_3d::graph::Core3d;
|
||||||
use bevy::core_pipeline::tonemapping::{DebandDither, Tonemapping};
|
use bevy::core_pipeline::tonemapping::{DebandDither, Tonemapping};
|
||||||
use bevy::ecs::system::lifetimeless::Read;
|
|
||||||
use bevy::math::Vec3A;
|
use bevy::math::Vec3A;
|
||||||
use bevy::prelude::*;
|
use bevy::prelude::*;
|
||||||
use bevy::render::camera::{
|
use bevy::render::camera::{
|
||||||
@@ -13,13 +12,13 @@ use bevy::render::camera::{
|
|||||||
};
|
};
|
||||||
use bevy::render::extract_component::{ExtractComponent, ExtractComponentPlugin};
|
use bevy::render::extract_component::{ExtractComponent, ExtractComponentPlugin};
|
||||||
use bevy::render::primitives::Frustum;
|
use bevy::render::primitives::Frustum;
|
||||||
|
use bevy::render::render_resource::TextureUsages;
|
||||||
use bevy::render::view::{
|
use bevy::render::view::{
|
||||||
update_frusta, ColorGrading, ExtractedView, VisibilitySystems, VisibleEntities,
|
update_frusta, ColorGrading, ExtractedView, VisibilitySystems, VisibleEntities,
|
||||||
};
|
};
|
||||||
use bevy::render::{Render, RenderApp, RenderSet};
|
use bevy::render::{Render, RenderApp, RenderSet};
|
||||||
use bevy::transform::TransformSystem;
|
use bevy::transform::TransformSystem;
|
||||||
use openxr::Fovf;
|
use openxr::Fovf;
|
||||||
use wgpu::TextureUsages;
|
|
||||||
|
|
||||||
use super::trackers::{OpenXRLeftEye, OpenXRRightEye, OpenXRTracker, OpenXRTrackingRoot};
|
use super::trackers::{OpenXRLeftEye, OpenXRRightEye, OpenXRTracker, OpenXRTrackingRoot};
|
||||||
|
|
||||||
@@ -46,7 +45,7 @@ impl Plugin for XrCameraPlugin {
|
|||||||
PostUpdate,
|
PostUpdate,
|
||||||
update_frusta::<XRProjection>
|
update_frusta::<XRProjection>
|
||||||
.after(TransformSystem::TransformPropagate)
|
.after(TransformSystem::TransformPropagate)
|
||||||
.before(VisibilitySystems::UpdatePerspectiveFrusta),
|
.before(VisibilitySystems::UpdateFrusta),
|
||||||
);
|
);
|
||||||
app.add_systems(
|
app.add_systems(
|
||||||
PostUpdate,
|
PostUpdate,
|
||||||
@@ -250,7 +249,7 @@ impl CameraProjection for XRProjection {
|
|||||||
// Copyright (c) 2016 Oculus VR, LLC.
|
// Copyright (c) 2016 Oculus VR, LLC.
|
||||||
// SPDX-License-Identifier: Apache-2.0
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
// =============================================================================
|
// =============================================================================
|
||||||
fn get_projection_matrix(&self) -> Mat4 {
|
fn get_clip_from_view(&self) -> Mat4 {
|
||||||
// symmetric perspective for debugging
|
// symmetric perspective for debugging
|
||||||
// let x_fov = (self.fov.angle_left.abs() + self.fov.angle_right.abs());
|
// let x_fov = (self.fov.angle_left.abs() + self.fov.angle_right.abs());
|
||||||
// let y_fov = (self.fov.angle_up.abs() + self.fov.angle_down.abs());
|
// let y_fov = (self.fov.angle_up.abs() + self.fov.angle_down.abs());
|
||||||
@@ -405,6 +404,6 @@ pub fn xr_camera_head_sync_render_world(
|
|||||||
let mut transform = Transform::IDENTITY;
|
let mut transform = Transform::IDENTITY;
|
||||||
transform.rotation = view.pose.orientation.to_quat();
|
transform.rotation = view.pose.orientation.to_quat();
|
||||||
transform.translation = view.pose.position.to_vec3();
|
transform.translation = view.pose.position.to_vec3();
|
||||||
extracted_view.transform = root.mul_transform(transform);
|
extracted_view.world_from_view = root.mul_transform(transform).into();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user