From 19de229bb2d904303c11ecca5642a37c666c1a5b Mon Sep 17 00:00:00 2001 From: hut Date: Sat, 30 Mar 2024 19:57:35 +0100 Subject: [PATCH] restore jupiter, add "physics off" command --- src/defs.txt | 1 + src/world.rs | 15 +++++++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/defs.txt b/src/defs.txt index 504b205..7b23f97 100644 --- a/src/defs.txt +++ b/src/defs.txt @@ -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 diff --git a/src/world.rs b/src/world.rs index a340ffc..bfc6500 100644 --- a/src/world.rs +++ b/src/world.rs @@ -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::() { state.collider = Collider::sphere(radius_float);