Skip to content

Commit

Permalink
Advanced Ballistics - Drag model revamp & Spin drift correction (#5566)
Browse files Browse the repository at this point in the history
* Advanced Ballistics - Drag model revamp
- Moved away from using the drag tables from the GNU exterior ballistics library
- The drag functions are now based off this data from JBM Ballistics: http://www.jbmballistics.com/ballistics/downloads/text/
- The differences are minor, but some players might still appreciate the additional authenticity

* The Mach number is now calculated in relation to the air temperature.

* Improved speed of sound calculation accuracy.

* Advanced Ballistics - DLL update

* Advanced Ballistics - Added drag function reference (JBM Ballistics)

* Advanced Ballistics - Fixed calculation error in the spin drift simulation
- The error was introduced with this PR (#4708)

* More descriptive variable names

* Minor performance optimizations

* Fixed some minor issues

* DLL rebuild

* Utilize new 'toFixed' script command
- Small performance improvement

* Fixed a typo

* Use correct reference speed for the drag compensation

* Updated all 'airFriction' values to match the new drag model

* 'Default' atmosphere now equals the ICAO standard atmosphere

* Update reference humidity to meet the ICAO standard
  • Loading branch information
ulteq authored and PabstMirror committed Oct 6, 2017
1 parent d5aeec1 commit be482ea
Show file tree
Hide file tree
Showing 18 changed files with 325 additions and 411 deletions.
Binary file modified ace_advanced_ballistics.dll
Binary file not shown.
Binary file modified ace_advanced_ballistics_x64.dll
Binary file not shown.
4 changes: 1 addition & 3 deletions addons/advanced_ballistics/functions/fnc_handleFirePFH.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
*/
#include "script_component.hpp"

private _aceTimeSecond = floor CBA_missionTime;

{
_x params ["_bullet","_caliber","_bulletTraceVisible","_index"];

Expand All @@ -33,7 +31,7 @@ private _aceTimeSecond = floor CBA_missionTime;
drop ["\A3\data_f\ParticleEffects\Universal\Refract","","Billboard",1,0.1,getPos _bullet,[0,0,0],0,1.275,1,0,[0.02*_caliber,0.01*_caliber],[[0,0,0,0.65],[0,0,0,0.2]],[1,0],0,0,"","",""];
};

_bullet setVelocity (_bulletVelocity vectorAdd (parseSimpleArray ("ace_advanced_ballistics" callExtension format["simulate:%1:%2:%3:%4:%5:%6:%7", _index, _bulletVelocity, _bulletPosition, ACE_wind, ASLToATL(_bulletPosition) select 2, _aceTimeSecond, CBA_missionTime - _aceTimeSecond])));
_bullet setVelocity (_bulletVelocity vectorAdd (parseSimpleArray ("ace_advanced_ballistics" callExtension format["simulate:%1:%2:%3:%4:%5:%6:%7", _index, _bulletVelocity, _bulletPosition, ACE_wind, ASLToATL(_bulletPosition) select 2, CBA_missionTime toFixed 6])));
};
nil
} count +GVAR(allBullets);
Expand Down
5 changes: 2 additions & 3 deletions addons/advanced_ballistics/functions/fnc_handleFired.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
TRACE_10("firedEH:",_unit, _weapon, _muzzle, _mode, _ammo, _magazine, _projectile, _vehicle, _gunner, _turret);

// Parameterization
private ["_abort", "_AmmoCacheEntry", "_WeaponCacheEntry", "_opticsName", "_opticType", "_bulletTraceVisible", "_temperature", "_barometricPressure", "_bulletMass", "_bulletLength", "_muzzleVelocity", "_muzzleVelocityShift", "_bulletVelocity", "_bulletLength", "_barrelTwist", "_stabilityFactor", "_aceTimeSecond", "_barrelVelocityShift", "_ammoTemperatureVelocityShift"];
private ["_abort", "_AmmoCacheEntry", "_WeaponCacheEntry", "_opticsName", "_opticType", "_bulletTraceVisible", "_temperature", "_barometricPressure", "_bulletMass", "_bulletLength", "_muzzleVelocity", "_muzzleVelocityShift", "_bulletVelocity", "_bulletLength", "_barrelTwist", "_stabilityFactor", "_barrelVelocityShift", "_ammoTemperatureVelocityShift"];

_abort = false;

Expand Down Expand Up @@ -113,8 +113,7 @@ if (_caliber > 0 && _bulletLength > 0 && _bulletMass > 0 && _barrelTwist > 0) th

GVAR(currentbulletID) = (GVAR(currentbulletID) + 1) % 10000;

_aceTimeSecond = floor CBA_missionTime;
"ace_advanced_ballistics" callExtension format["new:%1:%2:%3:%4:%5:%6:%7:%8:%9:%10:%11:%12:%13:%14:%15:%16:%17:%18", GVAR(currentbulletID), _airFriction, _ballisticCoefficients, _velocityBoundaries, _atmosphereModel, _dragModel, _stabilityFactor, _twistDirection, _muzzleVelocity, _transonicStabilityCoef, getPosASL _projectile, EGVAR(common,mapLatitude), EGVAR(weather,currentTemperature), EGVAR(common,mapAltitude), EGVAR(weather,currentHumidity), overcast, _aceTimeSecond, CBA_missionTime - _aceTimeSecond];
"ace_advanced_ballistics" callExtension format["new:%1:%2:%3:%4:%5:%6:%7:%8:%9:%10:%11:%12:%13:%14:%15:%16:%17:%18", GVAR(currentbulletID), _airFriction, _ballisticCoefficients, _velocityBoundaries, _atmosphereModel, _dragModel, _stabilityFactor, _twistDirection, _muzzleVelocity, _transonicStabilityCoef, getPosASL _projectile, EGVAR(common,mapLatitude), EGVAR(weather,currentTemperature), EGVAR(common,mapAltitude), EGVAR(weather,currentHumidity), overcast, CBA_missionTime toFixed 6];

GVAR(allBullets) pushBack [_projectile, _caliber, _bulletTraceVisible, GVAR(currentbulletID)];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ private _distance = 0;
while {_velocity > _thresholdVelocity} do {
private _bc = GVAR(targetSolutionInput) select 14;
private _dragModel = GVAR(targetSolutionInput) select 15;
private _drag = parseNumber(("ace_advanced_ballistics" callExtension format["retard:%1:%2:%3", _dragModel, _bc, _velocity]));
private _temperature = GVAR(targetSolutionInput) select 5;
private _drag = parseNumber(("ace_advanced_ballistics" callExtension format["retard:%1:%2:%3:%4", _dragModel, _bc, _velocity, _temperature]));
_distance = _distance + _velocity * __DELTA_T;
_velocity = _velocity - (_drag * __DELTA_T);
};
Expand Down
2 changes: 1 addition & 1 deletion addons/atragmx/functions/fnc_calculate_solution.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ while {_TOF < 15 && (_bulletPos select 1) < _targetRange} do {
_trueSpeed = vectorMagnitude _trueVelocity;

if (missionNamespace getVariable [QEGVAR(advanced_ballistics,enabled), false]) then {
private _drag = parseNumber(("ace_advanced_ballistics" callExtension format["retard:%1:%2:%3", _dragModel, _bc, _trueSpeed]));
private _drag = parseNumber(("ace_advanced_ballistics" callExtension format["retard:%1:%2:%3:%4", _dragModel, _bc, _trueSpeed, _temperature]));
_bulletAccel = (vectorNormalized _trueVelocity) vectorMultiply (-1 * _drag);
} else {
_bulletAccel = _trueVelocity vectorMultiply (_trueSpeed * _airFriction);
Expand Down
2 changes: 1 addition & 1 deletion addons/atragmx/functions/fnc_init.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ GVAR(atmosphereModeTBH) = true;
GVAR(altitude) = 0;
GVAR(temperature) = 15;
GVAR(barometricPressure) = 1013.25;
GVAR(relativeHumidity) = 0.5;
GVAR(relativeHumidity) = 0.0;

GVAR(latitude) = [38, 38, 38, 38];
GVAR(directionOfFire) = [0, 0, 0, 0];
Expand Down
Loading

0 comments on commit be482ea

Please sign in to comment.