feat: Update to Bevy 0.18 (#202)

This commit is contained in:
Pierce Thompson
2026-01-21 15:14:48 -05:00
committed by GitHub
parent 11bf9442e1
commit 3974766f7a
9 changed files with 1213 additions and 1036 deletions

View File

@@ -19,7 +19,7 @@ fn main() {
.add_plugins(bevy_mod_openxr::features::fb_passthrough::OxrFbPassthroughPlugin)
.add_systems(Startup, setup)
.add_systems(Update, modify_camera)
.insert_resource(AmbientLight {
.insert_resource(GlobalAmbientLight {
color: Default::default(),
brightness: 500.0,
affects_lightmapped_meshes: false,

View File

@@ -10,7 +10,7 @@ fn main() -> AppExit {
.add_plugins(bevy_mod_xr::hand_debug_gizmos::HandGizmosPlugin)
.add_systems(Startup, setup)
.add_systems(Update, handle_input)
.insert_resource(AmbientLight::default())
.insert_resource(GlobalAmbientLight::default())
.run()
}

View File

@@ -5,7 +5,7 @@ use ash::vk::{self, Handle};
use bevy_log::{debug, error};
use bevy_math::UVec2;
use openxr::{sys, Version};
use wgpu::{InstanceFlags, MemoryBudgetThresholds};
use wgpu::{ExperimentalFeatures, InstanceFlags, MemoryBudgetThresholds};
use wgpu::TextureUses;
use wgpu_hal::api::Vulkan;
use wgpu_hal::Api;
@@ -453,6 +453,7 @@ fn init_from_instance_and_dev(
required_limits: limits,
memory_hints: wgpu::MemoryHints::Performance,
trace: wgpu::Trace::Off,
experimental_features: ExperimentalFeatures::enabled(),
},
)
}?;
@@ -811,6 +812,7 @@ fn wgpu_to_vulkan(format: wgpu::TextureFormat) -> Option<vk::Format> {
Tf::EacR11Snorm => F::EAC_R11_SNORM_BLOCK,
Tf::EacRg11Unorm => F::EAC_R11G11_UNORM_BLOCK,
Tf::EacRg11Snorm => F::EAC_R11G11_SNORM_BLOCK,
Tf::P010 => F::G10X6_B10X6R10X6_2PLANE_420_UNORM_3PACK16,
Tf::Astc { block, channel } => match channel {
AstcChannel::Unorm => match block {
AstcBlock::B4x4 => F::ASTC_4X4_UNORM_BLOCK,

View File

@@ -9,22 +9,22 @@ use bevy_ecs::{
};
use bevy_log::{debug_span, error, info};
use bevy_render::{
Render, RenderApp,
extract_resource::ExtractResourcePlugin,
pipelined_rendering::PipelinedRenderingPlugin,
texture::{ManualTextureView, ManualTextureViews},
view::ExtractedView,
Render, RenderApp,
};
use bevy_mod_xr::{
camera::{calculate_projection, Fov, XrCamera, XrProjection, XrViewInit},
camera::{Fov, XrCamera, XrProjection, XrViewInit, calculate_projection},
session::{
XrFirst, XrHandleEvents, XrPreDestroySession, XrRenderSystems, XrRootTransform,
XrSessionCreated,
},
spaces::XrPrimaryReferenceSpace,
};
use bevy_transform::{components::Transform, TransformSystems};
use bevy_transform::{TransformSystems, components::Transform};
use openxr::ViewStateFlags;
use crate::{helper_traits::ToTransform as _, init::should_run_frame_loop, resources::*};
@@ -158,10 +158,7 @@ pub fn init_views<const SPAWN_CAMERAS: bool>(
add_texture_view(&mut manual_texture_views, temp_tex, &graphics_info, index);
if SPAWN_CAMERAS {
commands.spawn((
Camera {
target: RenderTarget::TextureView(view_handle),
..Default::default()
},
RenderTarget::TextureView(view_handle),
XrCamera(index),
Projection::custom(XrProjection::default()),
// NoFrustumCulling,
@@ -177,14 +174,14 @@ pub fn wait_frame(mut frame_waiter: ResMut<OxrFrameWaiter>, mut commands: Comman
pub fn update_cameras(
frame_state: Res<OxrFrameState>,
mut cameras: Query<(&mut Camera, &XrCamera)>,
mut cameras: Query<(&mut Camera, &mut RenderTarget, &XrCamera)>,
) {
for (mut camera, xr_camera) in &mut cameras {
camera.target =
for (_, mut target, xr_camera) in &mut cameras {
*target =
RenderTarget::TextureView(ManualTextureViewHandle(XR_TEXTURE_INDEX + xr_camera.0));
}
if frame_state.is_changed() {
for (mut camera, _) in &mut cameras {
for (mut camera, _, _) in &mut cameras {
camera.is_active = frame_state.should_render
}
}
@@ -317,7 +314,7 @@ pub fn add_texture_view(
let view = ManualTextureView {
texture_view: view.into(),
size: info.resolution,
format: info.format,
view_format: info.format,
};
let handle = ManualTextureViewHandle(XR_TEXTURE_INDEX + index);
manual_texture_views.insert(handle, view);

View File

@@ -120,7 +120,7 @@ fn on_tracker_add(mut world: DeferredWorld, HookContext { entity, .. }: HookCont
if world
.entity(entity)
.get_components::<Has<Children>>()
.is_some_and(identity)
.is_ok_and(identity)
{
return;
}

View File

@@ -19,9 +19,9 @@ fn main() {
.add_systems(Update, read_action_with_marker_component)
.add_systems(Update, handle_flight_input)
// Realtime lighting is expensive, use ambient light instead
.insert_resource(AmbientLight {
.insert_resource(GlobalAmbientLight {
brightness: 500.0,
..AmbientLight::default()
..GlobalAmbientLight::default()
})
.run();
}

View File

@@ -26,9 +26,9 @@ fn main() -> AppExit {
Update,
send_recenter.after(XRUtilsActionSystems::SyncActionStates),
)
.insert_resource(AmbientLight {
.insert_resource(GlobalAmbientLight {
brightness: 500.0,
..AmbientLight::default()
..GlobalAmbientLight::default()
})
.run()
}