added viscosity

This commit is contained in:
Dave Schuyler 2003-07-25 22:25:15 +00:00
parent a4a994b599
commit 4ff57f4306
3 changed files with 39 additions and 15 deletions

View File

@ -103,6 +103,26 @@ clear_physicals() {
_physicals.erase(_physicals.begin(), _physicals.end());
}
////////////////////////////////////////////////////////////////////
// Function : set_viscosity
// Access : Public
// Description : Set the global viscosity.
////////////////////////////////////////////////////////////////////
INLINE void PhysicsManager::
set_viscosity(float viscosity) {
_viscosity=viscosity;
}
////////////////////////////////////////////////////////////////////
// Function : get_viscosity
// Access : Public
// Description : Get the global viscosity.
////////////////////////////////////////////////////////////////////
INLINE float PhysicsManager::
get_viscosity() const {
return _viscosity;
}
////////////////////////////////////////////////////////////////////
// Function : attach_linear_integrator
// Access : Public

View File

@ -32,7 +32,7 @@ PhysicsManager::
PhysicsManager() {
_linear_integrator.clear();
_angular_integrator.clear();
_viscosity=0;
_viscosity=0.0;
}
////////////////////////////////////////////////////////////////////
@ -109,7 +109,7 @@ remove_physical(Physical *p) {
void PhysicsManager::
do_physics(float dt) {
// now, run through each physics object in the set.
pvector< Physical * >::iterator p_cur = _physicals.begin();
PhysicalsVector::iterator p_cur = _physicals.begin();
for (; p_cur != _physicals.end(); ++p_cur) {
Physical *physical = *p_cur;
nassertv(physical);

View File

@ -39,6 +39,18 @@
// as you want, pick an integrator and go.
////////////////////////////////////////////////////////////////////
class EXPCL_PANDAPHYSICS PhysicsManager {
public:
// NOTE that the physicals container is NOT reference counted.
// this does indeed mean that you are NOT supposed to use this
// as a primary storage container for the physicals. This is so
// because physicals, on their death, ask to be removed from their
// current physicsmanager, if one exists, relieving the client from
// the task and also allowing for dynamically created and destroyed
// physicals.
typedef pvector<Physical *> PhysicalsVector;
typedef pvector<PT(LinearForce)> LinearForcesVector;
typedef pvector<PT(AngularForce)> AngularForcesVector;
PUBLISHED:
PhysicsManager();
virtual ~PhysicsManager();
@ -53,8 +65,8 @@ PUBLISHED:
INLINE void clear_angular_forces();
INLINE void clear_physicals();
//INLINE void set_viscosity(float viscosity);
//float get_viscosity() const;
INLINE void set_viscosity(float viscosity);
INLINE float get_viscosity() const;
void remove_physical(Physical *p);
void remove_linear_force(LinearForce *f);
@ -72,17 +84,9 @@ public:
private:
float _viscosity;
// NOTE that the physicals container is NOT reference counted.
// this does indeed mean that you are NOT supposed to use this
// as a primary storage container for the physicals. This is so
// because physicals, on their death, ask to be removed from their
// current physicsmanager, if one exists, relieving the client from
// the task and also allowing for dynamically created and destroyed
// physicals.
pvector< Physical * > _physicals;
pvector< PT(LinearForce) > _linear_forces;
pvector< PT(AngularForce) > _angular_forces;
PhysicalsVector _physicals;
LinearForcesVector _linear_forces;
AngularForcesVector _angular_forces;
PT(LinearIntegrator) _linear_integrator;
PT(AngularIntegrator) _angular_integrator;