Merge branch 'ehofman/model' into next

This commit is contained in:
Tim Moore
2010-05-05 08:44:32 +02:00
5 changed files with 8 additions and 11 deletions
+2 -6
View File
@@ -135,15 +135,11 @@ SGMatModel::load_models( SGPropertyNode *prop_root )
} }
osg::Node* osg::Node*
SGMatModel::get_random_model( SGPropertyNode *prop_root ) SGMatModel::get_random_model( SGPropertyNode *prop_root, mt seed )
{ {
load_models( prop_root ); // comment this out if preloading models load_models( prop_root ); // comment this out if preloading models
int nModels = _models.size(); int nModels = _models.size();
// int index = int(sg_random() * nModels); return _models[mt_rand(&seed) * nModels].get();
static int index = -1;
if (++index >= nModels)
index = 0;
return _models[index].get();
} }
double double
+1 -1
View File
@@ -82,7 +82,7 @@ public:
* *
* @return A randomly select model from the variants. * @return A randomly select model from the variants.
*/ */
osg::Node *get_random_model( SGPropertyNode *prop_root ); osg::Node *get_random_model( SGPropertyNode *prop_root, mt seed );
/** /**
+1 -1
View File
@@ -611,7 +611,7 @@ SGLoadBTG(const std::string& path, SGMaterialLib *matlib, bool calc_lights, bool
i < tileGeometryBin.randomModels.getNumModels(); i++) { i < tileGeometryBin.randomModels.getNumModels(); i++) {
SGMatModelBin::MatModel obj SGMatModelBin::MatModel obj
= tileGeometryBin.randomModels.getMatModel(i); = tileGeometryBin.randomModels.getMatModel(i);
osg::Node* node = sgGetRandomModel(obj.model); osg::Node* node = sgGetRandomModel(obj.model, seed);
// Create a matrix to place the object in the correct // Create a matrix to place the object in the correct
// location, and then apply the rotation matrix created // location, and then apply the rotation matrix created
+2 -2
View File
@@ -60,8 +60,8 @@ void sgUserDataInit( SGPropertyNode *p ) {
root_props = p; root_props = p;
} }
osg::Node* sgGetRandomModel(SGMatModel *obj) { osg::Node* sgGetRandomModel(SGMatModel *obj, mt seed) {
return obj->get_random_model( root_props ); return obj->get_random_model( root_props, seed );
} }
namespace simgear namespace simgear
+2 -1
View File
@@ -26,6 +26,7 @@
#define _SG_USERDATA_HXX #define _SG_USERDATA_HXX
#include <simgear/compiler.h> #include <simgear/compiler.h>
#include <simgear/math/sg_random.h>
#include <osg/Node> #include <osg/Node>
@@ -42,7 +43,7 @@ void sgUserDataInit(SGPropertyNode *p);
/** /**
* Get a random model. * Get a random model.
*/ */
osg::Node* sgGetRandomModel(SGMatModel *obj); osg::Node* sgGetRandomModel(SGMatModel *obj, mt seed);
namespace simgear namespace simgear
{ {