restore jupiter, add "physics off" command

This commit is contained in:
yuni 2024-03-30 19:57:35 +01:00
parent de8eb23d91
commit 19de229bb2
2 changed files with 12 additions and 4 deletions

View file

@ -10,6 +10,7 @@ actor 0 0 0 suit
actor 300000 0 500000 jupiter
scale 200000
physics off
rotationy -1.40
angularmomentum 0 0.0001 0

View file

@ -209,6 +209,7 @@ struct ParserState {
is_alive: bool,
is_suited: bool,
is_vehicle: bool,
has_physics: bool,
thrust_forward: f32,
thrust_sideways: f32,
thrust_back: f32,
@ -254,6 +255,7 @@ impl Default for ParserState {
is_alive: false,
is_suited: false,
is_vehicle: false,
has_physics: true,
thrust_forward: default_engine.thrust_forward,
thrust_sideways: default_engine.thrust_forward,
thrust_back: default_engine.thrust_back,
@ -339,10 +341,12 @@ impl ParserState {
});
// Physics Parameters
let fix_scale = 1.0 / self.model_scale.powf(3.0);
actor.insert(RigidBody::Dynamic);
actor.insert(self.collider.clone());
actor.insert(ColliderDensity(self.mass * fix_scale));
if self.has_physics {
let fix_scale = 1.0 / self.model_scale.powf(3.0);
actor.insert(RigidBody::Dynamic);
actor.insert(self.collider.clone());
actor.insert(ColliderDensity(self.mass * fix_scale));
}
// Optional Components
if self.is_player {
@ -555,6 +559,9 @@ pub fn load_defs(
continue;
}
}
["physics", "off"] => {
state.has_physics = false;
}
["collider", "sphere", radius] => {
if let Ok(radius_float) = radius.parse::<f32>() {
state.collider = Collider::sphere(radius_float);