From 349634b0ae86f6bbda02bf1a56c788dc677c75b4 Mon Sep 17 00:00:00 2001 From: core Date: Sun, 16 Apr 2023 17:42:33 -0400 Subject: [PATCH] realistically scale planet masses --- server/src/orbit/constants.rs | 14 ++++++++++---- server/src/planet.rs | 6 +++--- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/server/src/orbit/constants.rs b/server/src/orbit/constants.rs index 40f321fa1a09926bd8f17d82c99013e271dbc1d8..825086c1101034b68c794e301aa4a24c73227598 100644 --- a/server/src/orbit/constants.rs +++ b/server/src/orbit/constants.rs @@ -1,10 +1,16 @@ -pub const GAME_SCALE: f64 = 0.0001567865; // 1000 / EARTH_RADIUS_RL +pub const GAME_SCALE_DISTANCE: f64 = 0.0001567865; // 1000 / EARTH_RADIUS_RL +pub const GAME_SCALE_MASS: f64 = 0.0000000000000000000006697923643670463; // 4000 / EARTH_MASS_RL pub const EARTH_RADIUS_RL: f64 = 6_378_100.0; -pub const EARTH_RADIUS: f64 = EARTH_RADIUS_RL * GAME_SCALE; +pub const EARTH_RADIUS: f64 = EARTH_RADIUS_RL * GAME_SCALE_DISTANCE; +pub const EARTH_MASS_RL: f64 = 5972000000000000000000000.0; +pub const EARTH_MASS: f64 = EARTH_MASS_RL * GAME_SCALE_MASS; pub const MOON_RADIUS_RL: f64 = 1_737_400.0; -pub const MOON_RADIUS: f64 = MOON_RADIUS_RL * GAME_SCALE; +pub const MOON_RADIUS: f64 = MOON_RADIUS_RL * GAME_SCALE_DISTANCE; +pub const MOON_MASS_RL: f64 = 73476730900000000000000.0; +pub const MOON_MASS: f64 = MOON_MASS_RL * GAME_SCALE_MASS; + pub const MOON_PERIAPSIS: f64 = 5400.0; //363228.9 * 1000.0 * GAME_SCALE; // real values pub const MOON_APOAPSIS: f64 = 5600.0; //405400.0 * 1000.0 * GAME_SCALE; // real values -pub const MOON_ORBIT_TIME: f64 = 23328000.0 * GAME_SCALE; // not real values (10x higher) \ No newline at end of file +pub const MOON_ORBIT_TIME: f64 = 23328000.0 * GAME_SCALE_DISTANCE; // not real values (10x higher) \ No newline at end of file diff --git a/server/src/planet.rs b/server/src/planet.rs index a304b20f74fa3b1bc16c9537f440fb323215e5bd..51371ff658118f41846e8a79452026be0b052d84 100644 --- a/server/src/planet.rs +++ b/server/src/planet.rs @@ -4,7 +4,7 @@ use rapier2d_f64::prelude::{RigidBodyHandle, RigidBodySet, ColliderBuilder, Rigi use starkingdoms_protocol::planet::PlanetType; use crate::{SCALE, manager::ClientHandlerMessage}; -use crate::orbit::constants::{EARTH_RADIUS, MOON_APOAPSIS, MOON_PERIAPSIS, MOON_RADIUS}; +use crate::orbit::constants::{EARTH_MASS, EARTH_RADIUS, MOON_APOAPSIS, MOON_MASS, MOON_PERIAPSIS, MOON_RADIUS}; use crate::orbit::orbit::{calculate_point_on_orbit, calculate_world_position_of_orbit}; //const GRAVITY: f64 = 0.001; @@ -69,7 +69,7 @@ impl Planets { &mut planets, "earth", PlanetType::Earth, - 4000.0, + EARTH_MASS, EARTH_RADIUS, (100.0, 100.0), rigid_body_set, @@ -82,7 +82,7 @@ impl Planets { &mut planets, "moon", PlanetType::Moon, - 1000.0, + MOON_MASS, MOON_RADIUS, (moon_start_point[0], moon_start_point[1]), rigid_body_set,