1
0
Fork 0

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

 <!-- definitions for the detailed precipitation manager -->
 <precipitation-control>
     <rain-droplet-size type="float" userarchive="n">0.015</rain-droplet-size>
     <snow-flake-size type="float" userarchive="n">0.03</snow-flake-size>
     <detailed-precipitation type="bool" userarchive="n">false</detailed-precipitation>
     <illumination type="float" userarchive="n">1.0</illumination>
     <clip-distance type="float" userarchive="n">5.0</clip-distance>
  </precipitation-control>

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
This commit is contained in:
Torsten Dreyer 2014-10-21 10:44:55 +02:00
parent a30dadcf18
commit 06e8fe747f

View file

@ -59,6 +59,9 @@ FGPrecipitationMgr::FGPrecipitationMgr()
// By default, no precipitation // By default, no precipitation
precipitation->setRainIntensity(0); precipitation->setRainIntensity(0);
precipitation->setSnowIntensity(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()); transform->addChild(precipitation->build());
group->addChild(transform.get()); group->addChild(transform.get());
} }
@ -139,6 +142,7 @@ float FGPrecipitationMgr::getPrecipitationAtAltitudeMax(void)
return fgGetFloat("/environment/params/external-precipitation-level-m", 0.0); return fgGetFloat("/environment/params/external-precipitation-level-m", 0.0);
} }
// By default (not cloud layer) // By default (not cloud layer)
max = SGCloudLayer::SG_MAX_CLOUD_COVERAGES; max = SGCloudLayer::SG_MAX_CLOUD_COVERAGES;
result = 0; result = 0;
@ -217,10 +221,15 @@ void FGPrecipitationMgr::update(double dt)
float altitudeAircraft; float altitudeAircraft;
float altitudeCloudLayer; float altitudeCloudLayer;
float rainDropletSize;
float snowFlakeSize;
float illumination;
altitudeCloudLayer = this->getPrecipitationAtAltitudeMax() * SG_METER_TO_FEET; altitudeCloudLayer = this->getPrecipitationAtAltitudeMax() * SG_METER_TO_FEET;
setPrecipitationLevel(altitudeCloudLayer); setPrecipitationLevel(altitudeCloudLayer);
// Does the user enable the precipitation ? // Does the user enable the precipitation ?
if (!precipitation->getEnabled() ) { if (!precipitation->getEnabled() ) {
// Disable precipitations // Disable precipitations
@ -234,6 +243,17 @@ void FGPrecipitationMgr::update(double dt)
return; 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 // Get the elevation of aicraft and of the cloud layer
altitudeAircraft = fgGetDouble("/position/altitude-ft", 0.0); altitudeAircraft = fgGetDouble("/position/altitude-ft", 0.0);