Browse Source

added viscosity

Dave Schuyler 22 years ago
parent
commit
4ff57f4306

+ 20 - 0
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

+ 2 - 2
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);

+ 17 - 13
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<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;