move stars.rs to an included array in src/data/

This commit is contained in:
yuni 2024-04-14 22:29:51 +02:00
parent 49f9900469
commit 69fb360229
6 changed files with 15559 additions and 15559 deletions

View file

@ -34,9 +34,8 @@ MAX_APPARENT_MAGNITUDE = 7.0
print("// This file was autogenerated by \"genrate_starchart.py\" using data from the")
print("// HYG database: https://github.com/astronexus/HYG-Database/tree/main/hyg")
print("// License: CC BY-SA 4.0: https://creativecommons.org/licenses/by-sa/4.0/")
print("")
print("// Each star's values: [x, y, z, magnitude, color index, distance, name]")
print("pub const STARS: &[(f32; f32, f32, f32, f32, f32, str)] = &[")
print("[")
def render(ra, dec, mag, ci, dist, name):
@ -59,7 +58,7 @@ def render(ra, dec, mag, ci, dist, name):
#brightness = 2.512 ** (0 - mag)
print(f' ({x:.04}, {y:.04}, {z:.04}, {mag:.04}, {ci}, {dist}, "{name}"),')
print(f'({x:.04},{y:.04},{z:.04},{mag:.04},{ci},{dist},"{name}"),')
def clean_name(string):
@ -99,5 +98,5 @@ for entry in entries:
# render(entry[0], entry[1], entry[2], entry[3], entry[4])
# count_extra += 1
print("];")
print("]")
print(f"Wrote {count} stars (total={total}) + {count_extra} extra entries.", file=sys.stderr)

15550
src/data/stars.in Normal file

File diff suppressed because it is too large Load diff

View file

@ -5,7 +5,6 @@ mod chat;
mod commands;
mod effects;
mod hud;
mod stars;
mod var;
mod world;

View file

@ -12,6 +12,9 @@ pub const PARSEC2METER: f64 = 3.0857e16;
pub const DIST_JUPTER_SUN: f64 = 778479.0e6;
pub const EARTH_GRAVITY: f32 = 9.81;
// Each star's values: [x, y, z, magnitude, color index, distance, name]
pub const STARS: &[(f32, f32, f32, f32, f32, f32, &str)] = &include!("data/stars.in");
pub fn star_color_index_to_rgb(color_index: f32) -> (f32, f32, f32) {
let temperature = 4600.0 * ((1.0 / (0.92 * color_index + 1.7)) + (1.0 / (0.92 * color_index + 0.62)));

15551
src/stars.rs

File diff suppressed because it is too large Load diff

View file

@ -1,4 +1,4 @@
use crate::{actor, audio, hud, nature, stars, var};
use crate::{actor, audio, hud, nature, var};
use bevy::prelude::*;
use bevy::render::render_resource::{AsBindGroup, ShaderRef};
use bevy::math::{DVec3, I64Vec3};
@ -12,7 +12,7 @@ use fastrand;
const ASTEROID_UPDATE_INTERVAL: f32 = 0.1; // seconds
const ASTEROID_SIZE_FACTOR: f32 = 10.0;
const RING_THICKNESS: f64 = 8.0e6;
const STARS_MAX_MAGNITUDE: f32 = 5.5;
const STARS_MAX_MAGNITUDE: f32 = 5.5; // max 7.0, see generate_starchart.py
const CENTER_WORLD_ON_PLAYER: bool = true;
@ -128,7 +128,7 @@ pub fn setup(
// Generate starmap
let sphere_handle = meshes.add(Circle::new(1.0));
let mut starcount = 0;
for star in stars::STARS {
for star in nature::STARS {
let mag = star.3;
if mag > STARS_MAX_MAGNITUDE {
continue;