]> git.mxchange.org Git - simgear.git/commitdiff
Vassilii Khachaturov:
authorehofman <ehofman>
Thu, 2 Feb 2006 09:56:48 +0000 (09:56 +0000)
committerehofman <ehofman>
Thu, 2 Feb 2006 09:56:48 +0000 (09:56 +0000)
Fix the current buggy rain orientation behaviour for the views attached to the
aircraft (while still inheriting bugs with the views attached to anything else).

simgear/environment/visual_enviro.cxx

index 6ea17f80540e8388b42bb6307cfd13783c8e589e..72a0fba43ee3a47c5985cfa91d527e72c9054031 100644 (file)
@@ -424,17 +424,23 @@ void SGEnviro::drawRain(double pitch, double roll, double heading, double speed,
        int slice_count = static_cast<int>(
                                (40.0 + rain_norm*150.0)* precipitation_density / 100.0);
 
-       float angle = speed;
-       if( angle > 90.0 )
-               angle = 90.0;
-
+       // www.wonderquest.com/falling-raindrops.htm says that
+       // Raindrop terminal velocity is 5 to 20mph
+       // Rather than model it accurately (temp, pressure, diameter), and make it
+       // smaller than terminal when closer to the precipitation cloud base,
+       // we interpolate in the 5-20mph range according to rain_norm.
+       double raindrop_speed_kts 
+               = (5.0 + rain_norm*15.0) * SG_MPH_TO_MPS * SG_MPS_TO_KT;
+
+       float angle = atanf(speed / raindrop_speed_kts) * SG_RADIANS_TO_DEGREES;
+       // We assume that the speed is HORIZONTAL airspeed here!!! XXX
+       // DOCUMENT THE CHANGE IN THE PARAMETER speed MEANING BY RENAMING IT!!!
        glPushMatrix();
-               // TODO:find the real view orientation, not the AC one
                // the cone rotate with speed
                angle = -pitch - angle;
+               glRotatef(heading, 0.0, 1.0, 0.0);
+               glRotatef(roll, 0.0, 0.0, 1.0);
                glRotatef(angle, 1.0, 0.0, 0.0);
-               glRotatef(roll, 0.0, 1.0, 0.0);
-               glRotatef(heading, 0.0, 0.0, 1.0);
 
                // up cone
                DrawCone2(15.0, 30.0, slice_count, true, rain_norm, speed);