From 87b667263143e623adebe14fa0be07b4c20b3641 Mon Sep 17 00:00:00 2001 From: "Elijah C. Voigt" Date: Wed, 20 Dec 2023 20:59:33 -0800 Subject: [PATCH] Everything works!... except animation... --- assets/martian.tweak.toml | 9 +++++++-- src/debug.rs | 11 +---------- src/display3d.rs | 2 +- src/loading.rs | 2 +- src/main.rs | 2 ++ src/tweak.rs | 18 +++++++++++++++--- 6 files changed, 27 insertions(+), 17 deletions(-) diff --git a/assets/martian.tweak.toml b/assets/martian.tweak.toml index 4db234c..35c653c 100644 --- a/assets/martian.tweak.toml +++ b/assets/martian.tweak.toml @@ -41,6 +41,11 @@ invalid = "/sfx/3D/3DInvalidMove" ### msaa = "Off" +### +# Enable HDR lighting +### +hdr = true + ### # Screen Space Ambient Occlusion # https://docs.rs/bevy/0.11.3/bevy/pbr/enum.ScreenSpaceAmbientOcclusionQualityLevel.html @@ -101,8 +106,8 @@ Rgba = { red = 1.0, green = 1.0, blue = 1.0, alpha = 0.0 } # Fog Faloff # https://docs.rs/bevy/0.11.3/bevy/pbr/enum.FogFalloff.html ### -# [display3d.fog.falloff] -# Exponential = { density = 0.005 } +[display3d.fog.falloff] +Exponential = { density = 0.005 } # Examples: # * Linear = { start = 1.0, end = 10.0 } # * Exponential = { density = 1.0 } diff --git a/src/debug.rs b/src/debug.rs index 36d531c..ce4f380 100644 --- a/src/debug.rs +++ b/src/debug.rs @@ -27,9 +27,6 @@ impl Plugin for DebugPlugin { display_diagnostics.run_if(resource_exists::()), toggle_debug_ui.run_if(resource_changed_or_removed::()), camera_info.run_if(resource_exists::()), - // debug_asset_event::.run_if(on_event::>()), - // debug_asset_event::.run_if(on_event::>()), - debug_asset_event::.run_if(on_event::>()), ), ); } @@ -141,10 +138,4 @@ fn camera_info(mut debug_infos: ResMut, cameras: Query<(&Camera, &Nam .intersperse(", ") .collect::(); debug_infos.set("Cameras".into(), camera_names); -} - -fn debug_asset_event(mut reader: EventReader>) { - reader.read().for_each(|e| { - info!("Asset Event: {:?}", e); - }); -} +} \ No newline at end of file diff --git a/src/display3d.rs b/src/display3d.rs index ebc183f..e817d2f 100644 --- a/src/display3d.rs +++ b/src/display3d.rs @@ -336,7 +336,7 @@ fn fix_skybox( ) { let tweak = tweaks.get(tweaks_file.handle.clone()).unwrap(); let handle = tweak - .get_handle::("display3d_models_skybox_file") + .get_handle_unchecked::("display3d_models_skybox_file") .unwrap(); let image = images.get_mut(handle).unwrap(); diff --git a/src/loading.rs b/src/loading.rs index 647894f..5b0b572 100644 --- a/src/loading.rs +++ b/src/loading.rs @@ -67,7 +67,7 @@ fn loading( .ids() .all(|id| server.is_loaded_with_dependencies(id)); - info!("s {} g {} t {}", s, g, t); + debug!("s {} g {} t {}", s, g, t); if t { // s && g && t { diff --git a/src/main.rs b/src/main.rs index e5470be..daa053c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,5 +1,7 @@ #![feature(iter_array_chunks)] // used in ray.rs #![feature(iter_intersperse)] // used in debug.rs +#![feature(async_closure)] // Loading tweakfiles + mod audio; mod credits; diff --git a/src/tweak.rs b/src/tweak.rs index 5f5583d..e239028 100644 --- a/src/tweak.rs +++ b/src/tweak.rs @@ -46,7 +46,17 @@ impl Tweaks { .filter_map(|(k, v)| match v { toml::Value::String(s) => std::path::Path::new(format!("assets/{}", s).as_str()) .exists() - .then(|| (k.clone(), load_context.load_untyped(s).untyped())), + .then(|| { + if s.ends_with(".gltf") || s.ends_with(".glb") { + Some(load_context.load::(s).untyped()) + } else if s.ends_with(".png") { + Some(load_context.load::(s).untyped()) + } else { + None + } + }).flatten().map(|h| { + (k.clone(), h) + }), _ => None, }) .collect(); @@ -69,8 +79,10 @@ impl Tweaks { pub fn get<'de, T: Deserialize<'de>>(&self, key: &str) -> Option { Tweaks::locate(&self.table, key) - .map(|val| val.try_into().ok()) - .flatten() + .map(|val| match val.try_into() { + Ok(val) => val, + Err(e) => panic!("{}", e.message()) + }) } fn iter_all(t: &toml::Table, key: &str) -> Vec<(String, toml::Value)> {