Slow orbital periods for readability at galaxy-inspection scale
- Introduce ORBITAL_PERIOD_SCALE = 4.0 multiplier so planets/stations/ gas clouds/anomalies all orbit visibly slower. At inspection-scale zoom the un-scaled periods (≈2.5s per unit of radius) made bodies spin like tops; tuned for a calm browsing pace. - Default Orbit angular_velocity 0.5 → 0.15 (≈40s per revolution). - Update orbital_period unit tests for the new scale factor.
This commit is contained in:
@@ -295,9 +295,15 @@ const ASTEROID_COLOR_COUNT: usize = 5;
|
||||
/// asteroid rocks. Stargates are intentionally excluded — they stay
|
||||
/// stationary as navigational aids. Periods are floored at
|
||||
/// [`MIN_ORBITAL_PERIOD`] so very tight orbits don't become a blur.
|
||||
///
|
||||
/// [`ORBITAL_PERIOD_SCALE`] then multiplies the raw period so all bodies
|
||||
/// orbit visibly slower — at galaxy-inspection scale the un-scaled periods
|
||||
/// (≈2.5 s per unit of radius) made planets spin like tops. Tuned for
|
||||
/// readable motion when the player is browsing the galaxy map.
|
||||
const MIN_ORBITAL_PERIOD: f32 = 2.0;
|
||||
const ORBITAL_PERIOD_SCALE: f32 = 4.0;
|
||||
fn orbital_period(orbit: f32, jitter: f32) -> f32 {
|
||||
(orbit * 2.5 + jitter).max(MIN_ORBITAL_PERIOD)
|
||||
((orbit * 2.5 + jitter) * ORBITAL_PERIOD_SCALE).max(MIN_ORBITAL_PERIOD)
|
||||
}
|
||||
|
||||
// ─── Generation ─────────────────────────────────────────────────────────────
|
||||
@@ -1239,10 +1245,11 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn orbital_period_grows_linearly_with_radius() {
|
||||
// No jitter → period = 2.5 × orbit.
|
||||
// No jitter → period = 2.5 × orbit × scale.
|
||||
let scale = ORBITAL_PERIOD_SCALE;
|
||||
assert!((orbital_period(0.0, 0.0) - MIN_ORBITAL_PERIOD).abs() < 1e-6);
|
||||
assert!((orbital_period(2.0, 0.0) - 5.0).abs() < 1e-6);
|
||||
assert!((orbital_period(8.0, 0.0) - 20.0).abs() < 1e-6);
|
||||
assert!((orbital_period(2.0, 0.0) - 5.0 * scale).abs() < 1e-5);
|
||||
assert!((orbital_period(8.0, 0.0) - 20.0 * scale).abs() < 1e-5);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -1254,9 +1261,10 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn orbital_period_applies_jitter_additively() {
|
||||
// Jitter is added before the scale, so the delta is jitter × scale.
|
||||
let base = orbital_period(5.0, 0.0);
|
||||
let jittered = orbital_period(5.0, 2.0);
|
||||
assert!((jittered - base - 2.0).abs() < 1e-6);
|
||||
assert!((jittered - base - 2.0 * ORBITAL_PERIOD_SCALE).abs() < 1e-5);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -24,7 +24,9 @@ impl Default for Orbit {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
angle: 0.0,
|
||||
angular_velocity: 0.5,
|
||||
// ~1 full revolution every 40 seconds — calm enough to read at
|
||||
// inspection-scale zoom levels. Callers can override per-instance.
|
||||
angular_velocity: 0.15,
|
||||
radius: 10.0,
|
||||
plane: OrbitPlane::Horizontal,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user