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

View file

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