From 5ecef68f1d7553534254df37dc675f934a259bd8 Mon Sep 17 00:00:00 2001 From: CLAYMORE-DEV Date: Sun, 6 Sep 2026 15:55:26 -0400 Subject: [PATCH 1/4] Made resources optional in system to prevent segfaults --- src/presets.rs | 52 ++++++++++++++++++++++++++++---------------------- 1 file changed, 29 insertions(+), 23 deletions(-) diff --git a/src/presets.rs b/src/presets.rs index fb10d9e..e035dee 100644 --- a/src/presets.rs +++ b/src/presets.rs @@ -77,9 +77,9 @@ pub fn handle_apply_preset_events( skyboxes: Query<&mut MeshMaterial3d>, auroras: Query<&mut MeshMaterial3d>, gradient_handles: Query<&mut MeshMaterial3d>, - mut sky_materials: ResMut>, - mut auroras_materials: ResMut>, - mut gradient_materials: ResMut>, + mut sky_materials_optional: Option>>, + mut auroras_materials_optional: Option>>, + mut gradient_materials_optional: Option>>, mut sky_colors_builder_optional: Option>, mut sun_settings_optional: Option>, ) { @@ -96,31 +96,37 @@ pub fn handle_apply_preset_events( } if let Some(star_settings) = &event.sky_preset.stars { - let skybox_material_handle = skyboxes - .single() - .expect("1 entity with SkyGradientMaterial"); - let mut skybox_material = sky_materials - .get_mut(skybox_material_handle) - .expect("SkyBoxMaterial"); - skybox_material.stars = star_settings.clone(); + if let Some(sky_materials) = sky_materials_optional.as_mut() { + let skybox_material_handle = skyboxes + .single() + .expect("1 entity with SkyGradientMaterial"); + let mut skybox_material = sky_materials + .get_mut(skybox_material_handle) + .expect("SkyBoxMaterial"); + skybox_material.stars = star_settings.clone(); + } } if let Some(aurora_bind_group) = &event.sky_preset.aurora_settings { - let aurora_material_handle = - auroras.single().expect("1 entity with SkyGradientMaterial"); - let mut aurora_material = auroras_materials - .get_mut(aurora_material_handle) - .expect("auroraMaterial"); - aurora_material.aurora_settings = aurora_bind_group.clone(); + if let Some(auroras_materials) = auroras_materials_optional.as_mut() { + let aurora_material_handle = + auroras.single().expect("1 entity with SkyGradientMaterial"); + let mut aurora_material = auroras_materials + .get_mut(aurora_material_handle) + .expect("auroraMaterial"); + aurora_material.aurora_settings = aurora_bind_group.clone(); + } } if let Some(gradient_bind_group) = &event.sky_preset.gradient_bind_group { - let gradient_material_handle = gradient_handles - .single() - .expect("1 entity with FullGradientMaterial"); - let mut gradient_material = gradient_materials - .get_mut(gradient_material_handle) - .expect("gradientMaterial"); - gradient_material.gradient_bind_group = gradient_bind_group.clone(); + if let Some(gradient_materials) = gradient_materials_optional.as_mut() { + let gradient_material_handle = gradient_handles + .single() + .expect("1 entity with FullGradientMaterial"); + let mut gradient_material = gradient_materials + .get_mut(gradient_material_handle) + .expect("gradientMaterial"); + gradient_material.gradient_bind_group = gradient_bind_group.clone(); + } } } } From f48a05d9da1b535e4d7dcb94819a28ad31c50916 Mon Sep 17 00:00:00 2001 From: CLAYMORE-DEV Date: Sun, 6 Sep 2026 16:10:50 -0400 Subject: [PATCH 2/4] Spelling errors --- src/gradient_driver.rs | 2 +- src/presets.rs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/gradient_driver.rs b/src/gradient_driver.rs index 72022dc..53ca1d7 100644 --- a/src/gradient_driver.rs +++ b/src/gradient_driver.rs @@ -21,7 +21,7 @@ impl Plugin for GradientDriverPlugin { fn build(&self, app: &mut App) { app.add_systems(Update, drive_gradients); - // initial sky color values will be wrong, until SkyTimeSettings can be fetched in update_sky_colors_builer + // initial sky color values will be wrong, until SkyTimeSettings can be fetched in update_sky_colors_builder app.insert_resource(self.sky_colors_builder.build(&SkyTimeSettings::default())); app.add_systems( Update, diff --git a/src/presets.rs b/src/presets.rs index e035dee..99eaf46 100644 --- a/src/presets.rs +++ b/src/presets.rs @@ -45,8 +45,8 @@ pub const DEFAULT_SKY_COLORS_BUILDER: SkyGradientBuilder = SkyGradientBuilder { }, }; -/// data that controlls the look of a sky -/// (not aurora upsampling size, nor noise 3dTexture, performance and "look" should be seperate) +/// data that controls the look of a sky +/// (not aurora upsampling size, nor noise 3dTexture, performance and "look" should be separate) /// (None) values will not override current sky settings. #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] #[derive(Default)] From 0f53fbbc21ee005176047a3476a899b75a7d4c55 Mon Sep 17 00:00:00 2001 From: CLAYMORE-DEV Date: Sun, 6 Sep 2026 19:04:59 -0400 Subject: [PATCH 3/4] System runs even when no material is present --- src/aurora.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/aurora.rs b/src/aurora.rs index bfd0d20..9b90ea3 100644 --- a/src/aurora.rs +++ b/src/aurora.rs @@ -90,13 +90,17 @@ fn aurora_follow_camera( fn resize_aurora_on_window_change( mut resize_events: MessageReader, mut images: ResMut>, + aurora_material_optional: Option>>, aurora_handles: Res, aurora_settings: Res, primary_windows: Query<&Window, With>, mut repeated_calls: Local, ) { + if aurora_material_optional.is_none() { + return; + }; let mut update_aurora = aurora_settings.is_changed(); - + for event in resize_events.read() { let is_primary = primary_windows.get(event.window).is_ok(); update_aurora |= is_primary; From 93c760c029df013eac5971a4d1c689abfa075591 Mon Sep 17 00:00:00 2001 From: CLAYMORE-DEV Date: Sat, 12 Sep 2026 17:47:50 -0400 Subject: [PATCH 4/4] A few spelling errors --- src/ambient_driver.rs | 2 +- src/aurora.rs | 4 ++-- src/gradient.rs | 2 +- src/gradient_driver.rs | 10 ++++++---- src/noise.rs | 2 +- src/plugin.rs | 4 ++-- 6 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/ambient_driver.rs b/src/ambient_driver.rs index a59b98d..ea7fc89 100644 --- a/src/ambient_driver.rs +++ b/src/ambient_driver.rs @@ -6,7 +6,7 @@ use bevy::prelude::*; #[cfg(feature = "serde")] use serde::{Deserialize, Serialize}; -/// used to build a ScalarGradient, bsed upon SkyTimeSettings +/// used to build a ScalarGradient, based upon SkyTimeSettings /// places the color we want based upon the timing of SkyTimeSettings #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] #[derive(Clone, Reflect)] diff --git a/src/aurora.rs b/src/aurora.rs index 9b90ea3..0b55e03 100644 --- a/src/aurora.rs +++ b/src/aurora.rs @@ -17,7 +17,7 @@ pub struct AuroraCameraTag; #[derive(Resource, Reflect, Clone)] pub struct AuroraSettings { - /// controlls size of the render target of the aurora material + /// controls size of the render target of the aurora material /// a value of 1.0: use 100% of the windows screen size. aka full quality. /// a value of 0.5: will render the aurora 50% of the screen and be upscaled 200% pub render_texture_percent: f32, @@ -90,7 +90,7 @@ fn aurora_follow_camera( fn resize_aurora_on_window_change( mut resize_events: MessageReader, mut images: ResMut>, - aurora_material_optional: Option>>, + aurora_material_optional: Option>>, aurora_handles: Res, aurora_settings: Res, primary_windows: Query<&Window, With>, diff --git a/src/gradient.rs b/src/gradient.rs index ee5f8a4..e2eb35c 100644 --- a/src/gradient.rs +++ b/src/gradient.rs @@ -4,7 +4,7 @@ use bevy::prelude::*; use serde::{Deserialize, Serialize}; use std::cmp::Ordering; -/// All the current colors that controlls the sky gradient +/// All the current colors that controls the sky gradient /// a sky gradient has 4 colors, and we animate it based upon the "sky time" /// gradient stops 0.0 -> 0.5 = DAY time colors /// gradient stops 0.5 -> 1.0 = NIGHT time colors diff --git a/src/gradient_driver.rs b/src/gradient_driver.rs index 53ca1d7..b6380cd 100644 --- a/src/gradient_driver.rs +++ b/src/gradient_driver.rs @@ -5,10 +5,7 @@ use bevy::{ }; use crate::{ - cycle::{SkyTime, SkyTimeSettings}, - gradient::{Gradient, SkyGradientBuilder, SkyGradients}, - gradient_material::FullGradientMaterial, - plugin::GradientTextureHandle, + aurora_material::AuroraMaterial, cycle::{SkyTime, SkyTimeSettings}, gradient::{Gradient, SkyGradientBuilder, SkyGradients}, gradient_material::FullGradientMaterial, plugin::GradientTextureHandle, }; /// animates the sky gradients, REQUIRES CyclePlugin. @@ -75,10 +72,15 @@ fn drive_gradients( fn resize_gradient_on_window_change( mut resize_events: MessageReader, mut images: ResMut>, + aurora_material_optional: Option>>, aurora_handles: Res, primary_windows: Query<&Window, With>, mut repeated_calls: Local, ) { + if aurora_material_optional.is_none() { + return; + }; + let mut update_texture = false; for event in resize_events.read() { let is_primary = primary_windows.get(event.window).is_ok(); diff --git a/src/noise.rs b/src/noise.rs index eddd8e7..c0adf41 100644 --- a/src/noise.rs +++ b/src/noise.rs @@ -262,7 +262,7 @@ fn make_noise_sampler() -> ImageSampler { }) } -/// will wait until a noisetextureasset is loaded, then override the texture data +/// will wait until a NoiseTextureAsset is loaded, then override the texture data #[cfg(feature = "serde")] #[derive(Resource)] pub struct PendingNoiseTextureAsset(Handle); diff --git a/src/plugin.rs b/src/plugin.rs index e7e3483..e79f4d2 100644 --- a/src/plugin.rs +++ b/src/plugin.rs @@ -39,13 +39,13 @@ impl Default for SkySettings { } } -/// controlls what features you want. +/// controls what features you want. /// you might not want to use the default Cycle/SunDriver/GradientDriver/Aurora for example /// then you can skip that plugin and implement your own. pub struct SkyPluginBuilder { pub settings: SkySettings, /// if enabled, the full sky is rendered to a texture - /// usefull if you need to sample the sky for a fog effect for example + /// useful if you need to sample the sky for a fog effect for example pub render_sky_to_texture: bool, pub use_preset_plugin: bool, pub noise: NoisePlugin,