move from mass-based to density-based definitions

This commit is contained in:
yuni 2024-04-10 22:04:28 +02:00
parent 860d7f8d4b
commit cd1f8c18cf
2 changed files with 23 additions and 28 deletions

View file

@ -61,7 +61,7 @@ struct ParserState {
warmup_seconds: f32, warmup_seconds: f32,
engine_type: actor::EngineType, engine_type: actor::EngineType,
oxygen: f32, oxygen: f32,
mass: f64, density: f64,
collider: Collider, collider: Collider,
camdistance: f32, camdistance: f32,
suit_integrity: f32, suit_integrity: f32,
@ -116,7 +116,7 @@ impl Default for ParserState {
warmup_seconds: default_engine.warmup_seconds, warmup_seconds: default_engine.warmup_seconds,
engine_type: default_engine.engine_type, engine_type: default_engine.engine_type,
oxygen: nature::OXY_D, oxygen: nature::OXY_D,
mass: 1.0, density: 100.0,
collider: Collider::sphere(1.0), collider: Collider::sphere(1.0),
camdistance: default_actor.camdistance, camdistance: default_actor.camdistance,
suit_integrity: 1.0, suit_integrity: 1.0,
@ -373,9 +373,9 @@ pub fn load_defs(
continue; continue;
} }
} }
["mass", value] => { ["density", value] => {
if let Ok(value_float) = value.parse::<f64>() { if let Ok(value_float) = value.parse::<f64>() {
state.mass = value_float; state.density = value_float;
} }
else { else {
error!("Can't parse float: {line}"); error!("Can't parse float: {line}");
@ -621,11 +621,10 @@ fn spawn_entities(
// Physics Parameters // Physics Parameters
if state.has_physics { if state.has_physics {
let fix_scale: f64 = 1.0 / (state.model_scale as f64).powf(3.0);
actor.insert(RigidBody::Dynamic); actor.insert(RigidBody::Dynamic);
actor.insert(LinearVelocity(state.velocity)); actor.insert(LinearVelocity(state.velocity));
actor.insert(AngularVelocity(state.angular_momentum)); actor.insert(AngularVelocity(state.angular_momentum));
actor.insert(ColliderDensity((state.mass * fix_scale) as f64)); actor.insert(ColliderDensity(state.density));
if state.collider_is_mesh { if state.collider_is_mesh {
actor.insert(AsyncSceneCollider::new(Some( actor.insert(AsyncSceneCollider::new(Some(
ComputedCollider::TriMesh ComputedCollider::TriMesh

View file

@ -13,13 +13,12 @@ actor 0 593051 0 suit
orbit 226000e3 0.66 orbit 226000e3 0.66
player yes player yes
id player id player
mass 200.0 scale 2
scale 1
oxygen 0.008 oxygen 0.008
health 0.3 health 0.3
angularmomentum 0 0 0 angularmomentum 0 0 0
collider capsule 2 1 collider capsule 1 0.5
thrust 1.2 1 1 300 1.5 thrust 1.2 1 1 400 1.5
rotationy 0.65 rotationy 0.65
engine monopropellant engine monopropellant
@ -28,11 +27,11 @@ actor 10 -30 20 MeteorAceGT
relativeto player relativeto player
scale 5 scale 5
vehicle yes vehicle yes
thrust 24.5 4.8 3.3 200000 3 thrust 24.5 4.8 3.3 500000 3
engine ion engine ion
collider sphere 1.5 collider sphere 1
camdistance 50 camdistance 50
mass 3000 density 200
angularmomentum 0.1 0.1 0.3 angularmomentum 0.1 0.1 0.3
actor 0 0 0 io actor 0 0 0 io
@ -85,14 +84,12 @@ actor 0 0 0 moonlet
id thebe id thebe
orbit 221900e3 0.66 orbit 221900e3 0.66
scale 50e3 scale 50e3
mass 430e15
angularmomentum 0 0.025 0 angularmomentum 0 0.025 0
actor 3000 0 0 moonlet actor 3000 0 0 moonlet
name Moonlet name Moonlet
relativeto player relativeto player
scale 500 scale 500
mass 10000000
angularmomentum 0 0.15 0 angularmomentum 0 0.15 0
actor -200 -110 1000 satellite actor -200 -110 1000 satellite
@ -105,13 +102,13 @@ actor -200 -110 1000 satellite
collider capsule 7.5 1 collider capsule 7.5 1
rotationy 0.5 rotationy 0.5
angularmomentum 0 0 0 angularmomentum 0 0 0
mass 10 density 0.01
actor 1000 20 300 monolith actor 1000 20 300 monolith
name "Mysterious Monolith 1" name "Mysterious Monolith 1"
relativeto player relativeto player
scale 2 scale 2
mass 1000 density 300
rotationx 0.5 rotationx 0.5
wants maxrotation 0.01 wants maxrotation 0.01
angularmomentum 0.0 0.0 0.01 angularmomentum 0.0 0.0 0.01
@ -121,7 +118,7 @@ actor 10000 2000 -3500 monolith
name "Mysterious Monolith 2" name "Mysterious Monolith 2"
relativeto player relativeto player
scale 2 scale 2
mass 1000 density 300
rotationx 0.5 rotationx 0.5
wants maxrotation 0.01 wants maxrotation 0.01
angularmomentum 0.0 0.0 0.01 angularmomentum 0.0 0.0 0.01
@ -131,7 +128,7 @@ actor -8000 -1000 -100 monolith
name "Mysterious Monolith 3" name "Mysterious Monolith 3"
relativeto player relativeto player
scale 2 scale 2
mass 1000 density 300
rotationx 0.5 rotationx 0.5
wants maxrotation 0.01 wants maxrotation 0.01
angularmomentum 0.0 0.0 0.01 angularmomentum 0.0 0.0 0.01
@ -142,7 +139,6 @@ actor -3300 10 0 pizzeria
relativeto player relativeto player
id pizzeria id pizzeria
scale 40 scale 40
mass 1000000
rotationy 0.30 rotationy 0.30
angularmomentum 0 0 0 angularmomentum 0 0 0
actor -120 0 20 MeteorAceGT actor -120 0 20 MeteorAceGT
@ -154,13 +150,13 @@ actor -3300 10 0 pizzeria
engine ion engine ion
collider sphere 1.5 collider sphere 1.5
camdistance 50 camdistance 50
mass 3000 density 200
angularmomentum 0 0 0.2 angularmomentum 0 0 0.2
actor -100 63 -13 pizzasign actor -100 63 -13 pizzasign
name "Pizzeria Sign" name "Pizzeria Sign"
relativeto pizzeria relativeto pizzeria
scale 20 scale 20
mass 200 density 200
rotationy 0.45 rotationy 0.45
angularmomentum 0 0 0 angularmomentum 0 0 0
actor -16 -10 0 lightorb actor -16 -10 0 lightorb
@ -193,8 +189,8 @@ actor -3300 10 0 pizzeria
name "Space Pizza™" name "Space Pizza™"
chatid pizzeria chatid pizzeria
alive yes alive yes
mass 200.0 scale 2
collider capsule 2 1 collider capsule 1 0.5
thrust 1.2 1 1 10 1.5 thrust 1.2 1 1 10 1.5
wants maxrotation 0 wants maxrotation 0
wants maxvelocity 0 wants maxvelocity 0
@ -251,8 +247,8 @@ actor 60 -15 -40 suit
name Icarus name Icarus
chatid hi_icarus chatid hi_icarus
alive yes alive yes
mass 200.0 scale 2
collider capsule 2 1 collider capsule 1 0.5
angularmomentum 0.4 0.2 0.1 angularmomentum 0.4 0.2 0.1
rotationy 0.6 rotationy 0.6
rotationx 1 rotationx 1
@ -351,8 +347,8 @@ actor -300 0 40 suit
name "Drifter" name "Drifter"
chatid drifter chatid drifter
oxygen 0.08 oxygen 0.08
mass 200.0 scale 2
collider capsule 2 1 collider capsule 1 0.5
chat drifter chat drifter
name "Drifter" name "Drifter"
msg 2 INIT dead "Error: No response" msg 2 INIT dead "Error: No response"