From fe3b009d2bfaa14afda7d898b2238628c5254b35 Mon Sep 17 00:00:00 2001 From: Dave Schuyler Date: Tue, 28 Oct 2003 00:25:00 +0000 Subject: [PATCH] added ls() --- panda/src/physics/physicsManager.I | 24 +++++++++++++++++++----- panda/src/physics/physicsManager.cxx | 8 ++++---- panda/src/physics/physicsManager.h | 9 +++++---- 3 files changed, 28 insertions(+), 13 deletions(-) diff --git a/panda/src/physics/physicsManager.I b/panda/src/physics/physicsManager.I index 9a1b608b23..9cbfb1dfae 100644 --- a/panda/src/physics/physicsManager.I +++ b/panda/src/physics/physicsManager.I @@ -27,8 +27,9 @@ attach_physical(Physical *p) { p->_physics_manager = this; pvector< Physical * >::iterator found; found = find(_physicals.begin(), _physicals.end(), p); - if (found == _physicals.end()) + if (found == _physicals.end()) { _physicals.push_back(p); + } } //////////////////////////////////////////////////////////////////// @@ -39,11 +40,12 @@ attach_physical(Physical *p) { INLINE void PhysicsManager:: add_linear_force(LinearForce *f) { nassertv(f); - pvector< PT(LinearForce) >::iterator found; + LinearForceVector::iterator found; PT(LinearForce) ptlf = f; found = find(_linear_forces.begin(), _linear_forces.end(), ptlf); - if (found == _linear_forces.end()) + if (found == _linear_forces.end()) { _linear_forces.push_back(f); + } } //////////////////////////////////////////////////////////////////// @@ -54,8 +56,9 @@ add_linear_force(LinearForce *f) { INLINE void PhysicsManager:: attach_physicalnode(PhysicalNode *p) { nassertv(p); - for (int i = 0; i < p->get_num_physicals(); i++) + for (int i = 0; i < p->get_num_physicals(); i++) { attach_physical(p->get_physical(i)); + } } //////////////////////////////////////////////////////////////////// @@ -76,7 +79,7 @@ clear_linear_forces() { INLINE void PhysicsManager:: add_angular_force(AngularForce *f) { nassertv(f); - pvector< PT(AngularForce) >::iterator found; + AngularForceVector::iterator found; PT(AngularForce) ptaf = f; found = find(_angular_forces.begin(), _angular_forces.end(), ptaf); if (found == _angular_forces.end()) @@ -144,3 +147,14 @@ attach_angular_integrator(AngularIntegrator *i) { nassertv(i); _angular_integrator = i; } + +//////////////////////////////////////////////////////////////////// +// Function: PhysicsManager::ls +// Access: Published +// Description: Shortcut for write(). This is handy for interactive +// debugging. +//////////////////////////////////////////////////////////////////// +INLINE void PhysicsManager:: +ls() const { + write(nout, 0); +} diff --git a/panda/src/physics/physicsManager.cxx b/panda/src/physics/physicsManager.cxx index 2df44d03dd..bda854cc96 100644 --- a/panda/src/physics/physicsManager.cxx +++ b/panda/src/physics/physicsManager.cxx @@ -52,7 +52,7 @@ PhysicsManager:: void PhysicsManager:: remove_linear_force(LinearForce *f) { nassertv(f); - pvector< PT(LinearForce) >::iterator found; + LinearForceVector::iterator found; PT(LinearForce) ptbf = f; found = find(_linear_forces.begin(), _linear_forces.end(), ptbf); @@ -71,7 +71,7 @@ remove_linear_force(LinearForce *f) { void PhysicsManager:: remove_angular_force(AngularForce *f) { nassertv(f); - pvector< PT(AngularForce) >::iterator found; + AngularForceVector::iterator found; PT(BaseForce) ptbf = f; found = find(_angular_forces.begin(), _angular_forces.end(), ptbf); @@ -180,7 +180,7 @@ write_linear_forces(ostream &out, unsigned int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""<<"_linear_forces ("<<_linear_forces.size()<<" forces)\n"; - for (pvector< PT(LinearForce) >::const_iterator i=_linear_forces.begin(); + for (LinearForceVector::const_iterator i=_linear_forces.begin(); i != _linear_forces.end(); ++i) { (*i)->write(out, indent+2); @@ -199,7 +199,7 @@ write_angular_forces(ostream &out, unsigned int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""<<"_angular_forces ("<<_angular_forces.size()<<" forces)\n"; - for (pvector< PT(AngularForce) >::const_iterator i=_angular_forces.begin(); + for (AngularForceVector::const_iterator i=_angular_forces.begin(); i != _angular_forces.end(); ++i) { (*i)->write(out, indent+2); diff --git a/panda/src/physics/physicsManager.h b/panda/src/physics/physicsManager.h index bc6f4934a7..0fd6ed2a96 100644 --- a/panda/src/physics/physicsManager.h +++ b/panda/src/physics/physicsManager.h @@ -48,8 +48,8 @@ public: // the task and also allowing for dynamically created and destroyed // physicals. typedef pvector PhysicalsVector; - typedef pvector LinearForcesVector; - typedef pvector AngularForcesVector; + typedef pvector LinearForceVector; + typedef pvector AngularForceVector; PUBLISHED: PhysicsManager(); @@ -74,6 +74,7 @@ PUBLISHED: void do_physics(float dt); virtual void output(ostream &out) const; + INLINE void ls() const; virtual void write_physicals(ostream &out, unsigned int indent=0) const; virtual void write_linear_forces(ostream &out, unsigned int indent=0) const; virtual void write_angular_forces(ostream &out, unsigned int indent=0) const; @@ -85,8 +86,8 @@ public: private: float _viscosity; PhysicalsVector _physicals; - LinearForcesVector _linear_forces; - AngularForcesVector _angular_forces; + LinearForceVector _linear_forces; + AngularForceVector _angular_forces; PT(LinearIntegrator) _linear_integrator; PT(AngularIntegrator) _angular_integrator;