1
0
Fork 0

Patch from Nicolas Vivien : don't pour rain above cloud layers, turn rain into snow when temperature is below 0C

This commit is contained in:
fredb 2008-11-02 09:45:31 +00:00
parent 692afe0bcb
commit 0fbf965b39

View file

@ -36,6 +36,7 @@
#include <simgear/math/SGMath.hxx> #include <simgear/math/SGMath.hxx>
#include <simgear/scene/sky/sky.hxx> #include <simgear/scene/sky/sky.hxx>
#include <simgear/scene/sky/cloud.hxx> #include <simgear/scene/sky/cloud.hxx>
#include <simgear/environment/visual_enviro.hxx>
#include <Main/fg_props.hxx> #include <Main/fg_props.hxx>
#include <Main/globals.hxx> #include <Main/globals.hxx>
@ -116,7 +117,9 @@ float FGPrecipitationMgr::getPrecipitationAtAltitudeMax(void)
{ {
int i; int i;
int max; int max;
double elev;
float result; float result;
SGPropertyNode *boundaryNode, *boundaryEntry;
// By default (not cloud layer) // By default (not cloud layer)
@ -148,6 +151,32 @@ float FGPrecipitationMgr::getPrecipitationAtAltitudeMax(void)
} }
} }
// If we haven't found clouds layers, we read the bounday layers table.
if (result > 0)
return result;
// Read boundary layers node
boundaryNode = fgGetNode("/environment/config/boundary");
if (boundaryNode != NULL) {
i = 0;
// For each boundary layers
while ( ( boundaryEntry = boundaryNode->getNode( "entry", i ) ) != NULL ) {
elev = boundaryEntry->getDoubleValue( "elevation-ft" );
if (elev > result)
result = elev;
++i;
}
}
// Convert the result in meter
result = result * SG_FEET_TO_METER;
return result; return result;
} }
@ -155,6 +184,10 @@ float FGPrecipitationMgr::getPrecipitationAtAltitudeMax(void)
/** /**
* @brief Update the precipitation drawing * @brief Update the precipitation drawing
* *
* To seem real, we stop the precipitation above the cloud or boundary layer.
* If METAR information doesn't give us this altitude, we will see precipitations
* in space...
* Moreover, below 0°C we change rain into snow.
*/ */
void FGPrecipitationMgr::update(double dt) void FGPrecipitationMgr::update(double dt)
{ {
@ -166,11 +199,24 @@ void FGPrecipitationMgr::update(double dt)
float altitudeAircraft; float altitudeAircraft;
float altitudeCloudLayer; float altitudeCloudLayer;
// Does the user enable the precipitation ?
if (!sgEnviro.get_precipitation_enable_state()) {
// Disable precipitations
precipitation->setRainIntensity(0);
precipitation->setSnowIntensity(0);
// Update the drawing...
precipitation->update();
// Exit
return;
}
// Get the elevation of aicraft and of the cloud layer // Get the elevation of aicraft and of the cloud layer
altitudeAircraft = fgGetDouble("/position/altitude-ft", 0.0); altitudeAircraft = fgGetDouble("/position/altitude-ft", 0.0);
altitudeCloudLayer = this->getPrecipitationAtAltitudeMax() * SG_METER_TO_FEET; altitudeCloudLayer = this->getPrecipitationAtAltitudeMax() * SG_METER_TO_FEET;
if (altitudeAircraft > altitudeCloudLayer) { if ((altitudeCloudLayer > 0) && (altitudeAircraft > altitudeCloudLayer)) {
// The aircraft is above the cloud layer // The aircraft is above the cloud layer
rain_intensity = 0; rain_intensity = 0;
snow_intensity = 0; snow_intensity = 0;