From 3bd810fedc3aea68628377a678426d0f4a5a849b Mon Sep 17 00:00:00 2001 From: ehofman Date: Sat, 30 Apr 2005 10:00:16 +0000 Subject: [PATCH] Make use of the repeatable sg_random() function so display systems can synchronize 3d clouds too. --- simgear/scene/sky/cloudfield.cxx | 4 +++- simgear/scene/sky/newcloud.cxx | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) 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 -- 2.39.5