mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Advanced Ballistics - Improve Performance in handleFirePFH (#7699)
* Improve Performance from handleFirePFH in Advanced Ballistics * PabstMirror Suggestion * Dont remove and readd the PFH but have one persitently running * Update addons/advanced_ballistics/XEH_postInit.sqf Co-authored-by: PabstMirror <pabstmirror@gmail.com> Co-authored-by: PabstMirror <pabstmirror@gmail.com>
This commit is contained in:
parent
7c93ee9ed3
commit
6a59bf2a6c
@ -22,6 +22,9 @@ if (!hasInterface) exitWith {};
|
||||
["ace_firedPlayer", DFUNC(handleFired)] call CBA_fnc_addEventHandler;
|
||||
["ace_firedPlayerNonLocal", DFUNC(handleFired)] call CBA_fnc_addEventHandler;
|
||||
|
||||
// Register Perframe Handler
|
||||
[FUNC(handleFirePFH), GVAR(simulationInterval)] call CBA_fnc_addPerFrameHandler;
|
||||
|
||||
//Add warnings for missing compat PBOs (only if AB is on)
|
||||
{
|
||||
_x params ["_modPBO", "_compatPBO"];
|
||||
|
@ -15,12 +15,11 @@
|
||||
* Public: No
|
||||
*/
|
||||
|
||||
private _deleted = false;
|
||||
{
|
||||
_x params ["_bullet","_caliber","_bulletTraceVisible","_index"];
|
||||
|
||||
if (!alive _bullet) then {
|
||||
GVAR(allBullets) deleteAt (GVAR(allBullets) find _x);
|
||||
} else {
|
||||
if (alive _bullet) then {
|
||||
private _bulletVelocity = velocity _bullet;
|
||||
private _bulletPosition = getPosASL _bullet;
|
||||
|
||||
@ -29,11 +28,12 @@
|
||||
};
|
||||
|
||||
_bullet setVelocity (_bulletVelocity vectorAdd (parseSimpleArray ("ace_advanced_ballistics" callExtension format["simulate:%1:%2:%3:%4:%5:%6", _index, _bulletVelocity, _bulletPosition, wind, ASLToATL(_bulletPosition) select 2, CBA_missionTime toFixed 6])));
|
||||
} else {
|
||||
GVAR(allBullets) set [_forEachIndex, objNull];
|
||||
_deleted = true;
|
||||
};
|
||||
nil
|
||||
} count +GVAR(allBullets);
|
||||
} forEach GVAR(allBullets);
|
||||
|
||||
if (GVAR(allBullets) isEqualTo []) then {
|
||||
[_this select 1] call CBA_fnc_removePerFrameHandler;
|
||||
GVAR(BulletPFH) = nil;
|
||||
if (_deleted) then {
|
||||
GVAR(allBullets) = GVAR(allBullets) - [objNull];
|
||||
};
|
||||
|
@ -27,7 +27,7 @@ private _abort = !local _unit;
|
||||
if (_abort) then {
|
||||
private _bulletVelocity = velocity _projectile;
|
||||
private _muzzleVelocity = vectorMagnitude _bulletVelocity;
|
||||
|
||||
|
||||
private _maxRange = uiNamespace getVariable format[QGVAR(maxRange_%1), _ammo];
|
||||
if (isNil "_maxRange") then {
|
||||
private _airFriction = getNumber(configFile >> "CfgAmmo" >> _ammo >> "airFriction");
|
||||
@ -40,12 +40,12 @@ if (_abort) then {
|
||||
uiNamespace setVariable [format[QGVAR(maxRange_%1), _ammo], _maxRange];
|
||||
};
|
||||
if (ACE_player distance _unit > _maxRange && {ACE_player distance ((getPosASL _unit) vectorAdd ((vectorNormalized _bulletVelocity) vectorMultiply _maxRange)) > _maxRange}) exitWith {};
|
||||
|
||||
|
||||
private _ammoCount = (_unit ammo _muzzle) + 1;
|
||||
private _tracersEvery = getNumber(configFile >> "CfgMagazines" >> _magazine >> "tracersEvery");
|
||||
private _lastRoundsTracer = getNumber(configFile >> "CfgMagazines" >> _magazine >> "lastRoundsTracer");
|
||||
if (_ammoCount <= _lastRoundsTracer || {_tracersEvery > 0 && {(_ammoCount - _lastRoundsTracer) % _tracersEvery == 0}}) exitWith { _abort = false };
|
||||
|
||||
|
||||
if (GVAR(bulletTraceEnabled) && {_muzzleVelocity > BULLET_TRACE_MIN_VELOCITY} && {cameraView == "GUNNER"}) then {
|
||||
if (currentWeapon ACE_player == binocular ACE_player) exitWith { _abort = false };
|
||||
if (currentWeapon ACE_player == primaryWeapon ACE_player && {count primaryWeaponItems ACE_player > 2}) then {
|
||||
@ -89,7 +89,7 @@ if (GVAR(muzzleVelocityVariationEnabled)) then {
|
||||
private _seed = 0.5 * (_time + _ammoCount) * (_time + _ammoCount + 1) + _ammoCount;
|
||||
// Generate normally distributed random number (via Box–Muller transform)
|
||||
private _z = sqrt(-2.0 * ln(0.00000001 max (-_seed random 1))) * cos(_seed random 360);
|
||||
|
||||
|
||||
_muzzleVelocity = _muzzleVelocity * (_z * _muzzleVelocityVariationSD + 1);
|
||||
};
|
||||
|
||||
@ -123,7 +123,3 @@ GVAR(currentbulletID) = (GVAR(currentbulletID) + 1) % 10000;
|
||||
"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), _ammoCount, _airFriction, _ballisticCoefficients, _velocityBoundaries, _atmosphereModel, _dragModel, _stabilityFactor, _twistDirection, _transonicStabilityCoef, getPosASL _projectile, _bulletVelocity, EGVAR(common,mapLatitude), EGVAR(weather,currentTemperature), EGVAR(common,mapAltitude), EGVAR(weather,currentHumidity), EGVAR(weather,currentOvercast), CBA_missionTime toFixed 6];
|
||||
|
||||
GVAR(allBullets) pushBack [_projectile, _caliber, _bulletTraceVisible, GVAR(currentbulletID)];
|
||||
|
||||
if (isNil QGVAR(BulletPFH)) then {
|
||||
GVAR(BulletPFH) = [FUNC(handleFirePFH), GVAR(simulationInterval), []] call CBA_fnc_addPerFrameHandler;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user