From 1a2b157ef3b866b3b199dd7adbf00958b6bd716d Mon Sep 17 00:00:00 2001 From: xfy Date: Fri, 10 Jul 2026 10:27:10 +0800 Subject: [PATCH] feat: BlackHoleParams tunable resource --- src/main.rs | 1 + src/params.rs | 52 ++++++++++++++++++++++++++++++++++++++++++++ src/render/plugin.rs | 1 + 3 files changed, 54 insertions(+) create mode 100644 src/params.rs diff --git a/src/main.rs b/src/main.rs index efa0a4d..645b590 100644 --- a/src/main.rs +++ b/src/main.rs @@ -5,6 +5,7 @@ use bevy::window::WindowPlugin; mod web; mod render; mod camera; +mod params; fn main() { // On web, abort startup if WebGPU isn't available and show a message. diff --git a/src/params.rs b/src/params.rs new file mode 100644 index 0000000..5e2d770 --- /dev/null +++ b/src/params.rs @@ -0,0 +1,52 @@ +use bevy::prelude::*; + +/// All tunable black-hole parameters. Edited by the egui panel (Task 17), +/// mirrored into BlackHoleUniforms each frame (Task 7). +#[derive(Resource, Clone)] +pub struct BlackHoleParams { + // Physics (natural units, Rs = 1) + pub rs: f32, + // Accretion disk + pub disk_inner: f32, + pub disk_outer: f32, + pub disk_tilt: f32, // radians, tilt of disk plane vs. camera + pub disk_brightness: f32, + pub disk_rotation_speed: f32, + pub doppler_enabled: bool, + pub doppler_strength: f32, + // Renderer + pub steps: u32, + pub render_scale: f32, + pub star_intensity: f32, + pub grid_enabled: bool, + pub grid_density: f32, + // Background + pub skybox_intensity: f32, + // Planets (count matches the storage buffer; Task 14) + pub planet_count: u32, + // Kerr (Phase 2; unused in Phase 1) + pub spin: f32, +} + +impl Default for BlackHoleParams { + fn default() -> Self { + Self { + rs: 1.0, + disk_inner: 3.0, + disk_outer: 15.0, + disk_tilt: 1.318, // ~75.5 deg, matching the reference video + disk_brightness: 1.0, + disk_rotation_speed: 0.5, + doppler_enabled: true, + doppler_strength: 1.0, + steps: 300, + render_scale: 1.0, + star_intensity: 1.0, + grid_enabled: false, + grid_density: 1.0, + skybox_intensity: 0.0, // procedural stars only by default + planet_count: 0, + spin: 0.0, + } + } +} diff --git a/src/render/plugin.rs b/src/render/plugin.rs index f54acda..590dfee 100644 --- a/src/render/plugin.rs +++ b/src/render/plugin.rs @@ -11,6 +11,7 @@ impl Plugin for BlackHolePlugin { .add_systems(Startup, spawn_fullscreen_quad) .add_systems(Update, update_time) .init_resource::() + .init_resource::() .add_systems(Update, crate::camera::orbit_controller); } }