Make use of the repeatable sg_random() function so display systems can synchronize 3d clouds too.
This commit is contained in:
@@ -28,6 +28,7 @@
|
|||||||
|
|
||||||
#include <plib/sg.h>
|
#include <plib/sg.h>
|
||||||
#include <plib/ssg.h>
|
#include <plib/ssg.h>
|
||||||
|
#include <simgear/math/sg_random.h>
|
||||||
#include <simgear/math/sg_geodesy.hxx>
|
#include <simgear/math/sg_geodesy.hxx>
|
||||||
#include <simgear/math/polar3d.hxx>
|
#include <simgear/math/polar3d.hxx>
|
||||||
|
|
||||||
@@ -193,6 +194,7 @@ SGCloudField::SGCloudField() :
|
|||||||
sgSetVec3( relative_position, 0,0,0);
|
sgSetVec3( relative_position, 0,0,0);
|
||||||
theField.reserve(200);
|
theField.reserve(200);
|
||||||
inViewClouds.reserve(200);
|
inViewClouds.reserve(200);
|
||||||
|
sg_srandom_time_10();
|
||||||
}
|
}
|
||||||
|
|
||||||
SGCloudField::~SGCloudField() {
|
SGCloudField::~SGCloudField() {
|
||||||
@@ -247,7 +249,7 @@ void SGCloudField::addCloud( sgVec3 pos, SGNewCloud *cloud) {
|
|||||||
|
|
||||||
|
|
||||||
static float Rnd(float n) {
|
static float Rnd(float n) {
|
||||||
return n * (-0.5f + rand() / (float) RAND_MAX);
|
return n * (-0.5f + sg_random());
|
||||||
}
|
}
|
||||||
|
|
||||||
// for debug only
|
// for debug only
|
||||||
|
|||||||
@@ -28,6 +28,7 @@
|
|||||||
|
|
||||||
#include <plib/sg.h>
|
#include <plib/sg.h>
|
||||||
#include <plib/ssg.h>
|
#include <plib/ssg.h>
|
||||||
|
#include <simgear/math/sg_random.h>
|
||||||
#include <simgear/misc/sg_path.hxx>
|
#include <simgear/misc/sg_path.hxx>
|
||||||
|
|
||||||
#include STL_ALGORITHM
|
#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
|
// return a random number between -n/2 and n/2
|
||||||
static float Rnd(float n) {
|
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
|
// generate all sprite with defined boxes
|
||||||
|
|||||||
Reference in New Issue
Block a user