mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Replace remaining lineIntersects with lineIntersectsSurfaces (#6898)
* Fix explosive placement while underwater * Apply suggestions from code review Co-Authored-By: alganthe <alganthe@live.fr> * Change placeApprove header to reflect changes * Replace lineIntersectsWith in isInMedicalFacility * Replace linesIntersects in isInRepairFacility, fix params Public func, params should have an expected type. * Replace linesIntersects in spallTrack * Replace lineIntersects in getFirstObjectIntersection and findReflection * Replace lineIntersects in advanced throwing grenades can pass glass underwater now, I bet all of 0 person will be glad that horrendous bug is now fixed. * Fix possible issue in pointing while underwater * Fix possible issue while underwater in attach * Replace count with isEqualTo in lineIntersectsSurfaces replacements * Fix inverted conditions * Fix drawArc * Fix fnc_attach * Reverse advanced_throwing and spallTrack lineIntersects changes * Fix issues raised from code review
This commit is contained in:
parent
ec27cee1ac
commit
5ae0ef6bbe
@ -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
|
||||
};
|
||||
};
|
||||
|
@ -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;};
|
||||
|
@ -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.
|
||||
|
@ -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 <ARRAY>
|
||||
@ -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
|
||||
|
@ -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 {
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -15,7 +15,7 @@
|
||||
* Public: Yes
|
||||
*/
|
||||
|
||||
params ["_object"];
|
||||
params [["_object", objNull, [objNull]]];
|
||||
TRACE_1("params",_object);
|
||||
|
||||
private _position = getPosASL _object;
|
||||
|
Loading…
Reference in New Issue
Block a user