mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-04 02:42:49 -04:00
Added ability to set random seed to assist in synchronizing physics and particles across cluster rendering machines
This commit is contained in:
parent
edf017e3f6
commit
7d2b8904e0
@ -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
|
||||
|
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user