isFlatEmpty: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Text replacement - " <h3 style='display:none'>Notes</h3>" to "")
m (Text replacement - "\{\{Feature *\| *Informative *\| ([^↵]+) *\}\}" to "{{Feature|informative|$1}}")
 
(56 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{{Command
{{RV|type=command


| arma2
|game1= arma2
|version1= 1.00


|1.00
|game2= arma2oa
|version2= 1.50
 
|game3= tkoh
|version3= 1.00
 
|game4= arma3
|version4= 0.50


|gr1= Positions
|gr1= Positions


| Checks given position against given filter params. Filter includes checks for:
|descr= Checks given position against given filter params. Filter includes checks for:
* If there are any objects closer than given distance from given position (in 2D)
* If there are any objects closer than given distance from given position (in 2D)
* If the area around position is flat enough to match given gradient
* If the area around position is flat enough to match given gradient
Line 13: Line 21:
* If the given position is over shore line
* If the given position is over shore line
The gradient seems to correlate with general hill steepness: 0.1 (10%) ~6°, 0.5 (50%) ~27°, 1.0 (100%) ~45°, etc.
The gradient seems to correlate with general hill steepness: 0.1 (10%) ~6°, 0.5 (50%) ~27°, 1.0 (100%) ~45°, etc.
{{Informative | See also [[BIS_fnc_findSafePos]].}}
{{Feature|informative|See also [[BIS_fnc_findSafePos]].}}


|pr=
|pr= <nowiki/>
* Objects accounted for proximity check seem to be static objects. Nearby vehicles and units do not seem to affect the output
* Objects accounted for proximity check seem to be static objects. Nearby vehicles and units do not seem to affect the output
* Given position will be magically transferred into given position + [[getTerrainHeightASL]] value
* Given position will be magically transferred into given position + [[getTerrainHeightASL]] value
Line 21: Line 29:
* The command might be a bit heavy on computations so avoid frequent and large area checks
* The command might be a bit heavy on computations so avoid frequent and large area checks


| position [[isFlatEmpty]] [minDistance, mode, maxGradient, maxGradientRadius, overLandOrWater, shoreLine, ignoreObject]
|s1= position [[isFlatEmpty]] [minDistance, mode, maxGradient, maxGradientRadius, overLandOrWater, shoreLine, ignoreObject]
 
|p1= position: [[Array]] - position in format [[PositionAGL]]


|p2= [minDistance, mode, maxGradient, maxGradientRadius, overLandOrWater, shoreLine, ignoreObject]: [[Array]]
|p1= position: [[Array]] format [[Position#PositionAGL|PositionAGL]]


|p3= minDistance: [[Number]] - (Optional, default -1) minimum (2D) distance from other objects (range 0..50). -1 to ignore proximity check
|p2= minDistance: [[Number]] - (Optional, default -1) minimum (2D) distance from other objects (range 0..50). -1 to ignore proximity check


|p4= mode: [[Number]] - (Optional, default -1) position check mode ('''ALWAYS USE DEFAULT VALUE''')
|p3= mode: [[Number]] - (Optional, default -1) position check mode ('''ALWAYS USE DEFAULT VALUE''')


|p5= maxGradient: [[Number]] - (Optional, default -1) maximum terrain steepness allowed. -1 to ignore
|p4= maxGradient: [[Number]] - (Optional, default -1) maximum terrain steepness allowed. -1 to ignore


|p6= maxGradientRadius: [[Number]] - (Optional, default 1) how far to extend gradient check
|p5= maxGradientRadius: [[Number]] - (Optional, default 1) how far to extend gradient check


|p7= overLandOrWater: [[Number]] - (Optional, default 0)
|p6= overLandOrWater: [[Number]] - (Optional, default 0)
* 0: position cannot be over water
* 0: position cannot be over water
* 2: position cannot be over land
* 2: position cannot be over land
* -1 to ignore
* -1 to ignore


|p8= shoreLine: [[Boolean]] - (Optional, default [[false]])
|p7= shoreLine: [[Boolean]] - (Optional, default [[false]])
* [[true]]: position is over shoreline (< ~25 m from water)
* [[true]]: position is over shoreline (< ~25 m from water)
* [[false]] to ignore
* [[false]] to ignore


|p9= ignoreObject: [[Object]] - (Optional, default [[objNull]]) object to ignore in proximity checks. [[objNull]] to ignore
|p8= ignoreObject: [[Object]] - (Optional, default [[objNull]]) object to ignore in proximity checks. [[objNull]] to ignore


| [[Array]] - Empty array [] if check failed or [[PositionASL]] if succeded. Resulting position will be original [[PositionAGL]] + [[getTerrainHeightASL]]
|r1= [[Array]] - empty array [] if check failed or [[Position#PositionASL|PositionASL]] if succeded. Resulting position will be original [[Position#PositionAGL|PositionAGL]] + [[getTerrainHeightASL]]


|x1= Check if player position is over land:
|x1= Check if player position is over land:
<code>_overLand = !([[position]] [[player]] [[isFlatEmpty]] [-1, -1, -1, -1, 0, [[false]]] [[isEqualTo]] []);</code>
<sqf>_overLand = !(position player isFlatEmpty [-1, -1, -1, -1, 0, false] isEqualTo []);</sqf>


|x2= Check if player position is over shore line:
|x2= Check if player position is over shore line:
<code>_overShore = !([[position]] [[player]] [[isFlatEmpty]] [-1, -1, -1, -1, 0, [[true]]] [[isEqualTo]] []);</code>
<sqf>_overShore = !(position player isFlatEmpty  [-1, -1, -1, -1, 0, true] isEqualTo []);</sqf>


|x3= Check if player position is over water:
|x3= Check if player position is over water:
<code>_overWater = !([[position]] [[player]] [[isFlatEmpty]] [-1, -1, -1, -1, 2, [[false]]] [[isEqualTo]] []);</code>
<sqf>_overWater = !(position player isFlatEmpty  [-1, -1, -1, -1, 2, false] isEqualTo []);</sqf>


|x4= Check if no object is closer than 5m to player position:
|x4= Check if no object is closer than 5m to player position:
<code>_isEmpty = !([[position]] [[player]] [[isFlatEmpty]] [5, -1, -1, -1, -1, [[false]], [[player]]] [[isEqualTo]] []);</code>
<sqf>_isEmpty = !(position player isFlatEmpty  [5, -1, -1, -1, -1, false, player] isEqualTo []);</sqf>


|x5= Check if area 10m around player position is relatively flat:
|x5= Check if area 10m around player position is relatively flat:
<code>_isFlat = !([[position]] [[player]] [[isFlatEmpty]] [-1, -1, 0.3, 10, -1] [[isEqualTo]] []);</code>
<sqf>_isFlat = !(position player isFlatEmpty  [-1, -1, 0.3, 10, -1] isEqualTo []);</sqf>


|x6= Check if area 15m around player position is very flat and empty:
|x6= Check if area 15m around player position is very flat and empty:
<code>_isFlatEmpty = !([[position]] [[player]] [[isFlatEmpty]] [15, -1, 0.1, 15, -1, [[false]], [[player]]] [[isEqualTo]] []);</code>
<sqf>_isFlatEmpty = !(position player isFlatEmpty  [15, -1, 0.1, 15, -1, false, player] isEqualTo []);</sqf>


| [[BIS_fnc_findSafePos]], [[selectBestPlaces]], [[findEmptyPosition]]
|seealso= [[BIS_fnc_findSafePos]] [[selectBestPlaces]] [[findEmptyPosition]]
}}
}}


<dl class='command_description'>
{{Note
</dl>
|user= Killzone_Kid
 
|timestamp= 20160424171800
<h3 style='display:none'>Bottom Section</h3>
|text= When this command is instructed to check if area at given position is empty it takes into account the radius of the bounding sphere of surrounding objects. Because of this, the high voltage columns such as "Land_HighVoltageColumnWire_F" and such objects may appear extremely large to the calculations and the position will be rejected even if visually it doesn't look too bad. To avoid this, use [[findEmptyPosition]] command first to find guaranteed empty position, then pass the result to [[isFlatEmpty]] making sure you switched off proximity check by setting 1st param to -1. For example:
 
<sqf>
{{GameCategory|arma3|Scripting Commands}}
// Check if given position is flat and empty within 1m radius
{{GameCategory|tkoh|Scripting Commands}}
[4274.66,12113,0.00139618] isFlatEmpty [1, -1, 0.1, 1, -1, false, objNull]; // []
 
</sqf>
<!-- CONTINUE Notes -->
<dl class="command_description">
<dd class="notedate">Posted on April 24, 2016 - 17:18 (UTC)</dd>
<dt class="note">[[User:Killzone Kid|Killzone Kid]]</dt>
<dd class="note">
When this command is instructed to check if area at given position is empty it takes into account the radius of the bounding sphere of surrounding objects. Because of this, the high voltage columns such as "Land_HighVoltageColumnWire_F" and such objects may appear extremely large to the calculations and the position will be rejected even if visually it doesn't look too bad. To avoid this, use [[findEmptyPosition]] command first to find guaranteed empty position, then pass the result to [[isFlatEmpty]] making sure you switched off proximity check by setting 1st param to -1. For example:
<code>{{cc|Check if given position is flat and empty within 1m radius}}
[4274.66,12113,0.00139618] [[isFlatEmpty]] [1, -1, 0.1, 1, -1, [[false]], [[objNull]]]; {{cc|[]}}</code>
The result suggests it is not flat and empty.
The result suggests it is not flat and empty.
<code>{{cc|Check if given position is flat within 1m radius}}
<sqf>
[4274.66,12113,0.00139618] [[isFlatEmpty]] [-1, -1, 0.1, 1, -1, [[false]], [[objNull]]]; {{cc|[4274.66,12113,48.3209]}}</code>
// Check if given position is flat within 1m radius
[4274.66,12113,0.00139618] isFlatEmpty [-1, -1, 0.1, 1, -1, false, objNull]; // [4274.66,12113,48.3209]
</sqf>
The result suggests it is.
The result suggests it is.
<code>{{cc|Check if given position is empty within 1m radius}}
<sqf>
[4274.66,12113,0.00139618] [[isFlatEmpty]] [1, -1, -1, -1, -1, [[false]], [[objNull]]]; {{cc|[]}}</code>
// Check if given position is empty within 1m radius
[4274.66,12113,0.00139618] isFlatEmpty [1, -1, -1, -1, -1, false, objNull]; // []
</sqf>
The result suggests it is not empty. But the position is in the middle of a road and there is nothing within 1m but there is "Land_HighVoltageColumnWire_F" not far.
The result suggests it is not empty. But the position is in the middle of a road and there is nothing within 1m but there is "Land_HighVoltageColumnWire_F" not far.
<code>{{cc|Check if given position is empty within 1m radius ignoring nearest "Land_HighVoltageColumnWire_F"}}
<sqf>
[4274.66,12113,0.00139618] [[isFlatEmpty]] [1, -1, -1, 1, -1, [[false]], [[nearestObject]] [[4274.66,12113,0.00139618], "Land_HighVoltageColumnWire_F"]]; {{cc|[4274.66,12113,48.3209]}}</code>
// Check if given position is empty within 1m radius ignoring nearest "Land_HighVoltageColumnWire_F"
[4274.66,12113,0.00139618] isFlatEmpty [1, -1, -1, 1, -1, false, nearestObject [[4274.66,12113,0.00139618], "Land_HighVoltageColumnWire_F"]]; // [4274.66,12113,48.3209]
</sqf>
The result now suggests it is empty. So instead of relying on internal proximity check we can combine both commands:
The result now suggests it is empty. So instead of relying on internal proximity check we can combine both commands:
<code>fnc_isFlatEmpty =
<sqf>
fnc_isFlatEmpty =
{
{
[[params]] ["_pos", "_params"];
params ["_pos", "_params"];
_pos = _pos [[findEmptyPosition]] [0, _params [[select]] 0];
_pos = _pos findEmptyPosition [0, _params select 0];
[[if]] (_pos [[isEqualTo]] []) [[exitWith]] {[]};
if (_pos isEqualTo []) exitWith {[]};
_params = +_params;
_params = +_params;
_params [[set]] [0, -1];
_params set [0, -1];
_pos = _pos [[isFlatEmpty]] _params;
_pos = _pos isFlatEmpty _params;
[[if]] (_pos [[isEqualTo]] []) [[exitWith]] {[]};
if (_pos isEqualTo []) exitWith {[]};
_pos
_pos
};
};


{{cc|Test}}
// Test
[[4274.66,12113,0.00139618], [1, -1, 0.1, 1, -1, [[false]], [[objNull]]]] [[call]] fnc_isFlatEmpty; {{cc|[4274.53,12113,48.3175]}}
[[4274.66,12113,0.00139618], [1, -1, 0.1, 1, -1, false, objNull]] call fnc_isFlatEmpty; // [4274.53,12113,48.3175]
</code>
</sqf>
</dd>
}}
</dl>
<!-- DISCONTINUE Notes -->

Latest revision as of 18:11, 15 March 2024

Hover & click on the images for description

Description

Description:
Checks given position against given filter params. Filter includes checks for:
  • If there are any objects closer than given distance from given position (in 2D)
  • If the area around position is flat enough to match given gradient
  • If the given position is over water or land
  • If the given position is over shore line
The gradient seems to correlate with general hill steepness: 0.1 (10%) ~6°, 0.5 (50%) ~27°, 1.0 (100%) ~45°, etc.
Problems:
  • Objects accounted for proximity check seem to be static objects. Nearby vehicles and units do not seem to affect the output
  • Given position will be magically transferred into given position + getTerrainHeightASL value
  • The second element must be -1 (≤ 0 really) at all times, otherwise command becomes unusable
  • The command might be a bit heavy on computations so avoid frequent and large area checks
Groups:
Positions

Syntax

Syntax:
position isFlatEmpty [minDistance, mode, maxGradient, maxGradientRadius, overLandOrWater, shoreLine, ignoreObject]
Parameters:
position: Array format PositionAGL
minDistance: Number - (Optional, default -1) minimum (2D) distance from other objects (range 0..50). -1 to ignore proximity check
mode: Number - (Optional, default -1) position check mode (ALWAYS USE DEFAULT VALUE)
maxGradient: Number - (Optional, default -1) maximum terrain steepness allowed. -1 to ignore
maxGradientRadius: Number - (Optional, default 1) how far to extend gradient check
overLandOrWater: Number - (Optional, default 0)
  • 0: position cannot be over water
  • 2: position cannot be over land
  • -1 to ignore
shoreLine: Boolean - (Optional, default false)
  • true: position is over shoreline (< ~25 m from water)
  • false to ignore
ignoreObject: Object - (Optional, default objNull) object to ignore in proximity checks. objNull to ignore
Return Value:
Array - empty array [] if check failed or PositionASL if succeded. Resulting position will be original PositionAGL + getTerrainHeightASL

Examples

Example 1:
Check if player position is over land:
_overLand = !(position player isFlatEmpty [-1, -1, -1, -1, 0, false] isEqualTo []);
Example 2:
Check if player position is over shore line:
_overShore = !(position player isFlatEmpty [-1, -1, -1, -1, 0, true] isEqualTo []);
Example 3:
Check if player position is over water:
_overWater = !(position player isFlatEmpty [-1, -1, -1, -1, 2, false] isEqualTo []);
Example 4:
Check if no object is closer than 5m to player position:
_isEmpty = !(position player isFlatEmpty [5, -1, -1, -1, -1, false, player] isEqualTo []);
Example 5:
Check if area 10m around player position is relatively flat:
_isFlat = !(position player isFlatEmpty [-1, -1, 0.3, 10, -1] isEqualTo []);
Example 6:
Check if area 15m around player position is very flat and empty:
_isFlatEmpty = !(position player isFlatEmpty [15, -1, 0.1, 15, -1, false, player] isEqualTo []);

Additional Information

See also:
BIS_fnc_findSafePos selectBestPlaces findEmptyPosition

Notes

Report bugs on the Feedback Tracker and/or discuss them on the Arma Discord or on the Forums.
Only post proven facts here! Add Note
Killzone_Kid - c
Posted on Apr 24, 2016 - 17:18 (UTC)
When this command is instructed to check if area at given position is empty it takes into account the radius of the bounding sphere of surrounding objects. Because of this, the high voltage columns such as "Land_HighVoltageColumnWire_F" and such objects may appear extremely large to the calculations and the position will be rejected even if visually it doesn't look too bad. To avoid this, use findEmptyPosition command first to find guaranteed empty position, then pass the result to isFlatEmpty making sure you switched off proximity check by setting 1st param to -1. For example:
// Check if given position is flat and empty within 1m radius [4274.66,12113,0.00139618] isFlatEmpty [1, -1, 0.1, 1, -1, false, objNull]; // []
The result suggests it is not flat and empty.
// Check if given position is flat within 1m radius [4274.66,12113,0.00139618] isFlatEmpty [-1, -1, 0.1, 1, -1, false, objNull]; // [4274.66,12113,48.3209]
The result suggests it is.
// Check if given position is empty within 1m radius [4274.66,12113,0.00139618] isFlatEmpty [1, -1, -1, -1, -1, false, objNull]; // []
The result suggests it is not empty. But the position is in the middle of a road and there is nothing within 1m but there is "Land_HighVoltageColumnWire_F" not far.
// Check if given position is empty within 1m radius ignoring nearest "Land_HighVoltageColumnWire_F" [4274.66,12113,0.00139618] isFlatEmpty [1, -1, -1, 1, -1, false, nearestObject [[4274.66,12113,0.00139618], "Land_HighVoltageColumnWire_F"]]; // [4274.66,12113,48.3209]
The result now suggests it is empty. So instead of relying on internal proximity check we can combine both commands:
fnc_isFlatEmpty = { params ["_pos", "_params"]; _pos = _pos findEmptyPosition [0, _params select 0]; if (_pos isEqualTo []) exitWith {[]}; _params = +_params; _params set [0, -1]; _pos = _pos isFlatEmpty _params; if (_pos isEqualTo []) exitWith {[]}; _pos }; // Test [[4274.66,12113,0.00139618], [1, -1, 0.1, 1, -1, false, objNull]] call fnc_isFlatEmpty; // [4274.53,12113,48.3175]