fix tidal locking rotation for galileian moons

This commit is contained in:
yuni 2024-10-03 01:50:57 +02:00
parent d98b216c8d
commit ec218c6351
2 changed files with 38 additions and 27 deletions

View file

@ -839,29 +839,23 @@ fn spawn_entities(
} else { } else {
state.pos state.pos
}; };
if let Some(r) = state.orbit_distance {
let mass: Option<f64> = if let Some(id) = &state.orbit_object_id {
match id.as_str() {
"jupiter" => Some(nature::JUPITER_MASS),
"sol" => Some(nature::JUPITER_MASS),
_ => {
error!("Found no mass for object `{id}`");
continue;
}
}
} else {
None
};
absolute_pos += nature::pos_offset_for_orbiting_body(r, mass, state.orbit_phase);
if state.is_tidally_locked { let orbited_mass: Option<f64> = if let Some(id) = &state.orbit_object_id {
if let Some(mass) = mass { match id.as_str() {
rotation = "jupiter" => Some(nature::JUPITER_MASS),
Quat::from_rotation_y(nature::rotation_for_orbiting_body(r, mass) as f32); "sol" => Some(nature::JUPITER_MASS),
} else { _ => {
error!("Attempted to use 'tidally locked' without specifying mass via 'orbitaround'"); error!("Found no mass for object `{id}`");
continue;
} }
} }
} else {
None
};
if let Some(r) = state.orbit_distance {
absolute_pos +=
nature::pos_offset_for_orbiting_body(r, orbited_mass, state.orbit_phase);
} else if state.is_tidally_locked { } else if state.is_tidally_locked {
error!("Attempted to use 'tidally locked' without specifying orbital distance via 'orbitaround'"); error!("Attempted to use 'tidally locked' without specifying orbital distance via 'orbitaround'");
} }
@ -931,6 +925,16 @@ fn spawn_entities(
}); });
load_asset(model.as_str(), &mut actor, &*asset_server); load_asset(model.as_str(), &mut actor, &*asset_server);
} }
if state.is_tidally_locked {
if let (Some(r), Some(mass)) = (state.orbit_distance, orbited_mass) {
rotation = Quat::from_rotation_y(nature::rotation_for_orbiting_body(r, mass) as f32)
* rotation;
} else {
error!(
"Attempted to use 'tidally locked' without specifying mass via 'orbitaround'"
);
}
}
actor.insert(Rotation::from(rotation)); actor.insert(Rotation::from(rotation));
// Physics Parameters // Physics Parameters

View file

@ -85,9 +85,10 @@ actor 0 0 0
relativeto jupiter relativeto jupiter
id metis id metis
orbitaround jupiter 128000e3 orbitaround jupiter 128000e3
tidally locked
scale 21.5e3 scale 21.5e3
moon yes moon yes
angularmomentum 0 0.025 0 angularmomentum 0 0 0
actor 0 0 0 orbitring actor 0 0 0 orbitring
relativeto jupiter relativeto jupiter
scale 128000e3 scale 128000e3
@ -99,9 +100,10 @@ actor 0 0 0
relativeto jupiter relativeto jupiter
id adrastea id adrastea
orbitaround jupiter 129000e3 orbitaround jupiter 129000e3
tidally locked
scale 8.2e3 scale 8.2e3
moon yes moon yes
angularmomentum 0 0.025 0 angularmomentum 0 0 0
actor 0 0 0 orbitring actor 0 0 0 orbitring
relativeto jupiter relativeto jupiter
scale 129000e3 scale 129000e3
@ -113,9 +115,10 @@ actor 0 0 0
relativeto jupiter relativeto jupiter
id amalthea id amalthea
orbitaround jupiter 181365.84e3 orbitaround jupiter 181365.84e3
tidally locked
scale 83.5e3 scale 83.5e3
moon yes moon yes
angularmomentum 0 0.025 0 angularmomentum 0 0 0
actor 0 0 0 orbitring actor 0 0 0 orbitring
relativeto jupiter relativeto jupiter
scale 181365.84e3 scale 181365.84e3
@ -143,8 +146,9 @@ actor 0 0 0
id io id io
relativeto jupiter relativeto jupiter
orbitaround jupiter 421700e3 orbitaround jupiter 421700e3
tidally locked
scale 1822e3 scale 1822e3
angularmomentum 0 0.0001 0 angularmomentum 0 0 0
sphere yes sphere yes
moon yes moon yes
physics off physics off
@ -159,8 +163,9 @@ actor 0 0 0
id europa id europa
relativeto jupiter relativeto jupiter
orbitaround jupiter 670900e3 orbitaround jupiter 670900e3
tidally locked
scale 1561e3 scale 1561e3
angularmomentum 0 0.0001 0 angularmomentum 0 0 0
sphere yes sphere yes
moon yes moon yes
physics off physics off
@ -175,8 +180,9 @@ actor 0 0 0
id ganymede id ganymede
relativeto jupiter relativeto jupiter
orbitaround jupiter 1070400e3 orbitaround jupiter 1070400e3
tidally locked
scale 2634e3 scale 2634e3
angularmomentum 0 0.0001 0 angularmomentum 0 0 0
sphere yes sphere yes
moon yes moon yes
physics off physics off
@ -191,8 +197,9 @@ actor 0 0 0
id callisto id callisto
relativeto jupiter relativeto jupiter
orbitaround jupiter 1882700e3 orbitaround jupiter 1882700e3
tidally locked
scale 2410e3 scale 2410e3
angularmomentum 0 0.0001 0 angularmomentum 0 0 0
sphere yes sphere yes
moon yes moon yes
physics off physics off