From d86a51399776736d0c7069004d5ffe92e239660b Mon Sep 17 00:00:00 2001 From: david Date: Thu, 25 Jul 2002 20:30:51 +0000 Subject: [PATCH] Fix random seeds to avoid coincident objects but still ensure consistency. --- src/Objects/obj.cxx | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Objects/obj.cxx b/src/Objects/obj.cxx index bef13c199..905fdf204 100644 --- a/src/Objects/obj.cxx +++ b/src/Objects/obj.cxx @@ -417,6 +417,7 @@ public: ssgBranch * branch; double lon_deg; double lat_deg; + unsigned int seed; }; @@ -438,10 +439,10 @@ public: static void fill_in_triangle (float * p1, float * p2, float * p3, FGNewMat::ObjectGroup * object_group, ssgBranch * branch, - double lon_deg, double lat_deg) + double lon_deg, double lat_deg, unsigned int seed) { // generate a repeatable random seed - sg_srandom((unsigned int)(p1[0])); + sg_srandom(seed); int nObjects = object_group->get_object_count(); for (int i = 0; i < nObjects; i++) { @@ -491,7 +492,8 @@ tri_in_range_callback (ssgEntity * entity, int mask) TriUserData * data = (TriUserData *)entity->getUserData(); if (!data->is_filled_in) { fill_in_triangle(data->p1, data->p2, data->p3, data->object_group, - data->branch, data->lon_deg, data->lat_deg); + data->branch, data->lon_deg, data->lat_deg, + data->seed); data->is_filled_in = true; } return 1; @@ -658,6 +660,7 @@ setup_triangle (float * p1, float * p2, float * p3, data->branch = in_range; data->lon_deg = lon_deg; data->lat_deg = lat_deg; + data->seed = (unsigned int)(p1[0] * i); // Set up the in-range node. in_range->setUserData(data);