diff --git a/addons/advanced_throwing/functions/fnc_drawArc.sqf b/addons/advanced_throwing/functions/fnc_drawArc.sqf index 906650627f..bd7bc7a661 100644 --- a/addons/advanced_throwing/functions/fnc_drawArc.sqf +++ b/addons/advanced_throwing/functions/fnc_drawArc.sqf @@ -53,7 +53,7 @@ for "_i" from 0.05 to 1.45 step 0.1 do { if (lineIntersects [_prevTrajASL, _newTrajASL]) then { // Checks the "VIEW" LOD _cross = 2; // 2: View LOD Block (Red) } else { - if (!((lineIntersectsSurfaces [_prevTrajASL, _newTrajASL, _activeThrowable, ACE_player, true, 1, "GEOM", "FIRE"]) isEqualTo [])) then { + if !((lineIntersectsSurfaces [_prevTrajASL, _newTrajASL, _activeThrowable, ACE_player, true, 1, "GEOM", "FIRE"]) isEqualTo []) then { _cross = 3; // 3: GEOM/FIRE LOD Block (Yellow) - pass a3 bulding glass, but blocked on some CUP glass }; }; diff --git a/addons/attach/functions/fnc_attach.sqf b/addons/attach/functions/fnc_attach.sqf index 21652f296d..4d43cf47e9 100644 --- a/addons/attach/functions/fnc_attach.sqf +++ b/addons/attach/functions/fnc_attach.sqf @@ -74,7 +74,7 @@ if (_unit == _attachToVehicle) then { //Self Attachment _virtualPosASL = _virtualPosASL vectorAdd ((positionCameraToWorld [0.3,0,0]) vectorDiff (positionCameraToWorld [0,0,0])); }; private _virtualPos = _virtualPosASL call EFUNC(common,ASLToPosition); - private _lineInterection = lineIntersects [eyePos ACE_player, _virtualPosASL, ACE_player]; + private _lineInterection = !((lineIntersectsSurfaces [eyePos ACE_player, _virtualPosASL, ACE_player]) isEqualTo []); //Don't allow placing in a bad position: if (_lineInterection && {GVAR(placeAction) == PLACE_APPROVE}) then {GVAR(placeAction) = PLACE_WAITING;}; diff --git a/addons/attach/functions/fnc_placeApprove.sqf b/addons/attach/functions/fnc_placeApprove.sqf index d0101695b4..2ae6f84b74 100644 --- a/addons/attach/functions/fnc_placeApprove.sqf +++ b/addons/attach/functions/fnc_placeApprove.sqf @@ -3,7 +3,7 @@ * Author: Pabst Mirror (based on Explosive attach by Garth de Wet (LH)) * Approves placement of the lightObject, scans for an appropriate location and attaches * A player can release the attachObject with it floating in mid-air. - * This will use lineIntersectsWith to scan towards the center of the vehicle to find a collision + * This will use lineIntersectsSurfaces to scan towards the center of the vehicle to find a collision * ArmA's collision detection is of couse terrible and often misses collisions (difference between what we see and collision LOD) * So it does multiple scans at slighly different angles * This is VERY computationaly intensive, but doesn't happen that often. diff --git a/addons/common/functions/fnc_getFirstObjectIntersection.sqf b/addons/common/functions/fnc_getFirstObjectIntersection.sqf index 1120707b2b..0cebf6232f 100644 --- a/addons/common/functions/fnc_getFirstObjectIntersection.sqf +++ b/addons/common/functions/fnc_getFirstObjectIntersection.sqf @@ -1,7 +1,7 @@ #include "script_component.hpp" /* * Author: Ruthberg - * Returns the the first intersection with terrain between two positions. @todo rewrite using lineIntersectsSurfaces? + * Returns the the first intersection with terrain between two positions. * * Arguments: * 0: PositionASL @@ -18,31 +18,14 @@ * Public: Yes */ -params ["_source", "_destination", "_accuracy"]; +params ["_source", "_destination"]; private _result = [false, [0, 0, 0]]; - -private _distance = _source vectorDistance _destination; - -if !(lineIntersectsWith [_source, _destination] isEqualTo []) then { - private _lower = 0; - private _upper = 1; - private _mid = 0.5; - - private _dir = _source vectorFromTo _destination; - - while {(_upper - _lower) * _distance > _accuracy} do { - _mid = _lower + (_upper - _lower) / 2; - - if !(lineIntersectsWith [_source, _source vectorAdd (_dir vectorMultiply (_mid * _distance))] isEqualTo []) then { - _upper = _mid; - } else { - _lower = _mid; - }; +private _hits = lineIntersectsSurfaces [_source, _destination, objNull, objNull, true, -1]; +{ + _x params ["_pos", "", "_obj"]; + if (!isNull _obj) exitWith { + _result = [true, _pos]; }; - - _mid = _lower + (_upper - _lower) / 2; - _result = [true, _source vectorAdd (_dir vectorMultiply (_mid * _distance))]; -}; - +} forEach _hits; _result diff --git a/addons/explosives/functions/fnc_setupExplosive.sqf b/addons/explosives/functions/fnc_setupExplosive.sqf index a85580f672..96fc4820e4 100644 --- a/addons/explosives/functions/fnc_setupExplosive.sqf +++ b/addons/explosives/functions/fnc_setupExplosive.sqf @@ -80,7 +80,7 @@ GVAR(TweakedAngle) = 0; #ifdef DEBUG_MODE_FULL drawLine3d [(eyePos _unit) call EFUNC(common,ASLToPosition), (_testPos) call EFUNC(common,ASLToPosition), [1,0,0,1]]; #endif - if (lineIntersects [eyePos _unit, _testPos, _unit]) exitWith {_return = false;}; + if !((lineIntersectsSurfaces [eyePos _unit, _testPos, _unit]) isEqualTo []) exitWith {_return = false;}; } forEach [[0,0], [-1,-1], [1,-1], [-1,1], [1,1]]; _return }; @@ -94,8 +94,8 @@ GVAR(TweakedAngle) = 0; private _testBase = _basePosASL vectorAdd _lookDirVector; { private _testPos = _testBase vectorAdd [0.1 * (_x select 0) * (cos _cameraAngle), 0.1 * (_x select 0) * (sin _cameraAngle), 0.1 * (_x select 1)]; - private _intersectsWith = lineIntersectsWith [eyePos _unit, _testPos, _unit]; - if (count _intersectsWith == 1) exitWith {_attachVehicle = (_intersectsWith select 0);}; + private _intersectObject = ((lineIntersectsSurfaces [eyePos _unit, _testPos, _unit]) param [0, objNull]) param [3, objNull]; + if !(_intersectObject isEqualTo objNull) exitWith {_attachVehicle = _intersectObject}; } forEach [[0,0], [-1,-1], [1,-1], [-1,1], [1,1]]; if ((!isNull _attachVehicle) && {[PLACE_RANGE_MIN] call _testPositionIsValid} && {(_attachVehicle isKindOf "Car") || {_attachVehicle isKindOf "Tank"} || {_attachVehicle isKindOf "Air"} || {_attachVehicle isKindOf "Ship"}}) then { diff --git a/addons/finger/functions/fnc_keyPress.sqf b/addons/finger/functions/fnc_keyPress.sqf index 5308c44e6c..faef2f00a3 100644 --- a/addons/finger/functions/fnc_keyPress.sqf +++ b/addons/finger/functions/fnc_keyPress.sqf @@ -48,7 +48,7 @@ private _nearbyMen = (ACE_player nearObjects ["CAManBase", (GVAR(maxRange) + 2)] {alive _x} && {(_x == (vehicle _x)) || {(vehicle _x) isKindOf "StaticWeapon"}} && {GVAR(indicatorForSelf) || {_x != ACE_player}} && - {!(lineIntersects [(eyePos _x), _playerEyePosASL, vehicle ACE_player, vehicle _x])} && + {((lineIntersectsSurfaces [(eyePos _x), _playerEyePosASL, vehicle ACE_player, vehicle _x]) isEqualTo [])} && {[_x] call EFUNC(common,isPlayer)}) then { _sendFingerToPlayers pushBack _x; diff --git a/addons/frag/functions/fnc_spallTrack.sqf b/addons/frag/functions/fnc_spallTrack.sqf index 8e1bf2f804..3cd3a27ad5 100644 --- a/addons/frag/functions/fnc_spallTrack.sqf +++ b/addons/frag/functions/fnc_spallTrack.sqf @@ -24,11 +24,7 @@ private _velocity = velocity _round; private _velocityStep = _velocity vectorMultiply _delta; private _forwardPos = _curPos vectorAdd _velocityStep; -private _intersectsWith = lineIntersectsWith [_curPos, _forwardPos]; - -if (_intersectsWith isEqualTo []) exitWith {}; - -// player sideChat format ["inter: %1", _intersectsWith]; +if !((lineIntersectsSurfaces [_curPos, _forwardPos]) isEqualTo []) exitWith {}; { // diag_log text format ["Adding HP: %1", _x]; private _index = count GVAR(spallHPData); diff --git a/addons/repair/functions/fnc_isInRepairFacility.sqf b/addons/repair/functions/fnc_isInRepairFacility.sqf index 10ef95ed66..dcbd141fb7 100644 --- a/addons/repair/functions/fnc_isInRepairFacility.sqf +++ b/addons/repair/functions/fnc_isInRepairFacility.sqf @@ -15,7 +15,7 @@ * Public: Yes */ -params ["_object"]; +params [["_object", objNull, [objNull]]]; TRACE_1("params",_object); private _position = getPosASL _object;