From 8e27525b355c969fc0c11f4ea4765a90fdaa7a54 Mon Sep 17 00:00:00 2001 From: hut Date: Thu, 25 Apr 2024 02:22:58 +0200 Subject: [PATCH] restore real size of moons. add setting "large_moons" --- src/commands.rs | 24 ++++++++++++++---------- src/var.rs | 2 ++ 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/src/commands.rs b/src/commands.rs index aa076f3..2d49cc7 100644 --- a/src/commands.rs +++ b/src/commands.rs @@ -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); diff --git a/src/var.rs b/src/var.rs index bab55b9..bb1de78 100644 --- a/src/var.rs +++ b/src/var.rs @@ -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,