Added ability to set random seed to assist in synchronizing physics and particles across cluster rendering machines

This commit is contained in:
Mark Mine 2005-02-26 00:22:47 +00:00
parent edf017e3f6
commit 7d2b8904e0
2 changed files with 21 additions and 0 deletions

View File

@ -22,6 +22,9 @@
#include <algorithm>
#include "pvector.h"
ConfigVariableInt PhysicsManager::_random_seed
("physics_manager_random_seed", 139);
////////////////////////////////////////////////////////////////////
// Function : PhysicsManager
// Access : Public
@ -44,6 +47,20 @@ PhysicsManager::
~PhysicsManager() {
}
////////////////////////////////////////////////////////////////////
// Function : InitRandomSeed
// Access : Public
// Description : One-time config function, sets up the random seed
// used by the physics and particle systems.
// For synchronizing across distributed computers
////////////////////////////////////////////////////////////////////
void PhysicsManager::
init_random_seed(void) {
// Use the random seed specified by the physics_manager_random_seed
// Config Variable
srand(_random_seed);
}
////////////////////////////////////////////////////////////////////
// Function : remove_linear_force
// Access : Public

View File

@ -32,6 +32,8 @@
#include "plist.h"
#include "pvector.h"
#include "configVariableInt.h"
////////////////////////////////////////////////////////////////////
// Class : PhysicsManager
// Description : Physics don't get much higher-level than this.
@ -74,6 +76,7 @@ PUBLISHED:
void remove_linear_force(LinearForce *f);
void remove_angular_force(AngularForce *f);
void do_physics(float dt);
void init_random_seed();
virtual void output(ostream &out) const;
virtual void write_physicals(ostream &out, unsigned int indent=0) const;
@ -85,6 +88,7 @@ PUBLISHED:
public:
friend class Physical;
static ConfigVariableInt _random_seed;
private:
float _viscosity;