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:
Joko 2020-06-13 22:45:09 +02:00 committed by GitHub
parent 7c93ee9ed3
commit 6a59bf2a6c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 16 deletions

View File

@ -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"];

View File

@ -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];
};

View File

@ -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;
};