]> git.mxchange.org Git - flightgear.git/commitdiff
More night ground lighting tweaks.
authorcurt <curt>
Wed, 6 Dec 2000 22:16:12 +0000 (22:16 +0000)
committercurt <curt>
Wed, 6 Dec 2000 22:16:12 +0000 (22:16 +0000)
src/Main/main.cxx
src/Objects/obj.cxx
src/Scenery/newcache.cxx
src/Scenery/tileentry.cxx

index 2af616382fe5c07b671602dac16c8762dd502401..69c89b42deb0dbd0cc346b82046acd73abe36848 100644 (file)
@@ -1363,7 +1363,7 @@ int main( int argc, char **argv ) {
            << FLIGHTGEAR_VERSION << endl );
 
     // seed the random number generater
-    sg_srandom();
+    sg_srandom_time();
 
     // Allocate global data structures.  This needs to happen before
     // we parse command line options
index 001c55fb67431c94310771554ec0b15e762a418e..25e420b8cb1eb000ac4223c67860bb49708781d2 100644 (file)
@@ -337,32 +337,39 @@ static void random_pt_inside_tri( float *res,
 static void gen_random_surface_points( ssgLeaf *leaf, ssgVertexArray *lights,
                                       double factor ) {
     int num = leaf->getNumTriangles();
-    short int n1, n2, n3;
-    float *p1, *p2, *p3;
-    sgVec3 result;
-
-    for ( int i = 0; i < num; ++i ) {
-       leaf->getTriangle( i, &n1, &n2, &n3 );
-       p1 = leaf->getVertex(n1);
-       p2 = leaf->getVertex(n2);
-       p3 = leaf->getVertex(n3);
-       double area = sgTriArea( p1, p2, p3 );
-       double num = area / factor;
-
-       // generate a light point for each unit of area
-       while ( num > 1.0 ) {
-           random_pt_inside_tri( result, p1, p2, p3 );
-           lights->add( result );
-           num -= 1.0;
-       }
-       // for partial units of area, use a zombie door method to
-       // create the proper random chance of a light being created
-       // for this triangle
-       if ( num > 0.0 ) {
-           if ( sg_random() <= num ) {
-               // a zombie made it through our door
+    if ( num > 0 ) {
+       short int n1, n2, n3;
+       float *p1, *p2, *p3;
+       sgVec3 result;
+
+       // generate a repeatable random seed
+       p1 = leaf->getVertex( 0 );
+       unsigned int *seed = (unsigned int *)p1;
+       sg_srandom( *seed );
+
+       for ( int i = 0; i < num; ++i ) {
+           leaf->getTriangle( i, &n1, &n2, &n3 );
+           p1 = leaf->getVertex(n1);
+           p2 = leaf->getVertex(n2);
+           p3 = leaf->getVertex(n3);
+           double area = sgTriArea( p1, p2, p3 );
+           double num = area / factor;
+
+           // generate a light point for each unit of area
+           while ( num > 1.0 ) {
                random_pt_inside_tri( result, p1, p2, p3 );
                lights->add( result );
+               num -= 1.0;
+           }
+           // for partial units of area, use a zombie door method to
+           // create the proper random chance of a light being created
+           // for this triangle
+           if ( num > 0.0 ) {
+               if ( sg_random() <= num ) {
+                   // a zombie made it through our door
+                   random_pt_inside_tri( result, p1, p2, p3 );
+                   lights->add( result );
+               }
            }
        }
     }
index 8ec1e841a08172939e2b67f80fb8020062443efe..1fe5307c51d2deefabf6f2e8bc8e646dd9df1e06 100644 (file)
@@ -134,6 +134,11 @@ static void print_refs( ssgSelector *sel, ssgTransform *trans,
 
 
 static ssgLeaf *gen_lights( ssgVertexArray *lights, int inc, float bright ) {
+    // generate a repeatable random seed
+    float *p1 = lights->get( 0 );
+    unsigned int *seed = (unsigned int *)p1;
+    sg_srandom( *seed );
+
     int size = lights->getNum() / inc;
 
     // Allocate ssg structure
@@ -143,25 +148,31 @@ static ssgLeaf *gen_lights( ssgVertexArray *lights, int inc, float bright ) {
     ssgColourArray   *cl = new ssgColourArray( size + 1 );
 
     sgVec4 color;
-    for ( int i = 0; i < lights->getNum(); i += inc ) {
-       vl->add( lights->get(i) );
-
-       // yellow = 1,1,0
+    for ( int i = 0; i < lights->getNum(); ++i ) {
+       // this loop is slightly less efficient than it otherwise
+       // could be, but we want a red light to always be red, and a
+       // yellow light to always be yellow, etc. so we are trying to
+       // preserve the random sequence.
        float zombie = sg_random();
-       if ( zombie > 0.5 ) {
-           // 50% chance of yellowish
-           sgSetVec4( color, 0.9, 0.9, 0.3, bright );
-       } else if ( zombie > 0.15 ) {
-           // 35% chance of whitish
-           sgSetVec4( color, 0.9, 0.9, 0.6, bright );
-       } else if ( zombie > 0.05 ) {
-           // 10% chance of orangish
-           sgSetVec4( color, 0.9, 0.6, 0.2, bright );
-       } else {
-           // 5% chance of redish
-           sgSetVec4( color, 0.9, 0.2, 0.2, bright );
+       if ( i % inc == 0 ) {
+           vl->add( lights->get(i) );
+
+           // yellow = 1,1,0
+           if ( zombie > 0.5 ) {
+               // 50% chance of yellowish
+               sgSetVec4( color, 0.9, 0.9, 0.3, bright );
+           } else if ( zombie > 0.15 ) {
+               // 35% chance of whitish
+               sgSetVec4( color, 0.9, 0.9, 0.8, bright );
+           } else if ( zombie > 0.05 ) {
+               // 10% chance of orangish
+               sgSetVec4( color, 0.9, 0.6, 0.2, bright );
+           } else {
+               // 5% chance of redish
+               sgSetVec4( color, 0.9, 0.2, 0.2, bright );
+           }
+           cl->add( color );
        }
-       cl->add( color );
     }
 
     // create ssg leaf
index c1cc514703fd7c2c8a780ecb0a5282b8e251cae1..5370d7858c1681ac8213302ba5621b6df75fa30c 100644 (file)
@@ -218,9 +218,9 @@ void FGTileEntry::prep_ssg_node( const Point3D& p, float vis) {
 
        // select which set of lights based on sun angle
        float sun_angle = cur_light_params.sun_angle * RAD_TO_DEG;
-       if ( sun_angle > 98 ) {
+       if ( sun_angle > 95 ) {
            lights_brightness->select(0x04);
-       } else if ( sun_angle > 93.5 ) {
+       } else if ( sun_angle > 92 ) {
            lights_brightness->select(0x02);
        } else if ( sun_angle > 89 ) {
            lights_brightness->select(0x01);