feat: flatscreen only mode when passing --flatscreen or -f
Signed-off-by: Schmarni <marnistromer@gmail.com>
This commit is contained in:
18
src/main.rs
18
src/main.rs
@@ -39,7 +39,7 @@ use bevy_mod_openxr::render::{OxrRenderPlugin, OxrWaitFrameSystem};
|
||||
use bevy_mod_openxr::resources::{OxrFrameState, OxrFrameWaiter, OxrSessionConfig};
|
||||
use bevy_mod_openxr::types::AppInfo;
|
||||
use bevy_mod_xr::camera::XrProjection;
|
||||
use bevy_mod_xr::session::{XrFirst, XrHandleEvents};
|
||||
use bevy_mod_xr::session::{XrFirst, XrHandleEvents, XrSessionPlugin};
|
||||
use clap::Parser;
|
||||
use core::client::{Client, tick_internal_client};
|
||||
use core::entity_handle::EntityHandlePlugin;
|
||||
@@ -271,7 +271,8 @@ fn bevy_loop(
|
||||
.add(ScenePlugin)
|
||||
.add(GltfPlugin::default())
|
||||
.add(AudioPlugin::default())
|
||||
.add(GizmoPlugin);
|
||||
.add(GizmoPlugin)
|
||||
.add(WindowPlugin::default());
|
||||
let mut task_pool_plugin = TaskPoolPlugin::default();
|
||||
// make tokio work
|
||||
let handle = tokio::runtime::Handle::current();
|
||||
@@ -298,8 +299,8 @@ fn bevy_loop(
|
||||
.disable::<ScheduleRunnerPlugin>()
|
||||
.add(FlatscreenInputPlugin);
|
||||
}
|
||||
app.add_plugins(
|
||||
add_xr_plugins(plugins.add(WindowPlugin::default()))
|
||||
app.add_plugins(if !args.flatscreen {
|
||||
add_xr_plugins(plugins)
|
||||
.set(OxrInitPlugin {
|
||||
app_info: AppInfo {
|
||||
name: "Stardust XR".into(),
|
||||
@@ -328,8 +329,11 @@ fn bevy_loop(
|
||||
.disable::<OxrPassthroughPlugin>()
|
||||
// we don't do any action stuff that needs to integrate with the ecosystem
|
||||
.disable::<OxrActionAttachingPlugin>()
|
||||
.disable::<OxrActionSyncingPlugin>(),
|
||||
);
|
||||
.disable::<OxrActionSyncingPlugin>()
|
||||
} else {
|
||||
// enable a event
|
||||
plugins.add(XrSessionPlugin { auto_handle: false })
|
||||
});
|
||||
|
||||
app.add_plugins((
|
||||
bevy_sk::hand::HandPlugin,
|
||||
@@ -447,6 +451,4 @@ fn xr_step(world: &mut World) {
|
||||
tick_internal_client();
|
||||
#[cfg(feature = "wayland")]
|
||||
wayland.update();
|
||||
// drawable::draw(token);
|
||||
// audio::update();
|
||||
}
|
||||
|
||||
@@ -29,25 +29,7 @@ pub struct LinesNodePlugin;
|
||||
|
||||
impl Plugin for LinesNodePlugin {
|
||||
fn build(&self, app: &mut App) {
|
||||
app.add_systems(Update, (build_line_mesh/* , update_visibillity */).chain());
|
||||
}
|
||||
}
|
||||
|
||||
fn update_visibillity(mut cmds: Commands) {
|
||||
for lines in LINES_REGISTRY.get_valid_contents().into_iter() {
|
||||
let Some(entity) = lines.entity.get().map(|e| **e) else {
|
||||
continue;
|
||||
};
|
||||
match lines.spatial.node().map(|n| n.enabled()).unwrap_or(false) {
|
||||
true => {
|
||||
cmds.entity(entity)
|
||||
.insert_recursive::<Children>(Visibility::Visible);
|
||||
}
|
||||
false => {
|
||||
cmds.entity(entity)
|
||||
.insert_recursive::<Children>(Visibility::Hidden);
|
||||
}
|
||||
}
|
||||
app.add_systems(Update, build_line_mesh);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ impl Plugin for ModelNodePlugin {
|
||||
PostUpdate,
|
||||
(
|
||||
gen_model_parts,
|
||||
apply_materials, /* , update_visibillity */
|
||||
apply_materials,
|
||||
)
|
||||
.chain(),
|
||||
);
|
||||
@@ -43,24 +43,6 @@ impl Plugin for ModelNodePlugin {
|
||||
#[derive(Component)]
|
||||
struct ModelNode(Weak<Model>);
|
||||
|
||||
fn update_visibillity(mut cmds: Commands) {
|
||||
for model in MODEL_REGISTRY.get_valid_contents().into_iter() {
|
||||
let Some(entity) = model.bevy_scene_entity.get() else {
|
||||
continue;
|
||||
};
|
||||
match model.spatial.node().map(|n| n.enabled()).unwrap_or(false) {
|
||||
true => {
|
||||
cmds.entity(entity.0)
|
||||
.insert_recursive::<Children>(Visibility::Visible);
|
||||
}
|
||||
false => {
|
||||
cmds.entity(entity.0)
|
||||
.insert_recursive::<Children>(Visibility::Hidden);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn load_models(
|
||||
asset_server: Res<AssetServer>,
|
||||
mut cmds: Commands,
|
||||
|
||||
@@ -60,7 +60,7 @@ impl Plugin for ControllerPlugin {
|
||||
);
|
||||
app.add_systems(XrPreDestroySession, destroy_spaces);
|
||||
app.add_systems(Startup, setup.run_if(resource_exists::<OxrInstance>));
|
||||
app.add_systems(PreFrameWait, update);
|
||||
app.add_systems(PreFrameWait, update.run_if(resource_exists::<Controllers>));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ use super::{CaptureManager, get_sorted_handlers};
|
||||
pub struct HandPlugin;
|
||||
impl Plugin for HandPlugin {
|
||||
fn build(&self, app: &mut App) {
|
||||
app.add_systems(PreFrameWait, update_hands);
|
||||
app.add_systems(PreFrameWait, update_hands.run_if(resource_exists::<Hands>));
|
||||
app.add_systems(XrSessionCreated, create_trackers);
|
||||
app.add_systems(XrPreDestroySession, destroy_trackers);
|
||||
app.add_systems(PostUpdate, update_hand_material);
|
||||
|
||||
Reference in New Issue
Block a user