Last active
April 23, 2023 20:39
-
-
Save veteran29/badbe1b700af03572f15e3e5b016ed94 to your computer and use it in GitHub Desktop.
Floating bushes detector
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// author: veteran29 | |
// execute in 3DEN editor debug console to see floating bushes as icons/lines | |
_eh = missionNamespace getVariable ["bushesEh", -1]; | |
removeMissionEventHandler ["Draw3D", _eh]; | |
bushesEh = addMissionEventHandler ["Draw3d", { | |
{ | |
_x params ["_from", "_to", "_bush"]; | |
_isClose = get3DENCamera distance _bush < 150; | |
_text = ["", getModelInfo _bush#0] select _isClose; | |
_icon = ["\A3\ui_f\data\map\markers\handdrawn\dot_CA.paa", ""] select _isClose; | |
drawIcon3D [_icon, [1,0,0,1], ASLToAGL getPosASL _bush, 0.25, 0.25, 0, _text, 1, 0.025, "PuristaMedium"]; | |
if (_isClose) then {drawLine3D [_from, _to, [1,1,1,1]]}; | |
} forEach floatingBushesDraw; | |
}]; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// author: veteran29 | |
// execute in 3DEN editor debug console | |
IGNORED_MODELS = ["vn_elephant_grass_01.p3d", "vn_b_arundod2s_f.p3d"]; | |
// non floating bushes will be hidden for easier debugging. | |
HIDE_NOT_FLOATING = false; | |
// bushes near cliffs will be ignored | |
IGNORE_ON_CLIFFS = true; | |
CLIFF_SEARCH_DIST = 35; | |
//-------------------------------------------------- | |
_center = [worldSize/2, worldSize/2]; | |
// bushes = nil; | |
if (isNil "bushes") then { | |
bushes = nearestTerrainObjects [_center, ["BUSH"], worldSize]; | |
}; | |
floatingBushes = (bushes select { | |
( | |
!(getModelInfo _x#0 in IGNORED_MODELS) | |
// floating over terrain | |
&& getPosATL _x#2 > 2 | |
// not over an terrain object (bushes on rocks) | |
&& { | |
private _p = getPosWorld _x; | |
private _int = lineIntersectsSurfaces [ | |
_p vectorAdd (vectorUp _x vectorMultiply 1.5), | |
_p vectorAdd (vectorUp _x vectorMultiply -4), | |
_x, | |
objNull, | |
true, | |
1, | |
"VIEW", | |
"GEOM" | |
]; | |
isNull (_int param [0, []] param [2, objNull]) | |
} | |
&& { | |
!IGNORE_ON_CLIFFS || {count nearestTerrainObjects [_x, ["ROCK"], CLIFF_SEARCH_DIST, false] == 0} | |
} | |
&& { | |
_x hideObject false; | |
true | |
} | |
) || { | |
_x hideObject HIDE_NOT_FLOATING; | |
false | |
} | |
}); | |
floatingBushesDraw = floatingBushes apply { | |
_p = getPosWorld _x; | |
[ | |
ASLToAGL (_p vectorAdd (vectorUp _x vectorMultiply 1.5)), | |
ASLToAGL (_p vectorAdd (vectorUp _x vectorMultiply -4)), | |
_x | |
] | |
}; | |
count floatingBushes |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment