]> git.tdb.fi Git - r2c2.git/commitdiff
Improve train color selection to always choose saturated colors
authorMikko Rasa <tdb@tdb.fi>
Tue, 12 Feb 2013 12:33:56 +0000 (14:33 +0200)
committerMikko Rasa <tdb@tdb.fi>
Tue, 12 Feb 2013 12:37:59 +0000 (14:37 +0200)
source/engineer/engineer.cpp

index ba92933430ee013690ae1164b7da977c644cd640..e1268c63f25323f55a9b002589989a419a3c573a 100644 (file)
@@ -417,9 +417,10 @@ void Engineer::train_added(Train &train)
        for(unsigned i=0; i<10; ++i)
        {
                GL::Color color;
-               color.r = rand()*1.0/RAND_MAX;
-               color.g = rand()*1.0/RAND_MAX;
-               color.b = rand()*1.0/RAND_MAX;
+               unsigned h = rand()%3;
+               color.r = (h==0 ? 0.0 : rand()*1.0/RAND_MAX);
+               color.g = (h==1 ? 0.0 : rand()*1.0/RAND_MAX);
+               color.b = (h==2 ? 0.0 : rand()*1.0/RAND_MAX);
                color = color*(1/max(max(color.r, color.g), color.b));
                float min_d_sq = 3;
                for(map<Train *, GL::Color>::const_iterator j=train_colors.begin(); j!=train_colors.end(); ++j)