restore real size of moons. add setting "large_moons"

This commit is contained in:
yuni 2024-04-25 02:22:58 +02:00
parent 569a88df19
commit 8e27525b35
2 changed files with 16 additions and 10 deletions

View file

@ -66,6 +66,7 @@ struct ParserState {
is_clickable: bool,
is_targeted_on_startup: bool,
is_sun: bool,
is_moon: bool,
is_point_of_interest: bool,
has_physics: bool,
has_ring: bool,
@ -116,6 +117,7 @@ impl Default for ParserState {
is_clickable: true,
is_targeted_on_startup: false,
is_sun: false,
is_moon: false,
is_point_of_interest: false,
has_physics: true,
has_ring: false,
@ -257,11 +259,10 @@ pub fn load_defs(
state.is_clickable = false;
}
["moon", "yes"] => {
state.model_scale *= 3.0;
state.is_moon = true;
}
["sun", "yes"] => {
state.is_sun = true;
state.model_scale *= 5.0;
}
["ring", "yes"] => {
state.has_ring = true;
@ -490,6 +491,7 @@ fn spawn_entities(
for state_wrapper in er_spawn.read() {
let state = &state_wrapper.0;
if state.class == DefClass::Actor {
// Preprocessing
let relative_pos = if let Some(id) = &state.relative_to {
match id2pos.0.get(&id.to_string()) {
Some(pos) => {
@ -503,7 +505,15 @@ fn spawn_entities(
} else {
state.pos
};
let scale = Vec3::splat(if state.is_sun {
5.0
} else if state.is_moon && settings.large_moons {
3.0
} else {
1.0
} * state.model_scale);
// Spawn the actor
let actor_entity;
{
let mut actor = commands.spawn_empty();
@ -534,18 +544,12 @@ fn spawn_entities(
actor.insert(PbrBundle {
mesh: sphere_handle,
material: sphere_material_handle,
transform: Transform {
scale: Vec3::splat(state.model_scale),
..default()
},
transform: Transform::from_scale(scale),
..default()
});
} else if let Some(model) = &state.model {
actor.insert(SpatialBundle {
transform: Transform {
scale: Vec3::splat(state.model_scale),
..default()
},
transform: Transform::from_scale(scale),
..default()
});
skeleton::load(model.as_str(), &mut actor, &*asset_server);

View file

@ -61,6 +61,7 @@ pub struct Settings {
pub shadows_sun: bool,
pub shadows_pointlights: bool,
pub shadowmap_resolution: usize,
pub large_moons: bool,
pub key_selectobject: MouseButton,
pub key_zoom: MouseButton,
pub key_map: KeyCode,
@ -175,6 +176,7 @@ impl Default for Settings {
shadows_sun: true,
shadows_pointlights: false,
shadowmap_resolution: 2048,
large_moons: false,
key_selectobject: MouseButton::Left,
key_zoom: MouseButton::Right,
key_map: KeyCode::KeyM,