From 527f6a4a97af0f5bbe6e1edbd31a6501e5aa774f Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Tue, 12 Feb 2013 14:33:56 +0200 Subject: [PATCH] Improve train color selection to always choose saturated colors --- source/engineer/engineer.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/source/engineer/engineer.cpp b/source/engineer/engineer.cpp index ba92933..e1268c6 100644 --- a/source/engineer/engineer.cpp +++ b/source/engineer/engineer.cpp @@ -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::const_iterator j=train_colors.begin(); j!=train_colors.end(); ++j) -- 2.43.0