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

Advanced Ballistics - Drag model revamp & Spin drift correction #5566

Merged
merged 16 commits into from
Oct 6, 2017
Merged
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
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])));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor error. format still expects 7 elements but you only give 6. Doesn't cause any runtime error and the extension doesn't care. So not a problem.

};
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"];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

private keyword would be faster.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

private _abort = true;
is evaluated at compile-time.
private ARRAY is runtime.
Also private ARRAY assigns nil to that variable. and later when you initialize it you assign again. so using private ARRAY you assign a value to the variable one extra time.

Copy link
Contributor Author

@ulteq ulteq Oct 3, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can try to fix that in a separate PR. Feel free to make a GitHub issue for it.

But I think we're using private ARRAY in many places.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fun-fact. using private keyword is also faster than not using private at all.
using private ARRAY however is slower than not privatizing variables. on average.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah.. I'll make a PR that changes it everywhere where appropriate.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

private ARRAY is only in use because some components haven't gotten the love of cleanup yet since private VAR = VALUE was introduced.


_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]));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whitespace after parseNumber and format.

_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]));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same.

_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