setTerrainHeight: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
(Fill in some data)
(Adjust old example to new syntax)
Line 25: Line 25:
|r1= [[Nothing]]
|r1= [[Nothing]]


|x1= <sqf>setTerrainHeight [ [ [X, Y, NewHeight], [X2, Y2, NewHeight2], ... ], adjustObjects];</sqf>
|x1= <sqf>
private _fnc_flattenTerrain =
{
params ["_start", "_a", "_b", "_h"];
_NewPositions = [];
for "_xStep" from 0 to _a do
{
for "_yStep" from 0 to _b do
{
private _newHeight = _start vectorAdd [_xStep, _yStep, 0];
_newHeight set [2, _h];
_NewPositions pushBack _newHeight;
};
};
_NewPositions
};
 
private _desiredTerrainHeight = 150;
setTerrainHeight [[getPosWorld player, 50, 50, _desiredTerrainHeight] call _fnc_flattenTerrain, true];
</sqf>


|p1= [ [X, Y, NewHeight], ... ]: [[Array]] of [[Array]] in format [[PositionASL]]
|p1= [ [X, Y, NewHeight], ... ]: [[Array]] of [[Array]] in format [[PositionASL]]

Revision as of 14:26, 20 June 2022

Hover & click on the images for description
Only available in Development branch(es) until its release with Arma 3 patch v2.10.

Description

Description:
🏗
This article is a work in progress!

Warning, this command is dangerous and if used incorrectly will cause issues.

Heightmap changes are stored in JIP queue, when doing multiple command invocations with the exact same XY positions (same number, same coordinates, order can be different) and different heights, the JIP messages will be merged which saves memory and network bandwidth and performance (each message is processed seperately) for joining clients.

If even just one position is missing or extra or different a new JIP message will be created, each new client will get the old and the new message, which costs bandwidth and performance because the client has to process both heightmap updates seperately.

JIP messages do NOT remove themselves if all positions are returned back to their original values, so if changes to different areas are done during a mission, they will accumulate in JIP queue.

setTerrainHeight should be used to set the height of an "area", and if that area should be further adjusted, the whole area should be adjusted and not just a subsection of it.
Groups:
Diagnostic

Syntax

Syntax:
setTerrainHeight
Parameters:
[ [X, Y, NewHeight], ... ]: Array of Array in format PositionASL XY are world coordinates, and are internally converted to heightmap coordinates like so
_hRes = (getTerrainInfo select 3) _heightmapCoordinates = [round(_x/_hRes), round(_y/_hres)];
adjustObjects: Bool optional, default true. If true then objects on modified points are moved up/down to keep the same ATL height (Danger! Even objects in the sky above modified terrain are adjusted)
Return Value:
Nothing

Examples

Example 1:
private _fnc_flattenTerrain = { params ["_start", "_a", "_b", "_h"]; _NewPositions = []; for "_xStep" from 0 to _a do { for "_yStep" from 0 to _b do { private _newHeight = _start vectorAdd [_xStep, _yStep, 0]; _newHeight set [2, _h]; _NewPositions pushBack _newHeight; }; }; _NewPositions }; private _desiredTerrainHeight = 150; setTerrainHeight [[getPosWorld player, 50, 50, _desiredTerrainHeight] call _fnc_flattenTerrain, true];

Additional Information

See also:
getTerrainInfo getTerrainHeight

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