From 06e8fe747fb1733528aa1e01bc6bd285a53ec127 Mon Sep 17 00:00:00 2001 From: Torsten Dreyer Date: Tue, 21 Oct 2014 10:44:55 +0200 Subject: [PATCH] Precipitation updates from ThorstenR required SimGear commit 75271c44a82ae0fb1ff9c91e93a12fa8b10099fd Since the consensus seems to be that the precipitation clipping issue is with the panel code, attached is my proposed update for the precipitation system in SG and FG * without corresponding control structures in FGData it falls back to default, except I have fixed an inconsistency in freezing behavior - previously rain changed suddenly to snow when the temperature dropped below zero, but the reverse transition was dragged out and gave odd visible motion with the wind as snow gradually changed back to rain with the particle speed not well defined. Now both transitions are sudden. And I see no more particles flow against the wind * with 0.015 0.03 false 1.0 5.0 added to Environment/environment.xml, the new system allows to switch more detailed management on. This provides * explicit setting of rain droplet size and snow flake size by the weather system * automatic sqrt(r) scaling of the vertical speed of raindrops * automatic transition to snow when freezing for small droplets but hail for large droplet sizes (looks like snow, but has different particle dynamics) * an illumination scaling factor to dim the precipitating based on the light we have in the scene (I still need to devise a property rule to set this automatically) The clip distance is also exposed now and considered at startup of the system - might be useful for e.g. airships when the gas bag provides rain cover (?) or to be simply off for open airplanes --- src/Environment/precipitation_mgr.cxx | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/Environment/precipitation_mgr.cxx b/src/Environment/precipitation_mgr.cxx index dcb74c660..9e83ab852 100644 --- a/src/Environment/precipitation_mgr.cxx +++ b/src/Environment/precipitation_mgr.cxx @@ -59,6 +59,9 @@ FGPrecipitationMgr::FGPrecipitationMgr() // By default, no precipitation precipitation->setRainIntensity(0); precipitation->setSnowIntensity(0); + + // set the clip distance from the config + precipitation->setClipDistance(fgGetFloat("/environment/precipitation-control/clip-distance",5.0)); transform->addChild(precipitation->build()); group->addChild(transform.get()); } @@ -139,6 +142,7 @@ float FGPrecipitationMgr::getPrecipitationAtAltitudeMax(void) return fgGetFloat("/environment/params/external-precipitation-level-m", 0.0); } + // By default (not cloud layer) max = SGCloudLayer::SG_MAX_CLOUD_COVERAGES; result = 0; @@ -217,10 +221,15 @@ void FGPrecipitationMgr::update(double dt) float altitudeAircraft; float altitudeCloudLayer; + float rainDropletSize; + float snowFlakeSize; + float illumination; altitudeCloudLayer = this->getPrecipitationAtAltitudeMax() * SG_METER_TO_FEET; setPrecipitationLevel(altitudeCloudLayer); + + // Does the user enable the precipitation ? if (!precipitation->getEnabled() ) { // Disable precipitations @@ -234,6 +243,17 @@ void FGPrecipitationMgr::update(double dt) return; } + // See if external droplet size and illumination are used + if (fgGetBool("/environment/precipitation-control/detailed-precipitation", false)) { + precipitation->setDropletExternal(true); + rainDropletSize = fgGetFloat("/environment/precipitation-control/rain-droplet-size", 0.015); + snowFlakeSize = fgGetFloat("/environment/precipitation-control/snow-flake-size", 0.03); + illumination = fgGetFloat("/environment/precipitation-control/illumination", 1.0); + precipitation->setRainDropletSize(rainDropletSize); + precipitation->setSnowFlakeSize(snowFlakeSize); + precipitation->setIllumination(illumination); + } + // Get the elevation of aicraft and of the cloud layer altitudeAircraft = fgGetDouble("/position/altitude-ft", 0.0);