mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Greatly improves the plausibility of the transonic flight simulation (#4652)
* Transonic flight now induces yawing and pitching of the nose of the bullet instead of modifying the bullet velocity directly * The ballistic coefficient now starts to decreases once the bullet goes transonic
This commit is contained in:
parent
dcd4137491
commit
e70a23d93a
@ -48,6 +48,7 @@ struct Bullet {
|
||||
double lastFrame;
|
||||
double hDeflection;
|
||||
double spinDrift;
|
||||
double bcDegradation;
|
||||
unsigned randSeed;
|
||||
std::default_random_engine randGenerator;
|
||||
};
|
||||
@ -68,7 +69,6 @@ Map* map = &mapDatabase[""];
|
||||
double calculateRoughnessLength(double posX, double posY) {
|
||||
// Source: http://es.ucsc.edu/~jnoble/wind/extrap/index.html
|
||||
double roughness_lengths[10] = {0.0002, 0.0005, 0.0024, 0.03, 0.055, 0.1, 0.2, 0.4, 0.8, 1.6};
|
||||
double roughnessLength = 0.0024;
|
||||
|
||||
int gridX = (int)floor(posX / 50);
|
||||
int gridY = (int)floor(posY / 50);
|
||||
@ -482,6 +482,7 @@ void __stdcall RVExtension(char *output, int outputSize, const char *function)
|
||||
bulletDatabase[index].lastFrame = tickTime;
|
||||
bulletDatabase[index].hDeflection = 0.0;
|
||||
bulletDatabase[index].spinDrift = 0.0;
|
||||
bulletDatabase[index].bcDegradation = 1.0;
|
||||
bulletDatabase[index].speed = 0.0;
|
||||
bulletDatabase[index].frames = 0.0;
|
||||
bulletDatabase[index].randSeed = 0;
|
||||
@ -617,6 +618,24 @@ void __stdcall RVExtension(char *output, int outputSize, const char *function)
|
||||
trueVelocity[2] = velocity[2] - wind[2];
|
||||
trueSpeed = sqrt(pow(trueVelocity[0], 2) + pow(trueVelocity[1], 2) + pow(trueVelocity[2], 2));
|
||||
|
||||
double speedOfSound = 331.3 + (0.6 * temperature);
|
||||
double transonicSpeed = 394 + (0.6 * temperature);
|
||||
if (bulletDatabase[index].transonicStabilityCoef < 1.0f && bulletSpeed < transonicSpeed && bulletSpeed > speedOfSound) {
|
||||
std::uniform_real_distribution<double> distribution(-10.0, 10.0);
|
||||
double coef = 1.0f - bulletDatabase[index].transonicStabilityCoef;
|
||||
|
||||
trueVelocity[0] += distribution(bulletDatabase[index].randGenerator) * coef;
|
||||
trueVelocity[1] += distribution(bulletDatabase[index].randGenerator) * coef;
|
||||
trueVelocity[2] += distribution(bulletDatabase[index].randGenerator) * coef;
|
||||
double speed = sqrt(pow(trueVelocity[0], 2) + pow(trueVelocity[1], 2) + pow(trueVelocity[2], 2));
|
||||
|
||||
trueVelocity[0] *= trueSpeed / speed;
|
||||
trueVelocity[1] *= trueSpeed / speed;
|
||||
trueVelocity[2] *= trueSpeed / speed;
|
||||
|
||||
bulletDatabase[index].bcDegradation *= pow(0.993, coef);
|
||||
};
|
||||
|
||||
temperature = bulletDatabase[index].temperature - 0.0065 * position[2];
|
||||
pressure = (1013.25 - 10 * bulletDatabase[index].overcast) * pow(1 - (0.0065 * (bulletDatabase[index].altitude + position[2])) / (273.15 + temperature + 0.0065 * bulletDatabase[index].altitude), 5.255754495);
|
||||
|
||||
@ -640,6 +659,7 @@ void __stdcall RVExtension(char *output, int outputSize, const char *function)
|
||||
}
|
||||
|
||||
ballisticCoefficient = calculateAtmosphericCorrection(ballisticCoefficient, temperature, pressure, bulletDatabase[index].humidity, bulletDatabase[index].atmosphereModel);
|
||||
ballisticCoefficient *= bulletDatabase[index].bcDegradation;
|
||||
drag = deltaT * calculateRetard(bulletDatabase[index].dragModel, ballisticCoefficient, trueSpeed);
|
||||
accel[0] = (trueVelocity[0] / trueSpeed) * drag;
|
||||
accel[1] = (trueVelocity[1] / trueSpeed) * drag;
|
||||
@ -694,16 +714,6 @@ void __stdcall RVExtension(char *output, int outputSize, const char *function)
|
||||
positionOffset[0] += sin(bulletDir + M_PI / 2) * spinDriftPartial;
|
||||
positionOffset[1] += cos(bulletDir + M_PI / 2) * spinDriftPartial;
|
||||
|
||||
double speedOfSound = 331.3 + (0.6 * temperature);
|
||||
if (bulletSpeed < (speedOfSound + 5) && bulletSpeedAvg > speedOfSound && bulletSpeed > (speedOfSound - 5)) {
|
||||
std::uniform_real_distribution<double> distribution(0.0, 1.0);
|
||||
double coef = 1.0f - bulletDatabase[index].transonicStabilityCoef;
|
||||
|
||||
velocityOffset[0] += (distribution(bulletDatabase[index].randGenerator) * 0.8 - 0.4) * coef;
|
||||
velocityOffset[1] += (distribution(bulletDatabase[index].randGenerator) * 0.8 - 0.4) * coef;
|
||||
velocityOffset[2] += (distribution(bulletDatabase[index].randGenerator) * 0.8 - 0.4) * coef;
|
||||
};
|
||||
|
||||
outputStr << "_bullet setVelocity (_bulletVelocity vectorAdd [" << velocityOffset[0] << "," << velocityOffset[1] << "," << velocityOffset[2] << "]); _bullet setPosASL (_bulletPosition vectorAdd [" << positionOffset[0] << "," << positionOffset[1] << "," << positionOffset[2] << "]);";
|
||||
strncpy_s(output, outputSize, outputStr.str().c_str(), _TRUNCATE);
|
||||
EXTENSION_RETURN();
|
||||
@ -725,7 +735,7 @@ void __stdcall RVExtension(char *output, int outputSize, const char *function)
|
||||
} else if (!strcmp(mode, "init")) {
|
||||
int mapSize = 0;
|
||||
int mapGrids = 0;
|
||||
int gridCells = 0;
|
||||
unsigned int gridCells = 0;
|
||||
|
||||
worldName = strtok_s(NULL, ":", &next_token);
|
||||
mapSize = strtol(strtok_s(NULL, ":", &next_token), NULL, 10);
|
||||
|
Loading…
Reference in New Issue
Block a user