Merge pull request #130 from Schmarni-Dev/legacy-rc
Update Legacy code to bevy 0.14
This commit is contained in:
2538
Cargo.lock
generated
2538
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
12
Cargo.toml
12
Cargo.toml
@@ -12,7 +12,7 @@ repository = "https://github.com/awtterpip/bevy_oxr"
|
||||
|
||||
[workspace.dependencies]
|
||||
eyre = "0.6.2"
|
||||
bevy = "0.13"
|
||||
bevy = "0.14.0"
|
||||
openxr = "0.18"
|
||||
color-eyre = "0.6.2"
|
||||
|
||||
@@ -36,14 +36,14 @@ bevy.workspace = true
|
||||
eyre.workspace = true
|
||||
futures-lite = "2.0.1"
|
||||
mint = "0.5.9"
|
||||
wgpu = "0.19"
|
||||
wgpu-core = { version = "0.19" }
|
||||
wgpu-hal = "0.19"
|
||||
wgpu = "0.20"
|
||||
wgpu-core = "0.21"
|
||||
wgpu-hal = "0.21"
|
||||
|
||||
[target.'cfg(windows)'.dependencies]
|
||||
openxr = { workspace = true, features = [ "linked", "static", "mint" ] }
|
||||
winapi = { version = "0.3.9", optional = true }
|
||||
d3d12 = { version = "0.19", features = ["libloading"], optional = true }
|
||||
d3d12 = { version = "0.20", features = ["libloading"], optional = true }
|
||||
|
||||
[target.'cfg(all(target_family = "unix", not(target_arch = "wasm32")) )'.dependencies]
|
||||
openxr = { workspace = true, features = [ "mint" ] }
|
||||
@@ -68,4 +68,4 @@ debug = true
|
||||
[package.metadata.docs.rs]
|
||||
rustdoc-args = ["-Zunstable-options", "--cfg", "docsrs"]
|
||||
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]
|
||||
bevy = "0.13"
|
||||
bevy.workspace = true
|
||||
bevy_oxr.path = "../.."
|
||||
openxr = { workspace = true, features = ["mint"] }
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
use bevy::color::palettes;
|
||||
use bevy::diagnostic::{FrameTimeDiagnosticsPlugin, LogDiagnosticsPlugin};
|
||||
use bevy::prelude::*;
|
||||
use bevy::transform::components::Transform;
|
||||
@@ -44,7 +45,12 @@ fn main() {
|
||||
|
||||
fn debug_hand_render(query: Query<&GlobalTransform, With<HandBone>>, mut gizmos: Gizmos) {
|
||||
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 +62,21 @@ fn setup(
|
||||
) {
|
||||
// plane
|
||||
commands.spawn(PbrBundle {
|
||||
mesh: meshes.add(Plane3d::new(Vec3::Y)),
|
||||
material: materials.add(StandardMaterial::from(Color::rgb(0.3, 0.5, 0.3))),
|
||||
mesh: meshes.add(Plane3d::new(Vec3::Y, Vec2::splat(2.5))),
|
||||
material: materials.add(StandardMaterial::from(Color::srgb(0.3, 0.5, 0.3))),
|
||||
..default()
|
||||
});
|
||||
// cube
|
||||
commands.spawn(PbrBundle {
|
||||
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),
|
||||
..default()
|
||||
});
|
||||
// cube
|
||||
commands.spawn(PbrBundle {
|
||||
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),
|
||||
..default()
|
||||
});
|
||||
|
||||
@@ -3,6 +3,7 @@ use bevy::prelude::*;
|
||||
use bevy::render::render_asset::RenderAssetUsages;
|
||||
use bevy::transform::components::Transform;
|
||||
use bevy_oxr::graphics::XrAppInfo;
|
||||
use bevy_oxr::prelude::XrSystems;
|
||||
use bevy_oxr::resources::XrViews;
|
||||
use bevy_oxr::xr_input::hands::common::HandInputDebugRenderer;
|
||||
use bevy_oxr::xr_input::interactions::{
|
||||
@@ -29,7 +30,7 @@ fn main() {
|
||||
})
|
||||
.add_plugins(LogDiagnosticsPlugin::default())
|
||||
.add_systems(Startup, setup)
|
||||
.add_systems(Update, (proto_locomotion, pull_to_ground).chain())
|
||||
.add_systems(Update, (proto_locomotion, pull_to_ground).chain().xr_only())
|
||||
.insert_resource(PrototypeLocomotionConfig::default())
|
||||
.add_systems(Startup, spawn_controllers_example)
|
||||
.add_plugins(HandInputDebugRenderer)
|
||||
@@ -95,7 +96,7 @@ fn setup(
|
||||
// cube
|
||||
commands.spawn(PbrBundle {
|
||||
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),
|
||||
..default()
|
||||
});
|
||||
|
||||
@@ -92,14 +92,14 @@ fn setup(
|
||||
) {
|
||||
// plane
|
||||
commands.spawn(PbrBundle {
|
||||
mesh: meshes.add(Plane3d::new(Vec3::Y).mesh()),
|
||||
material: materials.add(StandardMaterial::from(Color::rgb(0.3, 0.5, 0.3))),
|
||||
mesh: meshes.add(Plane3d::new(Vec3::Y, Vec2::splat(2.5)).mesh()),
|
||||
material: materials.add(StandardMaterial::from(Color::srgb(0.3, 0.5, 0.3))),
|
||||
..default()
|
||||
});
|
||||
// cube
|
||||
commands.spawn(PbrBundle {
|
||||
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),
|
||||
..default()
|
||||
});
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
[toolchain]
|
||||
channel = "1.77.2"
|
||||
components = ["rust-src"]
|
||||
profile = "default"
|
||||
targets = [
|
||||
"aarch64-apple-darwin",
|
||||
"aarch64-linux-android",
|
||||
"x86_64-pc-windows-msvc",
|
||||
"x86_64-unknown-linux-gnu",
|
||||
]
|
||||
@@ -4,7 +4,9 @@ use std::sync::{Arc, Mutex};
|
||||
// use anyhow::Context;
|
||||
use bevy::math::uvec2;
|
||||
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 eyre::{Context, ContextCompat};
|
||||
use openxr as xr;
|
||||
@@ -203,9 +205,9 @@ pub fn initialize_xr_instance(
|
||||
}),
|
||||
blend_mode.into(),
|
||||
wgpu_device.into(),
|
||||
RenderQueue(wgpu_queue.into()),
|
||||
RenderAdapterInfo(wgpu_adapter.get_info()),
|
||||
RenderAdapter(wgpu_adapter.into()),
|
||||
RenderQueue(Arc::new(WgpuWrapper::new(wgpu_queue))),
|
||||
RenderAdapterInfo(WgpuWrapper::new(wgpu_adapter.get_info())),
|
||||
RenderAdapter(Arc::new(WgpuWrapper::new(wgpu_adapter))),
|
||||
wgpu_instance.into(),
|
||||
))
|
||||
}
|
||||
|
||||
@@ -5,11 +5,13 @@ mod d3d12;
|
||||
#[cfg(feature = "vulkan")]
|
||||
mod vulkan;
|
||||
|
||||
use std::sync::Arc;
|
||||
|
||||
use bevy::ecs::query::With;
|
||||
use bevy::ecs::system::{Query, SystemState};
|
||||
use bevy::ecs::world::World;
|
||||
use bevy::render::renderer::{
|
||||
RenderAdapter, RenderAdapterInfo, RenderDevice, RenderInstance, RenderQueue,
|
||||
RenderAdapter, RenderAdapterInfo, RenderDevice, RenderInstance, RenderQueue, WgpuWrapper,
|
||||
};
|
||||
use bevy::window::{PrimaryWindow, RawHandleWrapper};
|
||||
use wgpu::Instance;
|
||||
@@ -228,7 +230,7 @@ pub fn try_full_init(
|
||||
render_queue,
|
||||
render_adapter_info,
|
||||
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 bevy::math::uvec2;
|
||||
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 eyre::{Context, ContextCompat};
|
||||
use openxr as xr;
|
||||
@@ -304,9 +306,9 @@ pub fn initialize_xr_instance(
|
||||
}),
|
||||
blend_mode.into(),
|
||||
wgpu_device.into(),
|
||||
RenderQueue(wgpu_queue.into()),
|
||||
RenderAdapterInfo(wgpu_adapter.get_info()),
|
||||
RenderAdapter(wgpu_adapter.into()),
|
||||
RenderQueue(Arc::new(WgpuWrapper::new(wgpu_queue))),
|
||||
RenderAdapterInfo(WgpuWrapper::new(wgpu_adapter.get_info())),
|
||||
RenderAdapter(Arc::new(WgpuWrapper::new(wgpu_adapter))),
|
||||
wgpu_instance.into(),
|
||||
))
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ pub mod xr_init;
|
||||
pub mod xr_input;
|
||||
|
||||
use std::sync::atomic::AtomicBool;
|
||||
use std::sync::Arc;
|
||||
|
||||
use crate::xr_init::{StartXrSession, XrInitPlugin};
|
||||
use crate::xr_input::oculus_touch::ActionSets;
|
||||
@@ -18,7 +19,7 @@ use bevy::ecs::system::SystemState;
|
||||
use bevy::prelude::*;
|
||||
use bevy::render::camera::{ManualTextureView, ManualTextureViewHandle, ManualTextureViews};
|
||||
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::{Render, RenderApp, RenderPlugin, RenderSet};
|
||||
use bevy::window::{PresentMode, PrimaryWindow, RawHandleWrapper};
|
||||
@@ -61,8 +62,8 @@ impl Plugin for OpenXrPlugin {
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
match graphics::initialize_xr_instance(
|
||||
&self.backend_preference,
|
||||
SystemState::<Query<&RawHandleWrapper, With<PrimaryWindow>>>::new(&mut app.world)
|
||||
.get(&app.world)
|
||||
SystemState::<Query<&RawHandleWrapper, With<PrimaryWindow>>>::new(app.world_mut())
|
||||
.get(&app.world())
|
||||
.get_single()
|
||||
.ok()
|
||||
.cloned(),
|
||||
@@ -89,7 +90,7 @@ impl Plugin for OpenXrPlugin {
|
||||
app.insert_resource(xr_instance);
|
||||
app.insert_resource(blend_mode);
|
||||
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.add_plugins(RenderPlugin {
|
||||
render_creation: RenderCreation::Manual(
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
use bevy::color::palettes;
|
||||
use bevy::render::extract_resource::ExtractResource;
|
||||
use bevy::{prelude::*, render::extract_resource::ExtractResourcePlugin};
|
||||
use std::{marker::PhantomData, mem, ptr};
|
||||
@@ -88,10 +89,7 @@ fn resume_passthrough(
|
||||
warn!("Unable to resume Passthrough: {}", e);
|
||||
return;
|
||||
}
|
||||
clear_color.set_a(0.0);
|
||||
clear_color.set_r(0.0);
|
||||
clear_color.set_g(0.0);
|
||||
clear_color.set_b(0.0);
|
||||
**clear_color = Srgba::NONE.into();
|
||||
*state = XrPassthroughState::Running;
|
||||
}
|
||||
fn pause_passthrough(
|
||||
@@ -103,7 +101,7 @@ fn pause_passthrough(
|
||||
warn!("Unable to resume Passthrough: {}", e);
|
||||
return;
|
||||
}
|
||||
clear_color.set_a(1.0);
|
||||
clear_color.set_alpha(1.0);
|
||||
*state = XrPassthroughState::Paused;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
use bevy::color::palettes;
|
||||
use bevy::ecs::schedule::IntoSystemConfigs;
|
||||
use bevy::log::{debug, info};
|
||||
use bevy::math::primitives::Direction3d;
|
||||
use bevy::math::Dir3;
|
||||
use bevy::prelude::{
|
||||
Color, Gizmos, GlobalTransform, Plugin, Quat, Query, Res, Transform, Update, Vec2, Vec3, With,
|
||||
Without,
|
||||
Gizmos, GlobalTransform, Plugin, Quat, Query, Res, Transform, Update, Vec2, Vec3, With, Without,
|
||||
};
|
||||
|
||||
use crate::xr_init::xr_only;
|
||||
@@ -74,7 +74,7 @@ pub fn draw_gizmos(
|
||||
// joint.position,
|
||||
// trans.forward(),
|
||||
// joint.radius,
|
||||
// Color::ORANGE_RED,
|
||||
// palettes::css::ORANGE_RED,
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
@@ -85,7 +85,7 @@ pub fn draw_gizmos(
|
||||
// joint.position,
|
||||
// trans.forward(),
|
||||
// joint.radius,
|
||||
// Color::LIME_GREEN,
|
||||
// palettes::css::LIME_GREEN,
|
||||
// );
|
||||
// }
|
||||
// return;
|
||||
@@ -105,9 +105,9 @@ pub fn draw_gizmos(
|
||||
y: 0.01,
|
||||
z: 0.0,
|
||||
},
|
||||
Direction3d::Y,
|
||||
Dir3::Y,
|
||||
0.2,
|
||||
Color::RED,
|
||||
palettes::css::RED,
|
||||
);
|
||||
}
|
||||
Err(_) => info!("too many tracking roots"),
|
||||
@@ -139,10 +139,10 @@ fn draw_hand_gizmo(
|
||||
) {
|
||||
match hand {
|
||||
Hand::Left => {
|
||||
let left_color = Color::YELLOW_GREEN;
|
||||
let off_color = Color::BLUE;
|
||||
let touch_color = Color::GREEN;
|
||||
let pressed_color = Color::RED;
|
||||
let left_color = palettes::css::YELLOW_GREEN;
|
||||
let off_color = palettes::css::BLUE;
|
||||
let touch_color = palettes::css::GREEN;
|
||||
let pressed_color = palettes::css::RED;
|
||||
|
||||
let grip_quat_offset = Quat::from_rotation_x(-1.4);
|
||||
let face_quat_offset = Quat::from_rotation_x(1.05);
|
||||
@@ -169,9 +169,9 @@ fn draw_hand_gizmo(
|
||||
//draw face
|
||||
gizmos.circle(
|
||||
face_translation_vec3,
|
||||
Direction3d::new_unchecked(face_quat_normal),
|
||||
Dir3::new_unchecked(face_quat_normal),
|
||||
0.04,
|
||||
Color::YELLOW_GREEN,
|
||||
palettes::css::YELLOW_GREEN,
|
||||
);
|
||||
|
||||
//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));
|
||||
gizmos.circle(
|
||||
b_translation_vec3,
|
||||
Direction3d::new_unchecked(face_quat_normal),
|
||||
Dir3::new_unchecked(face_quat_normal),
|
||||
0.0075,
|
||||
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));
|
||||
gizmos.circle(
|
||||
a_translation_vec3,
|
||||
Direction3d::new_unchecked(face_quat_normal),
|
||||
Dir3::new_unchecked(face_quat_normal),
|
||||
0.0075,
|
||||
a_color,
|
||||
);
|
||||
@@ -224,7 +224,7 @@ fn draw_hand_gizmo(
|
||||
//base
|
||||
gizmos.circle(
|
||||
joystick_base_vec,
|
||||
Direction3d::new_unchecked(face_quat_normal),
|
||||
Dir3::new_unchecked(face_quat_normal),
|
||||
0.014,
|
||||
joystick_color,
|
||||
);
|
||||
@@ -237,7 +237,7 @@ fn draw_hand_gizmo(
|
||||
//top
|
||||
gizmos.circle(
|
||||
joystick_top_vec,
|
||||
Direction3d::new_unchecked(face_quat_normal),
|
||||
Dir3::new_unchecked(face_quat_normal),
|
||||
0.005,
|
||||
joystick_color,
|
||||
);
|
||||
@@ -265,10 +265,10 @@ fn draw_hand_gizmo(
|
||||
}
|
||||
Hand::Right => {
|
||||
//get right controller
|
||||
let right_color = Color::YELLOW_GREEN;
|
||||
let off_color = Color::BLUE;
|
||||
let touch_color = Color::GREEN;
|
||||
let pressed_color = Color::RED;
|
||||
let right_color = palettes::css::YELLOW_GREEN;
|
||||
let off_color = palettes::css::BLUE;
|
||||
let touch_color = palettes::css::GREEN;
|
||||
let pressed_color = palettes::css::RED;
|
||||
|
||||
let grip_quat_offset = Quat::from_rotation_x(-1.4);
|
||||
let face_quat_offset = Quat::from_rotation_x(1.05);
|
||||
@@ -298,9 +298,9 @@ fn draw_hand_gizmo(
|
||||
//draw face
|
||||
gizmos.circle(
|
||||
face_translation_vec3,
|
||||
Direction3d::new_unchecked(face_quat_normal),
|
||||
Dir3::new_unchecked(face_quat_normal),
|
||||
0.04,
|
||||
Color::YELLOW_GREEN,
|
||||
palettes::css::YELLOW_GREEN,
|
||||
);
|
||||
|
||||
//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));
|
||||
gizmos.circle(
|
||||
b_translation_vec3,
|
||||
Direction3d::new_unchecked(face_quat_normal),
|
||||
Dir3::new_unchecked(face_quat_normal),
|
||||
0.0075,
|
||||
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));
|
||||
gizmos.circle(
|
||||
a_translation_vec3,
|
||||
Direction3d::new_unchecked(face_quat_normal),
|
||||
Dir3::new_unchecked(face_quat_normal),
|
||||
0.0075,
|
||||
a_color,
|
||||
);
|
||||
@@ -353,7 +353,7 @@ fn draw_hand_gizmo(
|
||||
//base
|
||||
gizmos.circle(
|
||||
joystick_base_vec,
|
||||
Direction3d::new_unchecked(face_quat_normal),
|
||||
Dir3::new_unchecked(face_quat_normal),
|
||||
0.014,
|
||||
joystick_color,
|
||||
);
|
||||
@@ -366,7 +366,7 @@ fn draw_hand_gizmo(
|
||||
//top
|
||||
gizmos.circle(
|
||||
joystick_top_vec,
|
||||
Direction3d::new_unchecked(face_quat_normal),
|
||||
Dir3::new_unchecked(face_quat_normal),
|
||||
0.005,
|
||||
joystick_color,
|
||||
);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
use bevy::{
|
||||
color::{palettes, Srgba},
|
||||
core::Name,
|
||||
prelude::{
|
||||
default, Color, Commands, Component, Deref, DerefMut, Entity, Gizmos, Plugin, PostUpdate,
|
||||
@@ -225,33 +226,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 {
|
||||
HandBone::Palm => (0.01, Color::WHITE),
|
||||
HandBone::Wrist => (0.01, Color::GRAY),
|
||||
HandBone::ThumbMetacarpal => (0.01, Color::RED),
|
||||
HandBone::ThumbProximal => (0.008, Color::RED),
|
||||
HandBone::ThumbDistal => (0.006, Color::RED),
|
||||
HandBone::ThumbTip => (0.004, Color::RED),
|
||||
HandBone::IndexMetacarpal => (0.01, Color::ORANGE),
|
||||
HandBone::IndexProximal => (0.008, Color::ORANGE),
|
||||
HandBone::IndexIntermediate => (0.006, Color::ORANGE),
|
||||
HandBone::IndexDistal => (0.004, Color::ORANGE),
|
||||
HandBone::IndexTip => (0.002, Color::ORANGE),
|
||||
HandBone::MiddleMetacarpal => (0.01, Color::YELLOW),
|
||||
HandBone::MiddleProximal => (0.008, Color::YELLOW),
|
||||
HandBone::MiddleIntermediate => (0.006, Color::YELLOW),
|
||||
HandBone::MiddleDistal => (0.004, Color::YELLOW),
|
||||
HandBone::MiddleTip => (0.002, Color::YELLOW),
|
||||
HandBone::RingMetacarpal => (0.01, Color::GREEN),
|
||||
HandBone::RingProximal => (0.008, Color::GREEN),
|
||||
HandBone::RingIntermediate => (0.006, Color::GREEN),
|
||||
HandBone::RingDistal => (0.004, Color::GREEN),
|
||||
HandBone::RingTip => (0.002, Color::GREEN),
|
||||
HandBone::LittleMetacarpal => (0.01, Color::BLUE),
|
||||
HandBone::LittleProximal => (0.008, Color::BLUE),
|
||||
HandBone::LittleIntermediate => (0.006, Color::BLUE),
|
||||
HandBone::LittleDistal => (0.004, Color::BLUE),
|
||||
HandBone::LittleTip => (0.002, Color::BLUE),
|
||||
HandBone::Palm => (0.01, palettes::css::WHITE),
|
||||
HandBone::Wrist => (0.01, palettes::css::GRAY),
|
||||
HandBone::ThumbMetacarpal => (0.01, palettes::css::RED),
|
||||
HandBone::ThumbProximal => (0.008, palettes::css::RED),
|
||||
HandBone::ThumbDistal => (0.006, palettes::css::RED),
|
||||
HandBone::ThumbTip => (0.004, palettes::css::RED),
|
||||
HandBone::IndexMetacarpal => (0.01, palettes::css::ORANGE),
|
||||
HandBone::IndexProximal => (0.008, palettes::css::ORANGE),
|
||||
HandBone::IndexIntermediate => (0.006, palettes::css::ORANGE),
|
||||
HandBone::IndexDistal => (0.004, palettes::css::ORANGE),
|
||||
HandBone::IndexTip => (0.002, palettes::css::ORANGE),
|
||||
HandBone::MiddleMetacarpal => (0.01, palettes::css::YELLOW),
|
||||
HandBone::MiddleProximal => (0.008, palettes::css::YELLOW),
|
||||
HandBone::MiddleIntermediate => (0.006, palettes::css::YELLOW),
|
||||
HandBone::MiddleDistal => (0.004, palettes::css::YELLOW),
|
||||
HandBone::MiddleTip => (0.002, palettes::css::YELLOW),
|
||||
HandBone::RingMetacarpal => (0.01, palettes::css::GREEN),
|
||||
HandBone::RingProximal => (0.008, palettes::css::GREEN),
|
||||
HandBone::RingIntermediate => (0.006, palettes::css::GREEN),
|
||||
HandBone::RingDistal => (0.004, palettes::css::GREEN),
|
||||
HandBone::RingTip => (0.002, palettes::css::GREEN),
|
||||
HandBone::LittleMetacarpal => (0.01, palettes::css::BLUE),
|
||||
HandBone::LittleProximal => (0.008, palettes::css::BLUE),
|
||||
HandBone::LittleIntermediate => (0.006, palettes::css::BLUE),
|
||||
HandBone::LittleDistal => (0.004, palettes::css::BLUE),
|
||||
HandBone::LittleTip => (0.002, palettes::css::BLUE),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
use std::f32::consts::PI;
|
||||
|
||||
use bevy::color::palettes;
|
||||
use bevy::log::{info, warn};
|
||||
use bevy::prelude::{
|
||||
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();
|
||||
transform.scale = Vec3::splat(0.1);
|
||||
let color = match state {
|
||||
XRInteractorState::Idle => Color::BLUE,
|
||||
XRInteractorState::Selecting => Color::PURPLE,
|
||||
XRInteractorState::Idle => palettes::css::BLUE,
|
||||
XRInteractorState::Selecting => palettes::css::PURPLE,
|
||||
};
|
||||
gizmos.cuboid(transform, color)
|
||||
}
|
||||
@@ -102,9 +103,9 @@ pub fn draw_interaction_gizmos(
|
||||
for (global_transform, interactable_state) in interactable_query.iter() {
|
||||
let transform = global_transform.compute_transform();
|
||||
let color = match interactable_state {
|
||||
XRInteractableState::Idle => Color::RED,
|
||||
XRInteractableState::Hover => Color::YELLOW,
|
||||
XRInteractableState::Select => Color::GREEN,
|
||||
XRInteractableState::Idle => palettes::css::RED,
|
||||
XRInteractableState::Hover => palettes::css::YELLOW,
|
||||
XRInteractableState::Select => palettes::css::GREEN,
|
||||
};
|
||||
gizmos.sphere(transform.translation, transform.rotation, 0.1, color);
|
||||
}
|
||||
@@ -124,8 +125,8 @@ pub fn draw_interaction_gizmos(
|
||||
);
|
||||
local.rotation = quat;
|
||||
let color = match interactor_state {
|
||||
XRInteractorState::Idle => Color::BLUE,
|
||||
XRInteractorState::Selecting => Color::PURPLE,
|
||||
XRInteractorState::Idle => palettes::css::BLUE,
|
||||
XRInteractorState::Selecting => palettes::css::PURPLE,
|
||||
};
|
||||
gizmos.cuboid(local, color);
|
||||
}
|
||||
@@ -135,8 +136,8 @@ pub fn draw_interaction_gizmos(
|
||||
Some(_) => match aim {
|
||||
Some(aim) => {
|
||||
let color = match interactor_state {
|
||||
XRInteractorState::Idle => Color::BLUE,
|
||||
XRInteractorState::Selecting => Color::PURPLE,
|
||||
XRInteractorState::Idle => palettes::css::BLUE,
|
||||
XRInteractorState::Selecting => palettes::css::PURPLE,
|
||||
};
|
||||
gizmos.ray(
|
||||
root.translation + root.rotation.mul_vec3(aim.0.translation),
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
use std::f32::consts::PI;
|
||||
|
||||
use bevy::{
|
||||
color::palettes,
|
||||
prelude::*,
|
||||
time::{Time, Timer, TimerMode},
|
||||
};
|
||||
@@ -127,7 +128,7 @@ pub fn proto_locomotion(
|
||||
hmd_translation.y = 0.0;
|
||||
let local = position.translation;
|
||||
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);
|
||||
}
|
||||
None => return,
|
||||
@@ -159,7 +160,7 @@ pub fn proto_locomotion(
|
||||
hmd_translation.y = 0.0;
|
||||
let local = position.translation;
|
||||
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);
|
||||
}
|
||||
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 bevy::core_pipeline::core_3d::graph::Core3d;
|
||||
use bevy::core_pipeline::tonemapping::{DebandDither, Tonemapping};
|
||||
use bevy::ecs::system::lifetimeless::Read;
|
||||
use bevy::math::Vec3A;
|
||||
use bevy::prelude::*;
|
||||
use bevy::render::camera::{
|
||||
@@ -13,13 +12,13 @@ use bevy::render::camera::{
|
||||
};
|
||||
use bevy::render::extract_component::{ExtractComponent, ExtractComponentPlugin};
|
||||
use bevy::render::primitives::Frustum;
|
||||
use bevy::render::render_resource::TextureUsages;
|
||||
use bevy::render::view::{
|
||||
update_frusta, ColorGrading, ExtractedView, VisibilitySystems, VisibleEntities,
|
||||
};
|
||||
use bevy::render::{Render, RenderApp, RenderSet};
|
||||
use bevy::transform::TransformSystem;
|
||||
use openxr::Fovf;
|
||||
use wgpu::TextureUsages;
|
||||
|
||||
use super::trackers::{OpenXRLeftEye, OpenXRRightEye, OpenXRTracker, OpenXRTrackingRoot};
|
||||
|
||||
@@ -46,7 +45,7 @@ impl Plugin for XrCameraPlugin {
|
||||
PostUpdate,
|
||||
update_frusta::<XRProjection>
|
||||
.after(TransformSystem::TransformPropagate)
|
||||
.before(VisibilitySystems::UpdatePerspectiveFrusta),
|
||||
.before(VisibilitySystems::UpdateFrusta),
|
||||
);
|
||||
app.add_systems(
|
||||
PostUpdate,
|
||||
@@ -250,7 +249,7 @@ impl CameraProjection for XRProjection {
|
||||
// Copyright (c) 2016 Oculus VR, LLC.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// =============================================================================
|
||||
fn get_projection_matrix(&self) -> Mat4 {
|
||||
fn get_clip_from_view(&self) -> Mat4 {
|
||||
// symmetric perspective for debugging
|
||||
// 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());
|
||||
@@ -405,6 +404,6 @@ pub fn xr_camera_head_sync_render_world(
|
||||
let mut transform = Transform::IDENTITY;
|
||||
transform.rotation = view.pose.orientation.to_quat();
|
||||
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