Minor wind deflection optimization (#4762)

This commit is contained in:
PabstMirror 2016-12-16 01:08:10 -06:00 committed by ulteq
parent d8fec7fbe3
commit 988c5b0a25

View File

@ -29,16 +29,16 @@
_x params ["_bullet", "_airFriction"]; _x params ["_bullet", "_airFriction"];
private _bulletVelocity = velocity _bullet; private _bulletVelocity = velocity _bullet;
private _bulletSpeed = vectorMagnitude _bulletVelocity; private _bulletSpeedSqr = vectorMagnitudeSqr _bulletVelocity;
if ((!alive _bullet) || {(_bullet isKindOf "BulletBase") && {_bulletSpeed < 100}}) then { if ((!alive _bullet) || {(_bullet isKindOf "BulletBase") && {_bulletSpeedSqr < 10000}}) then {
GVAR(trackedBullets) deleteAt (GVAR(trackedBullets) find _x); GVAR(trackedBullets) deleteAt (GVAR(trackedBullets) find _x);
} else { } else {
if (_isWind) then { if (_isWind) then {
private _trueVelocity = _bulletVelocity vectorDiff ACE_wind; private _trueVelocity = _bulletVelocity vectorDiff ACE_wind;
private _trueSpeed = vectorMagnitude _trueVelocity; private _trueSpeed = vectorMagnitude _trueVelocity;
private _dragRef = _deltaT * _airFriction * _bulletSpeed * _bulletSpeed; private _dragRef = _deltaT * _airFriction * _bulletSpeedSqr;
private _accelRef = (vectorNormalized _bulletVelocity) vectorMultiply (_dragRef); private _accelRef = (vectorNormalized _bulletVelocity) vectorMultiply (_dragRef);
_bulletVelocity = _bulletVelocity vectorDiff _accelRef; _bulletVelocity = _bulletVelocity vectorDiff _accelRef;