give objects orbiting jupiter an orbital velocity on startup
This commit is contained in:
parent
e16a650b22
commit
d9af542d54
14
src/cmd.rs
14
src/cmd.rs
|
@ -617,6 +617,12 @@ fn spawn_entities(
|
||||||
settings: Res<var::Settings>,
|
settings: Res<var::Settings>,
|
||||||
) {
|
) {
|
||||||
for state_wrapper in er_spawn.read() {
|
for state_wrapper in er_spawn.read() {
|
||||||
|
let jupiter_pos: DVec3 = if let Some(jupiter_pos) = id2pos.0.get(ID_JUPITER) {
|
||||||
|
*jupiter_pos
|
||||||
|
} else {
|
||||||
|
warn!("Could not determine Jupiter's position");
|
||||||
|
DVec3::ZERO
|
||||||
|
};
|
||||||
let state = &state_wrapper.0;
|
let state = &state_wrapper.0;
|
||||||
let mut rotation = state.rotation;
|
let mut rotation = state.rotation;
|
||||||
if state.class == DefClass::Actor {
|
if state.class == DefClass::Actor {
|
||||||
|
@ -669,6 +675,12 @@ fn spawn_entities(
|
||||||
} * state.model_scale,
|
} * state.model_scale,
|
||||||
);
|
);
|
||||||
let orbits_jupiter = state.id != ID_JUPITER;
|
let orbits_jupiter = state.id != ID_JUPITER;
|
||||||
|
let velocity = if orbits_jupiter {
|
||||||
|
let coords = absolute_pos - jupiter_pos;
|
||||||
|
state.velocity + nature::orbital_velocity(coords, nature::JUPITER_MASS)
|
||||||
|
} else {
|
||||||
|
state.velocity
|
||||||
|
};
|
||||||
|
|
||||||
// Spawn the actor
|
// Spawn the actor
|
||||||
let actor_entity;
|
let actor_entity;
|
||||||
|
@ -719,7 +731,7 @@ fn spawn_entities(
|
||||||
// Physics Parameters
|
// Physics Parameters
|
||||||
if state.has_physics {
|
if state.has_physics {
|
||||||
actor.insert(RigidBody::Dynamic);
|
actor.insert(RigidBody::Dynamic);
|
||||||
actor.insert(LinearVelocity(state.velocity));
|
actor.insert(LinearVelocity(velocity));
|
||||||
actor.insert(AngularVelocity(state.angular_momentum));
|
actor.insert(AngularVelocity(state.angular_momentum));
|
||||||
actor.insert(ColliderDensity(state.density));
|
actor.insert(ColliderDensity(state.density));
|
||||||
if state.collider_is_mesh {
|
if state.collider_is_mesh {
|
||||||
|
|
Loading…
Reference in a new issue