Make use of the repeatable sg_random() function so display systems can synchronize 3d clouds too.

This commit is contained in:
ehofman 2005-04-30 10:00:16 +00:00
parent f9cbf8361d
commit 3bd810fedc
2 changed files with 5 additions and 2 deletions

View File

@ -28,6 +28,7 @@
#include <plib/sg.h>
#include <plib/ssg.h>
#include <simgear/math/sg_random.h>
#include <simgear/math/sg_geodesy.hxx>
#include <simgear/math/polar3d.hxx>
@ -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

View File

@ -28,6 +28,7 @@
#include <plib/sg.h>
#include <plib/ssg.h>
#include <simgear/math/sg_random.h>
#include <simgear/misc/sg_path.hxx>
#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