Feature: don't cap bevy framerate when out of focus #52

Open
nondescriptpointer wants to merge 3 commits from nondescriptpointer/feat/bevy-framerate-out-of-focus into dev

View File

@@ -27,7 +27,7 @@ use bevy::render::settings::{Backends, RenderCreation, WgpuSettings};
use bevy::render::{RenderDebugFlags, RenderPlugin};
use bevy::scene::ScenePlugin;
use bevy::window::{CompositeAlphaMode, PresentMode};
use bevy::winit::{WakeUp, WinitPlugin};
use bevy::winit::{WakeUp, WinitPlugin, WinitSettings, UpdateMode};
use bevy_dmabuf::import::DmabufImportPlugin;
use bevy_mod_openxr::action_set_attaching::OxrActionAttachingPlugin;
use bevy_mod_openxr::action_set_syncing::OxrActionSyncingPlugin;
@@ -315,10 +315,10 @@ fn bevy_loop(
.async_compute
.on_thread_spawn = Some(enter_runtime_context.clone());
plugins = plugins.set(task_pool_plugin);
if args.flatscreen
let flatscreenmode = args.flatscreen
|| std::env::var_os("DISPLAY").is_some_and(|s| !s.is_empty())
|| std::env::var_os("WAYLAND_DISPLAY").is_some_and(|s| !s.is_empty())
{
|| std::env::var_os("WAYLAND_DISPLAY").is_some_and(|s| !s.is_empty());
if flatscreenmode {
let mut plugin = WinitPlugin::<WakeUp>::default();
plugin.run_on_any_thread = true;
plugins = plugins
@@ -378,6 +378,13 @@ fn bevy_loop(
}),
Schmarni-Dev commented 2025-08-17 18:19:43 -04:00 (Migrated from github.com)
Review

i don't think there's a reason to gate this behind flatscreen mode? i think it would be better to just insert that resource always

i don't think there's a reason to gate this behind flatscreen mode? i think it would be better to just insert that resource always
nondescriptpointer commented 2025-08-18 12:22:05 -04:00 (Migrated from github.com)
Review

If not in flatscreen mode bevy_oxr already inserts this resource:
https://github.com/awtterpip/bevy_oxr/blob/main/crates/bevy_openxr/src/openxr/init.rs

If not in flatscreen mode bevy_oxr already inserts this resource: https://github.com/awtterpip/bevy_oxr/blob/main/crates/bevy_openxr/src/openxr/init.rs
);
if flatscreenmode {
app.insert_resource(WinitSettings {
focused_mode: UpdateMode::Continuous,
unfocused_mode: UpdateMode::Continuous,
});
}
app.add_plugins(bevy_sk::hand::HandPlugin);
// app.add_plugins(HandGizmosPlugin);
app.world_mut().resource_mut::<AmbientLight>().brightness = 1000.0;