Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Advanced Ballistics - Take object size and trees into account for terrain roughness #10697

Merged
merged 2 commits into from
Feb 5, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ GVAR(currentGrid) = 0;
INFO_2("Starting Terrain Extension [cells: %1] [world: %2]",_gridCells,worldName);

[{
params ["_args","_idPFH"];
params ["_args", "_idPFH"];
_args params ["_mapGrids", "_gridCells", "_initStartTime"];

if (GVAR(currentGrid) >= _gridCells) exitWith {
Expand All @@ -57,12 +57,21 @@ INFO_2("Starting Terrain Extension [cells: %1] [world: %2]",_gridCells,worldName
for "_i" from 1 to 50 do {
private _x = floor(GVAR(currentGrid) / _mapGrids) * 50;
private _y = (GVAR(currentGrid) - floor(GVAR(currentGrid) / _mapGrids) * _mapGrids) * 50;

private _gridCenter = [_x + 25, _y + 25];
private _gridHeight = round(getTerrainHeightASL _gridCenter);
private _gridNumObjects = count (_gridCenter nearObjects ["Building", 50]);
"ace" callExtension ["ballistics:map:set", [GVAR(currentGrid), _gridHeight, _gridNumObjects, surfaceIsWater _gridCenter]];
private _gridHeight = round getTerrainHeightASL _gridCenter;
private _gridBuildingCount = {
private _bb = boundingBoxReal [_x, "ViewGeometry"];
private _height = _bb#1#2 - _bb#0#2;
private _volume = (_bb#1#0 - _bb#0#0) * (_bb#1#1 - _bb#0#1) * _height;

(_height > 0.3) && {_volume > 10}
} count (_windSource nearObjects ["Building", 50]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

help[L-S13]: Undefined Var - _windSource
   ┌─ addons/advanced_ballistics/functions/fnc_initializeTerrainExtension.sqf:69:18
   │
69 │         } count (_windSource nearObjects ["Building", 50]);
   │                  ^^^^^^^^^^^

LinkIsGrim marked this conversation as resolved.
Show resolved Hide resolved
private _gridTreeCount = count nearestTerrainObjects [_windSource, ["TREE"], 50, false];
private _roughnessIndex = _gridBuildingCount + round (_gridTreeCount / 9);

"ace" callExtension ["ballistics:map:set", [GVAR(currentGrid), _gridHeight, _roughnessIndex, surfaceIsWater _gridCenter]];
GVAR(currentGrid) = GVAR(currentGrid) + 1;
if (GVAR(currentGrid) >= _gridCells) exitWith {};
};

}, 0, [_mapGrids, _gridCells, _initStartTime]] call CBA_fnc_addPerFrameHandler
19 changes: 10 additions & 9 deletions addons/weather/functions/fnc_calculateRoughnessLength.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,20 @@
// Source: http://es.ucsc.edu/~jnoble/wind/extrap/index.html
#define ROUGHNESS_LENGTHS [0.0002, 0.0005, 0.0024, 0.03, 0.055, 0.1, 0.2, 0.4, 0.8, 1.6]

private _windSource = _this vectorDiff ((vectorNormalized wind) vectorMultiply 25);
private _windSource = ASLtoAGL (_this vectorDiff ((vectorNormalized wind) vectorMultiply 25));

Check notice on line 21 in addons/weather/functions/fnc_calculateRoughnessLength.sqf

View workflow job for this annotation

GitHub Actions / windows

`ASLtoAGL` does not match the wiki's case

non-standard command case
private _nearBuildingCount = {
// Filter lights - fixes high roughness on airports (#6602)
str _x find "light" == -1
} count (ASLToAGL _windSource nearObjects ["Building", 50]);
private _bb = boundingBoxReal [_x, "ViewGeometry"];
private _height = _bb#1#2 - _bb#0#2;
private _volume = (_bb#1#0 - _bb#0#0) * (_bb#1#1 - _bb#0#1) * _height;

(_height > 0.3) && {_volume > 10}
} count (_windSource nearObjects ["Building", 50]);
private _nearTreeCount = count nearestTerrainObjects [_windSource, ["TREE"], 50, false];
private _isWater = surfaceIsWater _windSource;

if (_nearBuildingCount == 0 && _isWater) exitWith {
0.0005
};

if (_nearBuildingCount >= 10) exitWith {
1.6
};

ROUGHNESS_LENGTHS select (2 + (_nearBuildingCount min 6))
private _roughnessIndex = _nearBuildingCount + round (_nearTreeCount / 9);
ROUGHNESS_LENGTHS select (2 + _roughnessIndex min 9)