Moved all wind calculations into the weather module

This commit is contained in:
ulteq 2015-05-11 10:59:07 +02:00
parent d6dde3c73f
commit b03333c9e8
11 changed files with 104 additions and 328 deletions

View File

@ -6,9 +6,7 @@ PREP(calculateAmmoTemperatureVelocityShift);
PREP(calculateAtmosphericCorrection); PREP(calculateAtmosphericCorrection);
PREP(calculateBarrelLengthVelocityShift); PREP(calculateBarrelLengthVelocityShift);
PREP(calculateRetardation); PREP(calculateRetardation);
PREP(calculateRoughnessLength);
PREP(calculateStabilityFactor); PREP(calculateStabilityFactor);
PREP(calculateWindSpeed);
PREP(displayProtractor); PREP(displayProtractor);
PREP(handleFired); PREP(handleFired);
PREP(initializeTerrainExtension); PREP(initializeTerrainExtension);

View File

@ -1,78 +0,0 @@
/*
* Author: Ruthberg
*
* Calculates the true wind speed at a given world position
*
* Arguments:
* 0: _this - world position <posASL>
*
* Return Value:
* 0: wind speed - m/s <NUMBER>
*
* Public: No
*/
#include "script_component.hpp"
private ["_windSpeed", "_windDir", "_height", "_newWindSpeed", "_windSource", "_roughnessLength"];
fnc_polar2vect = {
private ["_mag2D"];
_mag2D = (_this select 0) * cos((_this select 2));
[_mag2D * sin((_this select 1)), _mag2D * cos((_this select 1)), (_this select 0) * sin((_this select 2))];
};
_windSpeed = vectorMagnitude ACE_wind;
_windDir = (ACE_wind select 0) atan2 (ACE_wind select 1);
// Wind gradient
if (_windSpeed > 0.05) then {
_height = (ASLToATL _this) select 2;
_height = 0 max _height min 20;
if (_height < 20) then {
_roughnessLength = _this call FUNC(calculateRoughnessLength);
_windSpeed = _windSpeed * ln(_height / _roughnessLength) / ln(20 / _roughnessLength);
};
};
// Terrain effect on wind
if (_windSpeed > 0.05) then {
_newWindSpeed = 0;
{
_windSource = [100, _windDir + 180, _x] call fnc_polar2vect;
if (!(terrainIntersectASL [_this, _this vectorAdd _windSource])) exitWith {
_newWindSpeed = cos(_x * 9) * _windSpeed;
};
_windSource = [100, _windDir + 180 + _x, 0] call fnc_polar2vect;
if (!(terrainIntersectASL [_this, _this vectorAdd _windSource])) exitWith {
_newWindSpeed = cos(_x * 9) * _windSpeed;
};
_windSource = [100, _windDir + 180 - _x, 0] call fnc_polar2vect;
if (!(terrainIntersectASL [_this, _this vectorAdd _windSource])) exitWith {
_newWindSpeed = cos(_x * 9) * _windSpeed;
};
} forEach [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
_windSpeed = _newWindSpeed;
};
// Obstacle effect on wind
if (_windSpeed > 0.05) then {
_newWindSpeed = 0;
{
_windSource = [20, _windDir + 180, _x] call fnc_polar2vect;
if (!(lineIntersects [_this, _this vectorAdd _windSource])) exitWith {
_newWindSpeed = cos(_x * 2) * _windSpeed;
};
_windSource = [20, _windDir + 180 + _x, 0] call fnc_polar2vect;
if (!(lineIntersects [_this, _this vectorAdd _windSource])) exitWith {
_newWindSpeed = cos(_x * 2) * _windSpeed;
};
_windSource = [20, _windDir + 180 - _x, 0] call fnc_polar2vect;
if (!(lineIntersects [_this, _this vectorAdd _windSource])) exitWith {
_newWindSpeed = cos(_x * 2) * _windSpeed;
};
} forEach [0, 5, 10, 15, 20, 25, 30, 35, 40, 45];
_windSpeed = _newWindSpeed;
};
_windSpeed = 0 max _windSpeed;
_windSpeed

View File

@ -1,167 +0,0 @@
#include "script_component.hpp"
class CfgPatches {
class ADDON {
units[] = {"ACE_Box_Misc", "ACE_bananaItem"};
weapons[] = {"ACE_ItemCore","ACE_FakePrimaryWeapon", "ACE_Banana"};
requiredVersion = REQUIRED_VERSION;
requiredAddons[] = {"ace_main"};
author[] = {"KoffeinFlummi"};
authorUrl = "https://github.com/KoffeinFlummi/";
VERSION_CONFIG;
};
};
#include "CfgEventHandlers.hpp"
#include "CfgSounds.hpp"
#include "CfgVehicles.hpp"
#include "CfgWeapons.hpp"
#include "CfgMagazines.hpp"
#include "CfgActions.hpp"
#include "CfgMoves.hpp"
#include "CfgVoice.hpp"
#include "CfgUnitInsignia.hpp"
class ACE_Rsc_Display_Base {
idd = -1;
type = 0;
style = 48;
name = "";
duration = 999999;
fadeIn = 0;
fadeOut = 0;
font = "TahomaB";
size = 1;
colorBackground[] = {1, 1, 1, 0};
colorText[] = {1, 1, 1, 1};
};
class ACE_Rsc_Control_Base {
idc = 1;
type = 0;
style = 48;
access = 0;
lineSpacing = 0;
moving = 1;
text = "";
size = 1;
sizeEx = 0;
font = "TahomaB";
colorBackground[] = {1, 1, 1, 0};
colorText[] = {1, 1, 1, 1};
x = 0;
y = 0;
w = 0;
h = 0;
};
class ACE_Settings {
/*
*class GVAR(sampleSetting) {
* Value
* value = 1;
*
* Type (SCALAR, BOOL, STRING, ARRAY, COLOR)
* typeName = "SCALAR";
*
* Force the setting?
* force = 0;
*
* Does it appear on the options menu?
* isClientSettable = 1;
*
* The following settings only apply when isClientSettable == 1
* Stringtable entry with the setting name
* displayName = "$STR_ACE_Common_SettingName";
*
* Stringtable entry with the setting description
* description = "$STR_ACE_Common_SettingDescription";
*
* Stringtable entries that describe the options
* Only applies if typeName == "SCALAR";
* values[] = {"Disabled", "Enabled", "Only Cursor", "Only On Keypress", "Only Cursor and KeyPress"};
*};
*/
class GVAR(forceAllSettings) {
value = 0;
typeName = "BOOL";
};
/*class GVAR(enableNumberHotkeys) {
value = 1;
typeName = "BOOL";
isClientSettable = 1;
displayName = "$STR_ACE_Common_EnableNumberHotkeys";
};*/
class GVAR(settingFeedbackIcons) {
value = 1;
typeName = "SCALAR";
force = 0;
isClientSettable = 1;
displayName = "$STR_ACE_Common_SettingFeedbackIconsName";
description = "$STR_ACE_Common_SettingFeedbackIconsDesc";
values[] = {"Hide", "Top right, downwards", "Top right, to the left", "Top left, downwards", "Top left, to the right"};
};
class GVAR(SettingProgressBarLocation) {
value = 0;
typeName = "SCALAR";
force = 0;
isClientSettable = 1;
displayName = "$STR_ACE_Common_SettingProgressbarLocationName";
description = "$STR_ACE_Common_SettingProgressbarLocationDesc";
values[] = {"Top", "Bottom"};
};
class GVAR(displayTextColor) {
value[] = {0,0,0,0.1};
typeName = "COLOR";
isClientSettable = 1;
displayName = "$STR_ACE_Common_SettingDisplayTextColorName";
description = "$STR_ACE_Common_SettingDisplayTextColorDesc";
};
class GVAR(displayTextFontColor) {
value[] = {1,1,1,1};
typeName = "COLOR";
isClientSettable = 1;
displayName = "$STR_ACE_Common_SettingDisplayTextFontColorName";
description = "$STR_ACE_Common_SettingDisplayTextFontColorDesc";
};
};
#include "define.hpp"
#include <ProgressScreen.hpp>
#include <HintConfig.hpp>
#include <RscInfoType.hpp>
class CfgUIGrids {
class IGUI {
class Presets {
class Arma3 {
class Variables {
grid_ACE_displayText[] = {{((safezoneX + safezoneW) - (10 *(((safezoneW / safezoneH) min 1.2) / 40)) - 2.9 *(((safezoneW / safezoneH) min 1.2) / 40)),safeZoneY + 0.175 * safezoneH, (10 *(((safezoneW / safezoneH) min 1.2) / 40)), (2 *((((safezoneW / safezoneH) min 1.2) / 1.2) / 25))}, "(((safezoneW / safezoneH) min 1.2) / 40)","((((safezoneW / safezoneH) min 1.2) / 1.2) / 25)"};
};
};
};
class Variables {
class grid_ACE_displayText {
displayName = "ACE Hint";
description = "Textual in game feedback to the player.";
preview = "\a3\Ui_f\data\GUI\Cfg\UIGrids\grid_hint_ca.paa";
saveToProfile[] = {0,1};
};
};
};
};
/*
// check dll
class RscStandardDisplay;
class RscDisplayMain: RscStandardDisplay {
onLoad = QUOTE([ARR_4(""onLoad"",_this,""RscDisplayMain"",'GUI')] call (uinamespace getvariable 'BIS_fnc_initDisplay'); [ARR_5('header','tail',{0},{},_this select 0)] call COMPILE_FILE(functions\fnc_errorMessage));
};
*/
class ACE_Extensions {
extensions[] = {};
};

View File

@ -3,7 +3,6 @@
ADDON = false; ADDON = false;
PREP(buttonPressed); PREP(buttonPressed);
PREP(calculateWindSpeed);
PREP(canShow); PREP(canShow);
PREP(collectData); PREP(collectData);
PREP(createKestrelDialog); PREP(createKestrelDialog);

View File

@ -1,68 +0,0 @@
/*
* Author: Ruthberg
*
* Calculates the wind speed at a given world position
*
* Arguments:
* 0: _this - world position <posASL>
*
* Return Value:
* 0: wind speed - m/s <NUMBER>
*
* Public: No
*/
#include "script_component.hpp"
private ["_windSpeed", "_windDir", "_newWindSpeed", "_windSource"];
fnc_polar2vect = {
private ["_mag2D"];
_mag2D = (_this select 0) * cos((_this select 2));
[_mag2D * sin((_this select 1)), _mag2D * cos((_this select 1)), (_this select 0) * sin((_this select 2))];
};
_windSpeed = vectorMagnitude ACE_wind;
_windDir = (ACE_wind select 0) atan2 (ACE_wind select 1);
// Terrain effect on wind
if (_windSpeed > 0.05) then {
_newWindSpeed = 0;
{
_windSource = [100, _windDir + 180, _x] call fnc_polar2vect;
if (!(terrainIntersectASL [_this, _this vectorAdd _windSource])) exitWith {
_newWindSpeed = cos(_x * 9) * _windSpeed;
};
_windSource = [100, _windDir + 180 + _x, 0] call fnc_polar2vect;
if (!(terrainIntersectASL [_this, _this vectorAdd _windSource])) exitWith {
_newWindSpeed = cos(_x * 9) * _windSpeed;
};
_windSource = [100, _windDir + 180 - _x, 0] call fnc_polar2vect;
if (!(terrainIntersectASL [_this, _this vectorAdd _windSource])) exitWith {
_newWindSpeed = cos(_x * 9) * _windSpeed;
};
} forEach [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
_windSpeed = _newWindSpeed;
};
// Obstacle effect on wind
if (_windSpeed > 0.05) then {
_newWindSpeed = 0;
{
_windSource = [20, _windDir + 180, _x] call fnc_polar2vect;
if (!(lineIntersects [_this, _this vectorAdd _windSource])) exitWith {
_newWindSpeed = cos(_x * 2) * _windSpeed;
};
_windSource = [20, _windDir + 180 + _x, 0] call fnc_polar2vect;
if (!(lineIntersects [_this, _this vectorAdd _windSource])) exitWith {
_newWindSpeed = cos(_x * 2) * _windSpeed;
};
_windSource = [20, _windDir + 180 - _x, 0] call fnc_polar2vect;
if (!(lineIntersects [_this, _this vectorAdd _windSource])) exitWith {
_newWindSpeed = cos(_x * 2) * _windSpeed;
};
} forEach [0, 5, 10, 15, 20, 25, 30, 35, 40, 45];
_windSpeed = _newWindSpeed;
};
_windSpeed = 0 max _windSpeed;
_windSpeed

View File

@ -19,12 +19,13 @@ private ["_playerDir", "_windSpeed", "_windDir"];
_playerDir = getDir ACE_player; _playerDir = getDir ACE_player;
_windSpeed = vectorMagnitude ACE_wind; _windSpeed = vectorMagnitude ACE_wind;
_windDir = (ACE_wind select 0) atan2 (ACE_wind select 1); _windDir = (ACE_wind select 0) atan2 (ACE_wind select 1);
if (missionNamespace getVariable [QEGVAR(advanced_ballistics,enabled), false]) then { if (missionNamespace getVariable [QEGVAR(advanced_ballistics,enabled), false]) then {
_windSpeed = (eyePos ACE_player) call EFUNC(advanced_ballistics,calculateWindSpeed); // With wind gradient
_windSpeed = [eyePos ACE_player, true, true, true] call EFUNC(weather,calculateWindSpeed);
_windSpeed = abs(cos(_playerDir - _windDir)) * _windSpeed; _windSpeed = abs(cos(_playerDir - _windDir)) * _windSpeed;
} else { } else {
_windSpeed = (eyePos ACE_player) call FUNC(calculateWindSpeed); // Without wind gradient
_windSpeed = [eyePos ACE_player, false, true, true] call EFUNC(weather,calculateWindSpeed);
}; };
if (_windSpeed > 0.3 || {GVAR(MeasuredWindSpeed) > 0.1 && _windSpeed > 0.125}) then { if (_windSpeed > 0.3 || {GVAR(MeasuredWindSpeed) > 0.1 && _windSpeed > 0.125}) then {

View File

@ -5,6 +5,8 @@ ADDON = false;
PREP(calculateAirDensity); PREP(calculateAirDensity);
PREP(calculateBarometricPressure); PREP(calculateBarometricPressure);
PREP(calculateRoughnessLength);
PREP(calculateWindSpeed);
PREP(displayWindInfo); PREP(displayWindInfo);
PREP(getMapData); PREP(getMapData);
PREP(getWind); PREP(getWind);

View File

@ -5,8 +5,8 @@ class CfgPatches {
units[] = {}; units[] = {};
weapons[] = {}; weapons[] = {};
requiredVersion = REQUIRED_VERSION; requiredVersion = REQUIRED_VERSION;
requiredAddons[] = {"ace_common"}; requiredAddons[] = {"ace_common", "ace_modules"};
author[] = {"q1184", "Rocko", "esteldunedain","Ruthberg"}; author[] = {"q1184", "Rocko", "esteldunedain", "Ruthberg"};
VERSION_CONFIG; VERSION_CONFIG;
}; };
}; };

View File

@ -0,0 +1,90 @@
/*
* Author: Ruthberg
*
* Calculates the true wind speed at a given world position
*
* Arguments:
* 0: world position - posASL <POSTION>
* 1: Account for wind gradient <BOOL>
* 2: Account for terrain <BOOL>
* 3: Account for obstacles <BOOL>
*
* Return Value:
* 0: wind speed - m/s <NUMBER>
*
* Public: No
*/
#include "script_component.hpp"
private ["_windSpeed", "_windDir", "_height", "_newWindSpeed", "_windSource", "_roughnessLength"];
EXPLODE_4_PVT(_this,_position,_windGradientEnabled,_terrainEffectEnabled,_obstacleEffectEnabled);
fnc_polar2vect = {
private ["_mag2D"];
_mag2D = (_this select 0) * cos((_this select 2));
[_mag2D * sin((_this select 1)), _mag2D * cos((_this select 1)), (_this select 0) * sin((_this select 2))];
};
_windSpeed = vectorMagnitude ACE_wind;
_windDir = (ACE_wind select 0) atan2 (ACE_wind select 1);
// Wind gradient
if (_windGradientEnabled) then {
if (_windSpeed > 0.05) then {
_height = (ASLToATL _position) select 2;
_height = 0 max _height min 20;
if (_height < 20) then {
_roughnessLength = _position call FUNC(calculateRoughnessLength);
_windSpeed = _windSpeed * abs(ln(_height / _roughnessLength) / ln(20 / _roughnessLength));
};
};
};
// Terrain effect on wind
if (_terrainEffectEnabled) then {
if (_windSpeed > 0.05) then {
_newWindSpeed = 0;
{
_windSource = [100, _windDir + 180, _x] call fnc_polar2vect;
if (!(terrainIntersectASL [_position, _position vectorAdd _windSource])) exitWith {
_newWindSpeed = cos(_x * 9) * _windSpeed;
};
_windSource = [100, _windDir + 180 + _x, 0] call fnc_polar2vect;
if (!(terrainIntersectASL [_position, _position vectorAdd _windSource])) exitWith {
_newWindSpeed = cos(_x * 9) * _windSpeed;
};
_windSource = [100, _windDir + 180 - _x, 0] call fnc_polar2vect;
if (!(terrainIntersectASL [_position, _position vectorAdd _windSource])) exitWith {
_newWindSpeed = cos(_x * 9) * _windSpeed;
};
} forEach [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
_windSpeed = _newWindSpeed;
};
};
// Obstacle effect on wind
if (_obstacleEffectEnabled) then {
if (_windSpeed > 0.05) then {
_newWindSpeed = 0;
{
_windSource = [20, _windDir + 180, _x] call fnc_polar2vect;
if (!(lineIntersects [_position, _position vectorAdd _windSource])) exitWith {
_newWindSpeed = cos(_x * 2) * _windSpeed;
};
_windSource = [20, _windDir + 180 + _x, 0] call fnc_polar2vect;
if (!(lineIntersects [_position, _position vectorAdd _windSource])) exitWith {
_newWindSpeed = cos(_x * 2) * _windSpeed;
};
_windSource = [20, _windDir + 180 - _x, 0] call fnc_polar2vect;
if (!(lineIntersects [_position, _position vectorAdd _windSource])) exitWith {
_newWindSpeed = cos(_x * 2) * _windSpeed;
};
} forEach [0, 5, 10, 15, 20, 25, 30, 35, 40, 45];
_windSpeed = _newWindSpeed;
};
};
_windSpeed = 0 max _windSpeed;
_windSpeed

View File

@ -38,15 +38,14 @@ GVAR(WindInfo) = true;
_windIndex = 12; _windIndex = 12;
_windColor = [1, 1, 1, 1]; _windColor = [1, 1, 1, 1];
_windSpeed = if (missionNamespace getVariable [QEGVAR(advanced_ballistics,enabled), false]) then {
// Toogle behaviour depending on ace_advanced_ballistics being used or not // With wind gradient
// @todo, check ACE_AB is actually enabled [eyePos ACE_player, true, true, true] call FUNC(calculateWindSpeed);
_windSpeed = if (isClass (configFile >> "CfgPatches" >> "ACE_Advanced_Ballistics")) then {
(eyePos ACE_player) call EFUNC(advanced_ballistics,calculateWindSpeed);
} else { } else {
vectorMagnitude ACE_wind; // Without wind gradient
[eyePos ACE_player, false, true, true] call FUNC(calculateWindSpeed);
}; };
if (_windSpeed > 0.2) then { if (_windSpeed > 0.2) then {
_playerDir = getDir ACE_player; _playerDir = getDir ACE_player;
_windDir = (ACE_wind select 0) atan2 (ACE_wind select 1); _windDir = (ACE_wind select 0) atan2 (ACE_wind select 1);