implement a round-robin scheme for random objects to make sure the same type of object is placed at the same spot all the time

This commit is contained in:
ehofman
2010-02-01 10:05:14 +00:00
committed by Tim Moore
parent f529ec3018
commit 68797e51c6

View File

@@ -139,8 +139,9 @@ SGMatModel::get_random_model( SGPropertyNode *prop_root )
{
load_models( prop_root ); // comment this out if preloading models
int nModels = _models.size();
int index = int(sg_random() * nModels);
if (index >= nModels)
// int index = int(sg_random() * nModels);
static int index = -1;
if (++index >= nModels)
index = 0;
return _models[index].get();
}