From 4ff57f4306c8af2a0e6eaea5dfad8528502f8761 Mon Sep 17 00:00:00 2001 From: Dave Schuyler Date: Fri, 25 Jul 2003 22:25:15 +0000 Subject: [PATCH] added viscosity --- panda/src/physics/physicsManager.I | 20 +++++++++++++++++++ panda/src/physics/physicsManager.cxx | 4 ++-- panda/src/physics/physicsManager.h | 30 ++++++++++++++++------------ 3 files changed, 39 insertions(+), 15 deletions(-) diff --git a/panda/src/physics/physicsManager.I b/panda/src/physics/physicsManager.I index 4bbcb66a61..9a1b608b23 100644 --- a/panda/src/physics/physicsManager.I +++ b/panda/src/physics/physicsManager.I @@ -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 diff --git a/panda/src/physics/physicsManager.cxx b/panda/src/physics/physicsManager.cxx index cc8271f341..2df44d03dd 100644 --- a/panda/src/physics/physicsManager.cxx +++ b/panda/src/physics/physicsManager.cxx @@ -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); diff --git a/panda/src/physics/physicsManager.h b/panda/src/physics/physicsManager.h index bef50f5db7..bc6f4934a7 100644 --- a/panda/src/physics/physicsManager.h +++ b/panda/src/physics/physicsManager.h @@ -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 PhysicalsVector; + typedef pvector LinearForcesVector; + typedef pvector 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;