Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add airDensityDeclineRate to config system #1845

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -298,8 +298,26 @@ protected void getForcesAndMotions() {
//If we are free, do normal updates. But if we are towed by a vehicle, do trailer forces instead.
//This prevents trailers from behaving badly and flinging themselves into the abyss.
if (towedByConnection == null) {
//Set moments and air density.
airDensity = 1.225 * Math.pow(2, -(position.y-seaLevel) / (500D * world.getMaxHeight() / 256D));
//Set air density.
double altitude = (position.y-seaLevel) / ConfigSystem.settings.general.atmosphereScaleFactor.value;//meter
double temperature = 15.04;//centigrade
double pressure = 101.325;//kpa
//atmospheric pressure and temperature calculation can also be updated in future

if(altitude<11000){
temperature = 15.04 - 0.00649 * altitude;
pressure = 101.29 * Math.pow( ( temperature + 273.1) / 288.08 , 5.256);
}else if(altitude >= 11000 && altitude < 25000){
temperature = -56.46;
pressure = 22.65 * Math.exp(1.73 - 0.000157 * altitude);
}else if(altitude >= 25000){
temperature = -131.21 + 0.00299 * altitude;
pressure = 2.488 * Math.pow( ( temperature + 273.1) / 216.6 , -11.388);
}

airDensity = pressure / (0.2869 * ( temperature + 273.1));

//Set moments
momentRoll = definition.motorized.emptyMass * (1.5F + fuelTank.getFluidLevel() / 10000F);
momentPitch = 2D * currentMass;
momentYaw = 3D * currentMass;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public static class ConfigGeneral {
public JSONConfigEntry<Double> climbSpeed = new JSONConfigEntry<>(0.125D, "How far a vehicle will 'climb' blocks every tick when the wheels go into the ground. Higher values make vehicles climb blocks quicker at the cost of smooth movement.");
public JSONConfigEntry<Double> gravityFactor = new JSONConfigEntry<>(1.0D, "Factor for gravitational forces applied to vehicles. Can be adjusted if you think cars are too 'floaty'. Does not affect aircraft.");
public JSONConfigEntry<Double> maxFlightHeight = new JSONConfigEntry<>(0.0D, "How high planes can fly. Setting this to 0 (default) will allow planes to fly as high as their natural physics allows. Useful if you want to cap vertical height for some reason.");
public JSONConfigEntry<Double> atmosphereScaleFactor = new JSONConfigEntry<>(1.0, "Determine how many times the height of the atmosphere is the true height.");
public JSONConfigEntry<Double> engineSpeedTempFactor = new JSONConfigEntry<>(1.0D, "Factor for how RPM affects engine temp. Higher values will make engines heat up quicker at higher RPMs.");
public JSONConfigEntry<Double> engineBiomeTempFactor = new JSONConfigEntry<>(1.0D, "Factor for how biome temp affects engine temp. Higher values will make engines heat up quicker in hotter biomes.");
public JSONConfigEntry<Double> rfToElectricityFactor = new JSONConfigEntry<>(0.02D, "Factor for converting RF to internal electicity for vehicles. Default value is 1/100, but can be adjusted.");
Expand Down