More turbulence tweaks and fixes.
Skip turbulence calculations with magnitude is 0.
This commit is contained in:
parent
5d3b58438a
commit
b8a8d2194a
4 changed files with 13 additions and 7 deletions
|
@ -169,7 +169,8 @@ maybe_copy_value (FGEnvironment * env, const SGPropertyNode * node,
|
|||
const SGPropertyNode * child = node->getNode(name);
|
||||
// fragile: depends on not being typed
|
||||
// as a number
|
||||
if (child != 0 && child->getStringValue()[0] != '\0') {
|
||||
if (child != 0 && child->hasValue() &&
|
||||
child->getStringValue()[0] != '\0') {
|
||||
(env->*setter)(child->getDoubleValue());
|
||||
return true;
|
||||
} else {
|
||||
|
|
|
@ -110,10 +110,10 @@ FGEnvironmentMgr::bind ()
|
|||
&FGEnvironment::get_turbulence_magnitude_norm,
|
||||
&FGEnvironment::set_turbulence_magnitude_norm);
|
||||
fgSetArchivable("/environment/turbulence/magnitude-norm");
|
||||
fgTie("/environment/turbulence/rate_hz", _environment,
|
||||
fgTie("/environment/turbulence/rate-hz", _environment,
|
||||
&FGEnvironment::get_turbulence_rate_hz,
|
||||
&FGEnvironment::set_turbulence_rate_hz);
|
||||
fgSetArchivable("/environment/turbulence/rate_hz");
|
||||
fgSetArchivable("/environment/turbulence/rate-hz");
|
||||
|
||||
for (int i = 0; i < MAX_CLOUD_LAYERS; i++) {
|
||||
char buf[128];
|
||||
|
|
|
@ -93,7 +93,7 @@ FGAtmosphere::FGAtmosphere(FGFDMExec* fdmex) : FGModel(fdmex)
|
|||
// turbType = ttBerndt;
|
||||
TurbGain = 0.0;
|
||||
TurbRate = 1.0;
|
||||
|
||||
|
||||
bind();
|
||||
Debug(0);
|
||||
}
|
||||
|
@ -141,7 +141,7 @@ bool FGAtmosphere::Run(void)
|
|||
Calculate(h);
|
||||
}
|
||||
|
||||
if (turbType != ttNone) {
|
||||
if (turbType != ttNone && TurbGain > 0.0) {
|
||||
Turbulence();
|
||||
vWindNED += vTurbulence;
|
||||
}
|
||||
|
@ -278,7 +278,7 @@ void FGAtmosphere::Turbulence(void)
|
|||
vDirectiondAccelDt(eY) = 1 - 2.0*(double(rand())/double(RAND_MAX));
|
||||
vDirectiondAccelDt(eZ) = 1 - 2.0*(double(rand())/double(RAND_MAX));
|
||||
|
||||
MagnitudedAccelDt = 1 - 2.0*(double(rand())/double(RAND_MAX)) - Magnitude;
|
||||
MagnitudedAccelDt = 1 - 2.0*(double(rand())/double(RAND_MAX));
|
||||
// Scale the magnitude so that it moves
|
||||
// away from the peaks
|
||||
MagnitudedAccelDt = ((MagnitudedAccelDt - Magnitude) /
|
||||
|
|
|
@ -224,6 +224,8 @@ void FGJSBsim::init() {
|
|||
Atmosphere->SetTurbGain(tmp * tmp * 100.0);
|
||||
|
||||
tmp = turbulence_rate->getDoubleValue();
|
||||
if (tmp <= 0)
|
||||
tmp = 1.0;
|
||||
Atmosphere->SetTurbRate(tmp);
|
||||
|
||||
} else {
|
||||
|
@ -424,7 +426,10 @@ bool FGJSBsim::copy_to_JSBsim() {
|
|||
tmp = turbulence_gain->getDoubleValue();
|
||||
Atmosphere->SetTurbGain(tmp * tmp * 100.0);
|
||||
|
||||
tmp = turbulence_rate->getDoubleValue();
|
||||
if (turbulence_rate->hasValue())
|
||||
tmp = turbulence_rate->getDoubleValue();
|
||||
else
|
||||
tmp = 1.0;
|
||||
Atmosphere->SetTurbRate(tmp);
|
||||
|
||||
Atmosphere->SetWindNED( wind_from_north->getDoubleValue(),
|
||||
|
|
Loading…
Reference in a new issue