Browse Source

added deubg_output

Dave Schuyler 21 years ago
parent
commit
184ed3e96f
2 changed files with 40 additions and 4 deletions
  1. 38 4
      panda/src/physics/physicsManager.cxx
  2. 2 0
      panda/src/physics/physicsManager.h

+ 38 - 4
panda/src/physics/physicsManager.cxx

@@ -76,9 +76,9 @@ remove_angular_force(AngularForce *f) {
   PT(BaseForce) ptbf = f;
   found = find(_angular_forces.begin(), _angular_forces.end(), ptbf);
 
-  if (found == _angular_forces.end())
+  if (found == _angular_forces.end()) {
     return;
-
+  }
   _angular_forces.erase(found);
 }
 
@@ -115,12 +115,14 @@ do_physics(float dt) {
     nassertv(physical);
 
     // do linear
-    if (_linear_integrator.is_null() == false) {
+    //if (_linear_integrator.is_null() == false) {
+    if (_linear_integrator) {
       _linear_integrator->integrate(physical, _linear_forces, dt);
     }
 
     // do angular
-    if (_angular_integrator.is_null() == false) {
+    //if (_angular_integrator.is_null() == false) {
+    if (_angular_integrator) {
       _angular_integrator->integrate(physical, _angular_forces, dt);
     }
 
@@ -239,3 +241,35 @@ write(ostream &out, unsigned int indent) const {
   }
   #endif //] NDEBUG
 }
+
+////////////////////////////////////////////////////////////////////
+//     Function : write
+//       Access : Public
+//  Description : Write a string representation of this instance to
+//                <out>.
+////////////////////////////////////////////////////////////////////
+void PhysicsManager::
+debug_output(ostream &out, unsigned int indent) const {
+  #ifndef NDEBUG //[
+  out.width(indent); out<<""<<"PhysicsManager li"<<(_linear_integrator?1:0)<<" ai"<<(_angular_integrator?1:0)<<"\n";
+  out<<"  _physicals "<<_physicals.size()<<"\n";
+  //_physicals._phys_body.write(out, indent+2);
+  
+
+  out.width(indent+2);
+  out<<""<<"_linear_forces ("<<_linear_forces.size()<<" forces)\n";
+  for (LinearForceVector::const_iterator i=_linear_forces.begin();
+       i != _linear_forces.end();
+       ++i) {
+    (*i)->write(out, indent+2);
+  }
+
+  out.width(indent+2);
+  out<<""<<"  _angular_forces "<<_angular_forces.size()<<"\n";
+  for (AngularForceVector::const_iterator i=_angular_forces.begin();
+       i != _angular_forces.end();
+       ++i) {
+    (*i)->write(out, indent+2);
+  }
+  #endif //] NDEBUG
+}

+ 2 - 0
panda/src/physics/physicsManager.h

@@ -79,6 +79,8 @@ PUBLISHED:
   virtual void write_angular_forces(ostream &out, unsigned int indent=0) const;
   virtual void write(ostream &out, unsigned int indent=0) const;
 
+  virtual void debug_output(ostream &out, unsigned int indent=0) const;
+
 public:
   friend class Physical;