From 0fbf965b398083913567f55368d9e4cc3cce6f80 Mon Sep 17 00:00:00 2001 From: fredb Date: Sun, 2 Nov 2008 09:45:31 +0000 Subject: [PATCH] =?UTF-8?q?Patch=20from=20Nicolas=20Vivien=20:=20don't=20p?= =?UTF-8?q?our=20rain=20above=20cloud=20layers,=20turn=20rain=20into=20sno?= =?UTF-8?q?w=20when=20temperature=20is=20below=200=B0C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Environment/precipitation_mgr.cxx | 48 ++++++++++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) diff --git a/src/Environment/precipitation_mgr.cxx b/src/Environment/precipitation_mgr.cxx index d6b802d66..7d97674a1 100644 --- a/src/Environment/precipitation_mgr.cxx +++ b/src/Environment/precipitation_mgr.cxx @@ -36,6 +36,7 @@ #include #include #include +#include #include
#include
@@ -116,7 +117,9 @@ float FGPrecipitationMgr::getPrecipitationAtAltitudeMax(void) { int i; int max; + double elev; float result; + SGPropertyNode *boundaryNode, *boundaryEntry; // 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; } @@ -155,6 +184,10 @@ float FGPrecipitationMgr::getPrecipitationAtAltitudeMax(void) /** * @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) { @@ -166,11 +199,24 @@ void FGPrecipitationMgr::update(double dt) float altitudeAircraft; 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 altitudeAircraft = fgGetDouble("/position/altitude-ft", 0.0); altitudeCloudLayer = this->getPrecipitationAtAltitudeMax() * SG_METER_TO_FEET; - if (altitudeAircraft > altitudeCloudLayer) { + if ((altitudeCloudLayer > 0) && (altitudeAircraft > altitudeCloudLayer)) { // The aircraft is above the cloud layer rain_intensity = 0; snow_intensity = 0;