From 8d0982f2463479ae31f1098fe71e0510220b4c2f Mon Sep 17 00:00:00 2001 From: ghostly_zsh Date: Sat, 29 Nov 2025 11:21:04 -0600 Subject: [PATCH] fix: orbit indicator is a line --- crates/unified/src/client/rendering/mod.rs | 7 ++-- crates/unified/src/client/starguide/init.rs | 9 +++-- crates/unified/src/client/starguide/input.rs | 4 +-- crates/unified/src/client/starguide/orbit.rs | 37 +++++++++++--------- crates/unified/src/client/zoom.rs | 16 ++++----- 5 files changed, 39 insertions(+), 34 deletions(-) diff --git a/crates/unified/src/client/rendering/mod.rs b/crates/unified/src/client/rendering/mod.rs index 7510bff7e31500c293abf54cec727e2b251139ff..464a33b69e0b38ebfe05636336330b4fd017549a 100644 --- a/crates/unified/src/client/rendering/mod.rs +++ b/crates/unified/src/client/rendering/mod.rs @@ -2,7 +2,7 @@ use bevy::anti_alias::fxaa::Fxaa; use bevy::app::{App, Startup}; use bevy::core_pipeline::tonemapping::DebandDither; use bevy::post_process::bloom::Bloom; -use crate::ecs::{GameplayState, MainCamera, StarguideCamera, Me, MAIN_LAYER}; +use crate::ecs::{GameplayState, MAIN_LAYER, MAIN_STAR_LAYERS, MainCamera, Me, StarguideCamera}; use crate::prelude::*; pub fn render_plugin(app: &mut App) { @@ -12,7 +12,7 @@ pub fn render_plugin(app: &mut App) { } -pub fn setup_graphics(mut commands: Commands) { +pub fn setup_graphics(mut config_store: ResMut, mut commands: Commands) { commands .spawn(Camera2d) .insert(Camera { @@ -24,6 +24,9 @@ pub fn setup_graphics(mut commands: Commands) { .insert(DebandDither::Enabled) .insert(Fxaa::default()) .insert(MainCamera); + for (_, config, _) in config_store.iter_mut() { + config.render_layers = MAIN_STAR_LAYERS.clone(); + } } fn follow_camera( diff --git a/crates/unified/src/client/starguide/init.rs b/crates/unified/src/client/starguide/init.rs index 48026fef48bcecd7d60ccaba42cb6b06edd90df5..185e869e4d37a35045596a1ccb57692b80fb1ef5 100644 --- a/crates/unified/src/client/starguide/init.rs +++ b/crates/unified/src/client/starguide/init.rs @@ -19,20 +19,19 @@ pub fn init_starguide( window: Single<&Window, With>, mut commands: Commands, ) { - commands.spawn((Camera2d::default(), Camera { + /*commands.spawn((Camera2d::default(), Camera { is_active: false, clear_color: ClearColorConfig::Custom(Color::linear_rgba(0.0, 0.0, 0.0, 1.0)), order: 0, ..default() })) .insert(ORBIT_LAYER) - .insert(OrbitCamera); + .insert(OrbitCamera);*/ commands.spawn((Camera2d::default(), Camera { is_active: false, //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()) @@ -41,7 +40,7 @@ pub fn init_starguide( .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, @@ -54,7 +53,7 @@ pub fn init_starguide( let handle = images.add(image); commands.spawn((Sprite::from_image(handle.clone()), STARGUIDE_LAYER, StarguideOrbit)) .insert(Transform::from_xyz(0.0, 0.0, -10.0)); - commands.insert_resource(StarguideOrbitImage(handle)); + commands.insert_resource(StarguideOrbitImage(handle));*/ } pub fn player_init( diff --git a/crates/unified/src/client/starguide/input.rs b/crates/unified/src/client/starguide/input.rs index e0cf2bbc589e5fba3bbc599666da1101ce385cec..06734100d85443ff41b20195395c38da0a8418a0 100644 --- a/crates/unified/src/client/starguide/input.rs +++ b/crates/unified/src/client/starguide/input.rs @@ -35,12 +35,12 @@ fn on_click( fn starguide_drag( drag: ResMut, mut camera: Single<&mut Transform, With>, - mut orbit: Single<&mut Transform, (With, Without)>, + //mut orbit: Single<&mut Transform, (With, Without)>, cursor: Res, ) { if !drag.is_dragging { return } let Some(cursor) = cursor.0 else { return }; camera.translation = drag.init_camera_pos.extend(0.0) - (cursor - drag.init_cursor_pos).extend(0.0); - orbit.translation = drag.init_camera_pos.extend(0.0) - (cursor - drag.init_cursor_pos).extend(0.0); + //orbit.translation = drag.init_camera_pos.extend(0.0) - (cursor - drag.init_cursor_pos).extend(0.0); } diff --git a/crates/unified/src/client/starguide/orbit.rs b/crates/unified/src/client/starguide/orbit.rs index 1b1e5fcc092fe50fd85a9f2f37c768c4c4345b1e..051d675c6f3668ad61f8b4876dd0b6f9127e2a33 100644 --- a/crates/unified/src/client/starguide/orbit.rs +++ b/crates/unified/src/client/starguide/orbit.rs @@ -7,27 +7,28 @@ use bevy::render::render_resource::Extent3d; pub fn starguide_orbit_plugin(app: &mut App) { app - .add_systems(Update, (update_orbits, window_resize)); + .add_systems(Update, (update_orbits)); } fn update_orbits( - orbit_image: Res, - mut images: ResMut>, + //orbit_image: Res, + //mut images: ResMut>, camera: Single<(&Camera, &GlobalTransform, &Projection), With>, me: Single<(&Transform, &LinearVelocity), (With, Without)>, - orbit: Single<&Transform, (With, Without, Without)>, + //orbit: Single<&Transform, (With, Without, Without)>, + mut gizmos: Gizmos, world_config: Res, planets: Query<(&Mass, &Planet, &Transform)>, ) { - let Some(image) = images.get_mut(&orbit_image.0) else { + /*let Some(image) = images.get_mut(&orbit_image.0) else { error!("Orbit prediction image not found"); return - }; + };*/ let Some(world_config) = &world_config.config else { return; }; let Projection::Orthographic(ref projection) = camera.2.clone() else { return }; - image.clear(&(Color::BLACK.to_srgba().to_u8_array())); + //image.clear(&(Color::BLACK.to_srgba().to_u8_array())); let mut p_mass = 0.0; let mut p_transform = Transform::default(); @@ -60,25 +61,27 @@ fn update_orbits( let f_y = -2.0*a*e_y; // 200 steps in the revolution - for i in 0..400 { - let theta = (i as f32) / 200.0 * 2.0*PI; + let mut last_pos = Vec2::ZERO; + for i in 0..200 { + let theta = 2.0*PI*(i as f32)/200.0; let r = (1.0/2.0) * ((f_x*f_x + f_y*f_y - 4.0*a*a) / (-2.0*a - f_x*theta.cos() - f_y*theta.sin())); // convert r to image coords - let pos = Vec2::new(r*theta.cos(), r*theta.sin()); - let pos = pos + p_transform.translation.truncate() - orbit.translation.truncate(); + let pos = Vec2::new(r*theta.cos(), r*theta.sin()) + p_transform.translation.truncate(); + /*let pos = pos + p_transform.translation.truncate() - orbit.translation.truncate(); let pos = Vec2::new(pos.x, -pos.y); let pos = pos / projection.scale; - let pos = pos + image.size_f32()/2.0; - let pos = pos.as_uvec2(); + let pos = pos + image.size_f32()/2.0;*/ - if !(pos.x >= image.size().x || pos.y >= image.size().y) { - image.set_color_at(pos.x, pos.y, Color::linear_rgb(1.0, 0.0, 0.0)).unwrap(); + //if !(pos.x as u32 >= image.size().x || pos.y as u32 >= image.size().y) && i != 0 { + if i != 0 { + gizmos.line_2d(last_pos, pos, Color::linear_rgb(1.0, 0.0, 0.0)); } + last_pos = pos; } } -fn window_resize( +/*fn window_resize( orbit_image: Res, mut images: ResMut>, mut resize_ev: MessageReader, @@ -98,4 +101,4 @@ fn window_resize( depth_or_array_layers: 1, }); } -} +}*/ diff --git a/crates/unified/src/client/zoom.rs b/crates/unified/src/client/zoom.rs index 17f2d187f046e677159e16565792e1da46c7b0d2..af4e0fe77ead6ce79f936ff84c1dfc75ad4c703a 100644 --- a/crates/unified/src/client/zoom.rs +++ b/crates/unified/src/client/zoom.rs @@ -52,7 +52,7 @@ fn on_scroll( Without, ), >, - mut orbit_camera: Single< + /*mut orbit_camera: Single< &mut Camera, ( With, @@ -63,7 +63,7 @@ fn on_scroll( Without, Without, ), - >, + >,*/ mut camera: Single< (&mut Camera, &mut Projection), ( @@ -86,7 +86,7 @@ fn on_scroll( Without, ), >, - mut starguide_orbit: Single< + /*mut starguide_orbit: Single< &mut Transform, ( With, @@ -98,7 +98,7 @@ fn on_scroll( Without, Without, ), - >, + >,*/ ) { let (mut starfield_back, mut starfield_back_pos, mut visibility_back, size_back) = starfield_back.into_inner(); @@ -117,15 +117,15 @@ fn on_scroll( camera_projection.scale *= 1.03; starguide_projection.scale *= 1.03; } - starguide_orbit.scale = Vec3::splat(starguide_projection.scale); + //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; starguide_camera.0.is_active = true; - orbit_camera.is_active = true; + //orbit_camera.is_active = true; starguide_camera.2.translation = player.translation; - starguide_orbit.translation = player.translation; + //starguide_orbit.translation = player.translation; gameplay_next_state.set(GameplayState::Starguide); starfield_back.image_mode = SpriteImageMode::Auto; @@ -138,7 +138,7 @@ fn on_scroll( camera.0.is_active = true; gameplay_next_state.set(GameplayState::Main); starguide_camera.0.is_active = false; - orbit_camera.is_active = false; + //orbit_camera.is_active = false; if matches!(*visibility_back, Visibility::Hidden) { if let Some(size_back) = size_back {