From 1d680e35fb246797bb2b96e25df5a045fbcdc526 Mon Sep 17 00:00:00 2001 From: ghostly_zsh Date: Fri, 28 Nov 2025 13:22:12 -0600 Subject: [PATCH] fix: orbit background fills the screen as it should --- crates/unified/src/client/starguide/init.rs | 12 +++++--- crates/unified/src/client/starguide/orbit.rs | 31 ++++++++++++++++++-- crates/unified/src/client/zoom.rs | 14 +++++++++ 3 files changed, 51 insertions(+), 6 deletions(-) diff --git a/crates/unified/src/client/starguide/init.rs b/crates/unified/src/client/starguide/init.rs index 58d610b1de0493352f1bcbc74b8a8af11cce4ef8..d263bff20cf2cda7ea441e50c2ef5a9a4761e670 100644 --- a/crates/unified/src/client/starguide/init.rs +++ b/crates/unified/src/client/starguide/init.rs @@ -30,16 +30,18 @@ pub fn init_starguide( commands.spawn((Camera2d::default(), Camera { is_active: false, - clear_color: ClearColorConfig::None, + //clear_color: ClearColorConfig::None, + clear_color: ClearColorConfig::Custom(Color::linear_rgba(0.0, 0.0, 0.0, 1.0)), order: 1, ..default() })) + .insert(Bloom::default()) .insert(DebandDither::Enabled) .insert(Fxaa::default()) .insert(STARGUIDE_LAYER) .insert(StarguideCamera); - /*let image = Image::new_fill( + let image = Image::new_fill( Extent3d { width: window.width() as u32, height: window.height() as u32, @@ -50,8 +52,8 @@ pub fn init_starguide( RenderAssetUsages::MAIN_WORLD | RenderAssetUsages::RENDER_WORLD, ); let handle = images.add(image); - commands.spawn((Sprite::from_image(handle.clone()), ORBIT_LAYER, StarguideOrbit)); - commands.insert_resource(StarguideOrbitImage(handle));*/ + commands.spawn((Sprite::from_image(handle.clone()), STARGUIDE_LAYER, StarguideOrbit)); + commands.insert_resource(StarguideOrbitImage(handle)); } pub fn player_init( @@ -70,8 +72,10 @@ pub fn player_init( fn player_position_update( me: Single<&Transform, (Changed, With)>, + mut orbit: Single<&mut Transform, (With, Without)>, mut starguide_me: Single<&mut Transform, (With, Without, Without)>, ) { + orbit.translation = me.translation; starguide_me.translation = me.translation; starguide_me.rotation = me.rotation; } diff --git a/crates/unified/src/client/starguide/orbit.rs b/crates/unified/src/client/starguide/orbit.rs index c0e9793a377c34bb04e7deb04bf9bd951a04ff95..79346a1aa237128cf023b45dde7e2e0500203ad4 100644 --- a/crates/unified/src/client/starguide/orbit.rs +++ b/crates/unified/src/client/starguide/orbit.rs @@ -1,7 +1,11 @@ -use crate::{ecs::StarguideOrbitImage, prelude::*}; +use bevy::window::WindowResized; + +use crate::{ecs::{StarguideCamera, StarguideOrbitImage}, prelude::*}; +use bevy::render::render_resource::Extent3d; pub fn starguide_orbit_plugin(app: &mut App) { - //app.add_systems(Update, update_orbits); + app + .add_systems(Update, (update_orbits, window_resize)); } fn update_orbits( @@ -12,8 +16,31 @@ fn update_orbits( error!("Orbit prediction image not found"); return }; + image.clear(&(Color::WHITE.to_srgba().to_u8_array())); for i in 0..100 { image.set_color_at(i, 100, Color::linear_rgb(1.0, 0.0, 0.0)).unwrap(); } } + +fn window_resize( + orbit_image: Res, + mut images: ResMut>, + mut resize_ev: MessageReader, + camera: Single<&Camera, With>, +) { + let Some(image) = images.get_mut(&orbit_image.0) else { + error!("Orbit prediction image not found"); + return + }; + for _ in resize_ev.read() { + let Some(UVec2 {x: width, y: height}) = camera.physical_target_size() else { + continue + }; + image.resize(Extent3d { + width: width, + height: height, + depth_or_array_layers: 1, + }); + } +} diff --git a/crates/unified/src/client/zoom.rs b/crates/unified/src/client/zoom.rs index ca1791c5f288a90ffbc681b7e823f9cbebce9f1a..432563c33ff60e5f146cb59d3e73be4eac9e51f1 100644 --- a/crates/unified/src/client/zoom.rs +++ b/crates/unified/src/client/zoom.rs @@ -86,6 +86,19 @@ fn on_scroll( Without, ), >, + mut starguide_orbit: Single< + &mut Transform, + ( + With, + Without, + Without, + Without, + Without, + Without, + Without, + Without, + ), + >, ) { let (mut starfield_back, mut starfield_back_pos, mut visibility_back, size_back) = starfield_back.into_inner(); @@ -104,6 +117,7 @@ fn on_scroll( camera_projection.scale *= 1.03; starguide_projection.scale *= 1.03; } + starguide_orbit.scale = Vec3::splat(starguide_projection.scale); if camera_projection.scale > 20.0 && matches!(gameplay_state.get(), GameplayState::Main) { camera.0.is_active = false;