From: ehofman Date: Sat, 30 Apr 2005 10:00:16 +0000 (+0000) Subject: Make use of the repeatable sg_random() function so display systems can synchronize... X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=3bd810fedc3aea68628377a678426d0f4a5a849b;p=simgear.git Make use of the repeatable sg_random() function so display systems can synchronize 3d clouds too. --- diff --git a/simgear/scene/sky/cloudfield.cxx b/simgear/scene/sky/cloudfield.cxx index bdd64aa3..af0abc33 100644 --- a/simgear/scene/sky/cloudfield.cxx +++ b/simgear/scene/sky/cloudfield.cxx @@ -28,6 +28,7 @@ #include #include +#include #include #include @@ -193,6 +194,7 @@ SGCloudField::SGCloudField() : sgSetVec3( relative_position, 0,0,0); theField.reserve(200); inViewClouds.reserve(200); + sg_srandom_time_10(); } SGCloudField::~SGCloudField() { @@ -247,7 +249,7 @@ void SGCloudField::addCloud( sgVec3 pos, SGNewCloud *cloud) { static float Rnd(float n) { - return n * (-0.5f + rand() / (float) RAND_MAX); + return n * (-0.5f + sg_random()); } // for debug only diff --git a/simgear/scene/sky/newcloud.cxx b/simgear/scene/sky/newcloud.cxx index 917d8065..3053606a 100644 --- a/simgear/scene/sky/newcloud.cxx +++ b/simgear/scene/sky/newcloud.cxx @@ -28,6 +28,7 @@ #include #include +#include #include #include STL_ALGORITHM @@ -240,7 +241,7 @@ void SGNewCloud::addSprite(float x, float y, float z, float r, CLbox_type type, // return a random number between -n/2 and n/2 static float Rnd(float n) { - return n * (-0.5f + rand() / (float) RAND_MAX); + return n * (-0.5f + sg_random()); } // generate all sprite with defined boxes