M crates/unified/assets/config/planets.pc.toml => crates/unified/assets/config/planets.pc.toml +2 -1
@@ 1,5 1,6 @@
[orbit]
-planet_spring_compliance = 10000000000.0
+planet_spring_compliance = 0.01
+planet_spring_damping = 0.1
[[planets]]
name = "Sun"
M crates/unified/src/config/planet.rs => crates/unified/src/config/planet.rs +2 -1
@@ 72,5 72,6 @@ pub struct PlanetConfigCollection {
#[derive(Deserialize, Asset, TypePath, Clone, Debug)]
pub struct OrbitConfig {
- pub planet_spring_compliance: f64
+ pub planet_spring_compliance: f64,
+ pub planet_spring_damping: f64,
}
M crates/unified/src/server/orbit/mod.rs => crates/unified/src/server/orbit/mod.rs +3 -3
@@ 22,7 22,7 @@ impl Plugin for OrbitPlugin {
fn update_orbits(
mut planets: Query<(&Planet, &Transform, &mut LinearVelocity), Without<PlanetSpring>>,
planets_2: Query<(&Planet, &Transform, &Mass), Without<PlanetSpring>>,
- mut planet_springs: Query<(&PlanetSpring, &mut Transform), Without<Planet>>,
+ mut planet_springs: Query<(&PlanetSpring, &mut Transform, &mut LinearVelocity), Without<Planet>>,
world_config: Res<WorldConfigResource>,
time: Res<Time>
) {
@@ 61,8 61,8 @@ fn update_orbits(
let b_factor = (1.0 - e * e).sqrt();
let vx = -a * e_k.sin() * de_dt;
let vy = a * b_factor * e_k.cos() * de_dt;
- vel.x = vx + parent_velocity.x;
- vel.y = vy + parent_velocity.y;
+ planet_spring.2.x = vx + parent_velocity.x;
+ planet_spring.2.y = vy + parent_velocity.y;
}
}
M crates/unified/src/server/planets.rs => crates/unified/src/server/planets.rs +7 -3
@@ 73,14 73,18 @@ pub fn update_planets(
planet.default_transform[1],
planet.default_transform[2],
),
- Mass(planet.mass),
- RigidBody::Static,
+ RigidBody::Kinematic,
+ LinearVelocity::ZERO,
)).id();
commands.spawn((
PlanetSpringJoint {
name: planet.name.clone()
},
- FixedJoint::new(planet_entity, spring)/*.with_point_compliance(planet_config.orbit.planet_spring_compliance)*/,
+ FixedJoint::new(planet_entity, spring).with_point_compliance(planet_config.orbit.planet_spring_compliance),
+ JointDamping {
+ linear: planet_config.orbit.planet_spring_damping,
+ angular: 1.0,
+ },
));
}