diff --git a/panda/src/particlesystem/baseParticle.cxx b/panda/src/particlesystem/baseParticle.cxx index af74c24f49..db7b9814d9 100644 --- a/panda/src/particlesystem/baseParticle.cxx +++ b/panda/src/particlesystem/baseParticle.cxx @@ -46,7 +46,7 @@ BaseParticle(const BaseParticle ©) { // Description : Default Destructor //////////////////////////////////////////////////////////////////// BaseParticle:: -~BaseParticle(void) { +~BaseParticle() { } //////////////////////////////////////////////////////////////////// @@ -55,6 +55,38 @@ BaseParticle:: // Description : for spriteParticleRenderer //////////////////////////////////////////////////////////////////// float BaseParticle:: -get_theta(void) const { +get_theta() const { return 0.0f; } + +//////////////////////////////////////////////////////////////////// +// Function : output +// Access : Public +// Description : Write a string representation of this instance to +// . +//////////////////////////////////////////////////////////////////// +void BaseParticle:: +output(ostream &out) const { + #ifndef NDEBUG //[ + out<<"BaseParticle"; + #endif //] NDEBUG +} + +//////////////////////////////////////////////////////////////////// +// Function : write +// Access : Public +// Description : Write a string representation of this instance to +// . +//////////////////////////////////////////////////////////////////// +void BaseParticle:: +write(ostream &out, unsigned int indent) const { + #ifndef NDEBUG //[ + out.width(indent); out<<""; out<<"BaseParticle:\n"; + out.width(indent+2); out<<""; out<<"_age "<<_age<<"\n"; + out.width(indent+2); out<<""; out<<"_lifespan "<<_lifespan<<"\n"; + out.width(indent+2); out<<""; out<<"_alive "<<_alive<<"\n"; + out.width(indent+2); out<<""; out<<"_last_position "<<_last_position<<"\n"; + PhysicsObject::write(out, indent+2); + #endif //] NDEBUG +} + diff --git a/panda/src/particlesystem/baseParticle.h b/panda/src/particlesystem/baseParticle.h index 7ba40d500a..4a6952d58b 100644 --- a/panda/src/particlesystem/baseParticle.h +++ b/panda/src/particlesystem/baseParticle.h @@ -28,6 +28,38 @@ // abstract base class. //////////////////////////////////////////////////////////////////// class EXPCL_PANDAPHYSICS BaseParticle : public PhysicsObject { +public: + // local methods + INLINE void set_age(float age); + INLINE void set_lifespan(float lifespan); + INLINE void set_alive(bool alive); + + INLINE float get_age() const; + INLINE float get_lifespan() const; + INLINE bool get_alive() const; + + INLINE float get_parameterized_age() const; + INLINE float get_parameterized_vel() const; + + // child methods + virtual void init() = 0; + virtual void die() = 0; + virtual void update() = 0; + + // for spriteParticleRenderer + virtual float get_theta() const; + + // from PhysicsObject + virtual PhysicsObject *make_copy() const = 0; + + virtual void output(ostream &out) const; + virtual void write(ostream &out, unsigned int indent=0) const; + +protected: + BaseParticle(int lifespan = 1, bool alive = false); + BaseParticle(const BaseParticle ©); + virtual ~BaseParticle(); + private: // NOTE: age and lifespan are in seconds. float _age; @@ -35,36 +67,6 @@ private: bool _alive; LPoint3f _last_position; - -protected: - BaseParticle(int lifespan = 1, bool alive = false); - BaseParticle(const BaseParticle ©); - virtual ~BaseParticle(void); - -public: - - // local methods - INLINE void set_age(float age); - INLINE void set_lifespan(float lifespan); - INLINE void set_alive(bool alive); - - INLINE float get_age(void) const; - INLINE float get_lifespan(void) const; - INLINE bool get_alive(void) const; - - INLINE float get_parameterized_age(void) const; - INLINE float get_parameterized_vel(void) const; - - // child methods - virtual void init(void) = 0; - virtual void die(void) = 0; - virtual void update(void) = 0; - - // for spriteParticleRenderer - virtual float get_theta(void) const; - - // from PhysicsObject - virtual PhysicsObject *make_copy(void) const = 0; }; #include "baseParticle.I" diff --git a/panda/src/particlesystem/baseParticleRenderer.cxx b/panda/src/particlesystem/baseParticleRenderer.cxx index 832857d859..f705286349 100644 --- a/panda/src/particlesystem/baseParticleRenderer.cxx +++ b/panda/src/particlesystem/baseParticleRenderer.cxx @@ -57,7 +57,7 @@ BaseParticleRenderer(const BaseParticleRenderer& copy) : // Description : Destructor //////////////////////////////////////////////////////////////////// BaseParticleRenderer:: -~BaseParticleRenderer(void) { +~BaseParticleRenderer() { } //////////////////////////////////////////////////////////////////// @@ -67,7 +67,7 @@ BaseParticleRenderer:: // enables alpha channeling. //////////////////////////////////////////////////////////////////// void BaseParticleRenderer:: -enable_alpha(void) { +enable_alpha() { _render_state = RenderState::make(TransparencyAttrib::make(TransparencyAttrib::M_alpha)); } @@ -77,7 +77,7 @@ enable_alpha(void) { // Description : kills the intermediate alpha node/arc //////////////////////////////////////////////////////////////////// void BaseParticleRenderer:: -disable_alpha(void) { +disable_alpha() { _render_state = RenderState::make(TransparencyAttrib::make(TransparencyAttrib::M_none)); } diff --git a/panda/src/particlesystem/baseParticleRenderer.h b/panda/src/particlesystem/baseParticleRenderer.h index 11baeda5f1..9689ecf987 100644 --- a/panda/src/particlesystem/baseParticleRenderer.h +++ b/panda/src/particlesystem/baseParticleRenderer.h @@ -50,12 +50,12 @@ PUBLISHED: PP_BLEND_CUBIC }; - virtual ~BaseParticleRenderer(void); + virtual ~BaseParticleRenderer(); - INLINE GeomNode *get_render_node(void) const; + INLINE GeomNode *get_render_node() const; INLINE void set_alpha_mode(ParticleRendererAlphaMode am); - INLINE ParticleRendererAlphaMode get_alpha_mode(void) const; + INLINE ParticleRendererAlphaMode get_alpha_mode() const; INLINE void set_user_alpha(float ua); INLINE float get_user_alpha(void) const; @@ -70,8 +70,8 @@ protected: void update_alpha_mode(ParticleRendererAlphaMode am); - void enable_alpha(void); - void disable_alpha(void); + void enable_alpha(); + void disable_alpha(); INLINE float get_cur_alpha(BaseParticle* bp); @@ -95,12 +95,12 @@ private: virtual void kill_particle(int index) = 0; - virtual void init_geoms(void) = 0; + virtual void init_geoms() = 0; virtual void render(pvector< PT(PhysicsObject) >& po_vector, int ttl_particles) = 0; public: - virtual BaseParticleRenderer *make_copy(void) = 0; + virtual BaseParticleRenderer *make_copy() = 0; friend class ParticleSystem; }; diff --git a/panda/src/particlesystem/config_particlesystem.h b/panda/src/particlesystem/config_particlesystem.h index 1d24729ca9..d41f3f2f11 100644 --- a/panda/src/particlesystem/config_particlesystem.h +++ b/panda/src/particlesystem/config_particlesystem.h @@ -28,4 +28,12 @@ NotifyCategoryDecl(particlesystem, EXPCL_PANDAPHYSICS, EXPTP_PANDAPHYSICS); extern EXPCL_PANDAPHYSICS void init_libparticlesystem(); +#ifndef NDEBUG //[ + // Non-release build: + #define PARTICLE_SYSTEM_DEBUG +#else //][ + // Release build: + #undef PARTICLE_SYSTEM_DEBUG +#endif //] + #endif // CONFIG_PARTICLESYSTEM_H diff --git a/panda/src/physics/actorNode.cxx b/panda/src/physics/actorNode.cxx index 742b97dcc5..af6900b58d 100644 --- a/panda/src/physics/actorNode.cxx +++ b/panda/src/physics/actorNode.cxx @@ -56,7 +56,7 @@ ActorNode(const ActorNode ©) : // Description : destructor //////////////////////////////////////////////////////////////////// ActorNode:: -~ActorNode(void) { +~ActorNode() { } //////////////////////////////////////////////////////////////////// @@ -66,7 +66,7 @@ ActorNode:: // Physical, moving the node and subsequent geometry. //////////////////////////////////////////////////////////////////// void ActorNode:: -update_transform(void) { +update_transform() { LMatrix4f lcs = _mass_center->get_lcs(); // lock the callback so that this doesn't call transform_changed. @@ -93,7 +93,6 @@ transform_changed() { CPT(TransformState) transform = get_transform(); // extract the position - LPoint3f pos; transform->get_mat().get_row3(pos,3); @@ -114,7 +113,24 @@ transform_changed() { // . //////////////////////////////////////////////////////////////////// void ActorNode:: -output(ostream &out, unsigned int indent) const { - out.width(indent); out<<""; out<<"ActorNode:\n"; - PhysicalNode::output(out, indent+2); +output(ostream &out) const { + #ifndef NDEBUG //[ + out<<"ActorNode"; + #endif //] NDEBUG +} + +//////////////////////////////////////////////////////////////////// +// Function : write +// Access : Public +// Description : Write a string representation of this instance to +// . +//////////////////////////////////////////////////////////////////// +void ActorNode:: +write(ostream &out, unsigned int indent) const { + #ifndef NDEBUG //[ + out.width(indent); out<<""; out<<"ActorNode:\n"; + out.width(indent+2); out<<""; out<<"_mass_center "<<_mass_center<<"\n"; + out.width(indent+2); out<<""; out<<"_ok_to_callback "<<_ok_to_callback<<"\n"; + PhysicalNode::write(out, indent+2); + #endif //] NDEBUG } diff --git a/panda/src/physics/actorNode.h b/panda/src/physics/actorNode.h index 5d11a870b8..c12b33f001 100644 --- a/panda/src/physics/actorNode.h +++ b/panda/src/physics/actorNode.h @@ -40,7 +40,8 @@ public: // update the parent arc with PhysicsObject information void update_transform(); - virtual void output(ostream &out, unsigned int indent=0) const; + virtual void output(ostream &out) const; + virtual void write(ostream &out, unsigned int indent=0) const; private: // node hook if the client changes the node's transform. diff --git a/panda/src/physics/angularEulerIntegrator.cxx b/panda/src/physics/angularEulerIntegrator.cxx index 0dbe904f14..04070c6ddd 100644 --- a/panda/src/physics/angularEulerIntegrator.cxx +++ b/panda/src/physics/angularEulerIntegrator.cxx @@ -162,7 +162,22 @@ child_integrate(Physical *physical, // . //////////////////////////////////////////////////////////////////// void AngularEulerIntegrator:: -output(ostream &out, unsigned int indent) const { - out.width(indent); out<<""; out<<"AngularEulerIntegrator:\n"; - AngularIntegrator::output(out, indent+2); +output(ostream &out) const { + #ifndef NDEBUG //[ + out<<"AngularEulerIntegrator"; + #endif //] NDEBUG +} + +//////////////////////////////////////////////////////////////////// +// Function : write +// Access : Public +// Description : Write a string representation of this instance to +// . +//////////////////////////////////////////////////////////////////// +void AngularEulerIntegrator:: +write(ostream &out, unsigned int indent) const { + #ifndef NDEBUG //[ + out.width(indent); out<<""; out<<"AngularEulerIntegrator:\n"; + AngularIntegrator::write(out, indent+2); + #endif //] NDEBUG } diff --git a/panda/src/physics/angularEulerIntegrator.h b/panda/src/physics/angularEulerIntegrator.h index 9bdc28d106..5b27df1275 100644 --- a/panda/src/physics/angularEulerIntegrator.h +++ b/panda/src/physics/angularEulerIntegrator.h @@ -27,16 +27,17 @@ // physically modelable objects given a quantum dt. //////////////////////////////////////////////////////////////////// class EXPCL_PANDAPHYSICS AngularEulerIntegrator : public AngularIntegrator { +PUBLISHED: + AngularEulerIntegrator(); + virtual ~AngularEulerIntegrator(); + + virtual void output(ostream &out) const; + virtual void write(ostream &out, unsigned int indent=0) const; + private: virtual void child_integrate(Physical *physical, pvector< PT(AngularForce) >& forces, float dt); - - virtual void output(ostream &out, unsigned int indent=0) const; - -PUBLISHED: - AngularEulerIntegrator(void); - virtual ~AngularEulerIntegrator(void); }; #endif // EULERINTEGRATOR_H diff --git a/panda/src/physics/angularForce.cxx b/panda/src/physics/angularForce.cxx index d2876bafe5..a33846a1c5 100644 --- a/panda/src/physics/angularForce.cxx +++ b/panda/src/physics/angularForce.cxx @@ -26,7 +26,7 @@ TypeHandle AngularForce::_type_handle; // Description : constructor //////////////////////////////////////////////////////////////////// AngularForce:: -AngularForce(void) : +AngularForce() : BaseForce() { } @@ -46,7 +46,7 @@ AngularForce(const AngularForce ©) : // Description : destructor //////////////////////////////////////////////////////////////////// AngularForce:: -~AngularForce(void) { +~AngularForce() { } //////////////////////////////////////////////////////////////////// @@ -66,7 +66,7 @@ get_vector(const PhysicsObject *po) { // Description : access query //////////////////////////////////////////////////////////////////// bool AngularForce:: -is_linear(void) const { +is_linear() const { return false; } @@ -77,7 +77,22 @@ is_linear(void) const { // . //////////////////////////////////////////////////////////////////// void AngularForce:: -output(ostream &out, unsigned int indent) const { - out.width(indent); out<<""; out<<"AngularForce:\n"; - BaseForce::output(out, indent+2); +output(ostream &out) const { + #ifndef NDEBUG //[ + out<<"AngularForce"; + #endif //] NDEBUG +} + +//////////////////////////////////////////////////////////////////// +// Function : write +// Access : Public +// Description : Write a string representation of this instance to +// . +//////////////////////////////////////////////////////////////////// +void AngularForce:: +write(ostream &out, unsigned int indent) const { + #ifndef NDEBUG //[ + out.width(indent); out<<""; out<<"AngularForce:\n"; + BaseForce::write(out, indent+2); + #endif //] NDEBUG } diff --git a/panda/src/physics/angularForce.h b/panda/src/physics/angularForce.h index b408dd1bd5..5d60a51527 100644 --- a/panda/src/physics/angularForce.h +++ b/panda/src/physics/angularForce.h @@ -33,7 +33,8 @@ PUBLISHED: LVector3f get_vector(const PhysicsObject *po); virtual bool is_linear() const; - virtual void output(ostream &out, unsigned int indent=0) const; + virtual void output(ostream &out) const; + virtual void write(ostream &out, unsigned int indent=0) const; protected: AngularForce(); diff --git a/panda/src/physics/angularIntegrator.cxx b/panda/src/physics/angularIntegrator.cxx index a298dc845d..bd9c8fa332 100644 --- a/panda/src/physics/angularIntegrator.cxx +++ b/panda/src/physics/angularIntegrator.cxx @@ -24,7 +24,7 @@ // Description : constructor //////////////////////////////////////////////////////////////////// AngularIntegrator:: -AngularIntegrator(void) { +AngularIntegrator() { } //////////////////////////////////////////////////////////////////// @@ -33,7 +33,7 @@ AngularIntegrator(void) { // Description : destructor //////////////////////////////////////////////////////////////////// AngularIntegrator:: -~AngularIntegrator(void) { +~AngularIntegrator() { } //////////////////////////////////////////////////////////////////// @@ -59,7 +59,23 @@ integrate(Physical *physical, pvector< PT(AngularForce) >& forces, // . //////////////////////////////////////////////////////////////////// void AngularIntegrator:: -output(ostream &out, unsigned int indent) const { - out.width(indent); out<<""; out<<"AngularIntegrator:\n"; - BaseIntegrator::output(out, indent+2); +output(ostream &out) const { + #ifndef NDEBUG //[ + out<<"AngularIntegrator"; + #endif //] NDEBUG +} + +//////////////////////////////////////////////////////////////////// +// Function : write +// Access : Public +// Description : Write a string representation of this instance to +// . +//////////////////////////////////////////////////////////////////// +void AngularIntegrator:: +write(ostream &out, unsigned int indent) const { + #ifndef NDEBUG //[ + out.width(indent); out<<""; out<<"AngularIntegrator:\n"; + out.width(indent+2); out<<""; out<<"_max_angular_dt "<<_max_angular_dt<<" (class const)\n"; + BaseIntegrator::write(out, indent+2); + #endif //] NDEBUG } diff --git a/panda/src/physics/angularIntegrator.h b/panda/src/physics/angularIntegrator.h index 5d4aae08fa..b535942728 100644 --- a/panda/src/physics/angularIntegrator.h +++ b/panda/src/physics/angularIntegrator.h @@ -30,15 +30,16 @@ //////////////////////////////////////////////////////////////////// class EXPCL_PANDAPHYSICS AngularIntegrator : public BaseIntegrator { public: - virtual ~AngularIntegrator(void); + virtual ~AngularIntegrator(); void integrate(Physical *physical, pvector< PT(AngularForce) > &forces, float dt); - virtual void output(ostream &out, unsigned int indent=0) const; + virtual void output(ostream &out) const; + virtual void write(ostream &out, unsigned int indent=0) const; protected: - AngularIntegrator(void); + AngularIntegrator(); private: static const float _max_angular_dt; diff --git a/panda/src/physics/angularVectorForce.I b/panda/src/physics/angularVectorForce.I index 68b52d7fd3..ae130499cb 100644 --- a/panda/src/physics/angularVectorForce.I +++ b/panda/src/physics/angularVectorForce.I @@ -39,6 +39,6 @@ set_vector(float x, float y, float z) { // Access : public //////////////////////////////////////////////////////////////////// INLINE LVector3f AngularVectorForce:: -get_local_vector(void) const { +get_local_vector() const { return _fvec; } diff --git a/panda/src/physics/angularVectorForce.cxx b/panda/src/physics/angularVectorForce.cxx index d9b209c520..92ef0d26ec 100644 --- a/panda/src/physics/angularVectorForce.cxx +++ b/panda/src/physics/angularVectorForce.cxx @@ -88,7 +88,23 @@ get_child_vector(const PhysicsObject *) { // . //////////////////////////////////////////////////////////////////// void AngularVectorForce:: -output(ostream &out, unsigned int indent) const { - out.width(indent); out<<""; out<<"AngularVectorForce:\n"; - AngularForce::output(out, indent+2); +output(ostream &out) const { + #ifndef NDEBUG //[ + out<<"AngularVectorForce"; + #endif //] NDEBUG +} + +//////////////////////////////////////////////////////////////////// +// Function : write +// Access : Public +// Description : Write a string representation of this instance to +// . +//////////////////////////////////////////////////////////////////// +void AngularVectorForce:: +write(ostream &out, unsigned int indent) const { + #ifndef NDEBUG //[ + out.width(indent); out<<""; out<<"AngularVectorForce:\n"; + out.width(indent+2); out<<""; out<<"_fvec "<<_fvec<<"\n"; + AngularForce::write(out, indent+2); + #endif //] NDEBUG } diff --git a/panda/src/physics/angularVectorForce.h b/panda/src/physics/angularVectorForce.h index bac63263b7..5a635e5f3d 100644 --- a/panda/src/physics/angularVectorForce.h +++ b/panda/src/physics/angularVectorForce.h @@ -31,30 +31,31 @@ PUBLISHED: AngularVectorForce(const LVector3f& vec); AngularVectorForce(float x = 0.0f, float y = 0.0f, float z = 0.0f); AngularVectorForce(const AngularVectorForce ©); - virtual ~AngularVectorForce(void); + virtual ~AngularVectorForce(); INLINE void set_vector(const LVector3f& v); INLINE void set_vector(float x, float y, float z); - INLINE LVector3f get_local_vector(void) const; + INLINE LVector3f get_local_vector() const; - virtual void output(ostream &out, unsigned int indent=0) const; + virtual void output(ostream &out) const; + virtual void write(ostream &out, unsigned int indent=0) const; private: LVector3f _fvec; - virtual AngularForce *make_copy(void) const; + virtual AngularForce *make_copy() const; virtual LVector3f get_child_vector(const PhysicsObject *po); public: - static TypeHandle get_class_type(void) { + static TypeHandle get_class_type() { return _type_handle; } - static void init_type(void) { + static void init_type() { AngularForce::init_type(); register_type(_type_handle, "AngularVectorForce", AngularForce::get_class_type()); } - virtual TypeHandle get_type(void) const { + virtual TypeHandle get_type() const { return get_class_type(); } virtual TypeHandle force_init_type() {init_type(); return get_class_type();} diff --git a/panda/src/physics/baseForce.I b/panda/src/physics/baseForce.I index 9d97954141..d81a2fb082 100644 --- a/panda/src/physics/baseForce.I +++ b/panda/src/physics/baseForce.I @@ -21,7 +21,7 @@ // Access : Public //////////////////////////////////////////////////////////////////// INLINE ForceNode *BaseForce:: -get_force_node(void) const { +get_force_node() const { return _force_node; } @@ -39,6 +39,6 @@ set_active(bool active) { // Access : Public //////////////////////////////////////////////////////////////////// INLINE bool BaseForce:: -get_active(void) const { +get_active() const { return _active; } diff --git a/panda/src/physics/baseForce.cxx b/panda/src/physics/baseForce.cxx index 56a88f8e52..e5b48d551a 100644 --- a/panda/src/physics/baseForce.cxx +++ b/panda/src/physics/baseForce.cxx @@ -58,7 +58,24 @@ BaseForce:: // . //////////////////////////////////////////////////////////////////// void BaseForce:: -output(ostream &out, unsigned int indent) const { - out.width(indent); out<<""; out<<"BaseForce:\n"; - //TypedReferenceCount::output(out); +output(ostream &out) const { + #ifndef NDEBUG //[ + out<<"BaseForce"; + #endif //] NDEBUG +} + +//////////////////////////////////////////////////////////////////// +// Function : write +// Access : Public +// Description : Write a string representation of this instance to +// . +//////////////////////////////////////////////////////////////////// +void BaseForce:: +write(ostream &out, unsigned int indent) const { + #ifndef NDEBUG //[ + out.width(indent); out<<""; out<<"BaseForce:\n"; + out.width(indent+2); out<<""; out<<"_force_node "<<_force_node<<"\n"; + out.width(indent+2); out<<""; out<<"_active "<<_active<<"\n"; + //TypedReferenceCount::write(out); + #endif //] NDEBUG } diff --git a/panda/src/physics/baseForce.h b/panda/src/physics/baseForce.h index fece853f3c..5f60eb3d17 100644 --- a/panda/src/physics/baseForce.h +++ b/panda/src/physics/baseForce.h @@ -19,9 +19,9 @@ #ifndef BASEFORCE_H #define BASEFORCE_H -#include -#include -#include +#include "pandabase.h" +#include "typedReferenceCount.h" +#include "luse.h" #include "physicsObject.h" @@ -44,7 +44,8 @@ PUBLISHED: virtual LVector3f get_vector(const PhysicsObject *po) = 0; - virtual void output(ostream &out, unsigned int indent=0) const; + virtual void output(ostream &out) const; + virtual void write(ostream &out, unsigned int indent=0) const; protected: BaseForce(bool active = true); diff --git a/panda/src/physics/baseIntegrator.cxx b/panda/src/physics/baseIntegrator.cxx index 140389b402..53729be08e 100644 --- a/panda/src/physics/baseIntegrator.cxx +++ b/panda/src/physics/baseIntegrator.cxx @@ -150,6 +150,61 @@ precompute_angular_matrices(Physical *physical, // . //////////////////////////////////////////////////////////////////// void BaseIntegrator:: -output(ostream &out, unsigned int indent) const { - out.width(indent); out<<""; out<<"BaseIntegrator:\n"; +output(ostream &out) const { + #ifndef NDEBUG //[ + out<<"BaseIntegrator"; + #endif //] NDEBUG +} + +//////////////////////////////////////////////////////////////////// +// Function : write_precomputed_linear_matrices +// Access : Public +// Description : Write a string representation of this instance to +// . +//////////////////////////////////////////////////////////////////// +void BaseIntegrator:: +write_precomputed_linear_matrices(ostream &out, unsigned int indent) const { + #ifndef NDEBUG //[ + out.width(indent); + out<<""<<"_precomputed_linear_matrices\n"; + for (MatrixVector::const_iterator i=_precomputed_linear_matrices.begin(); + i != _precomputed_linear_matrices.end(); + ++i) { + out.width(indent+2); out<<""; (*i).output(out); out<<"\n"; + } + #endif //] NDEBUG +} + +//////////////////////////////////////////////////////////////////// +// Function : write_precomputed_angular_matrices +// Access : Public +// Description : Write a string representation of this instance to +// . +//////////////////////////////////////////////////////////////////// +void BaseIntegrator:: +write_precomputed_angular_matrices(ostream &out, unsigned int indent) const { + #ifndef NDEBUG //[ + out.width(indent); + out<<""<<"_precomputed_angular_matrices\n"; + for (MatrixVector::const_iterator i=_precomputed_angular_matrices.begin(); + i != _precomputed_angular_matrices.end(); + ++i) { + out.width(indent+2); out<<""; (*i).output(out); out<<"\n"; + } + #endif //] NDEBUG +} + +//////////////////////////////////////////////////////////////////// +// Function : write +// Access : Public +// Description : Write a string representation of this instance to +// . +//////////////////////////////////////////////////////////////////// +void BaseIntegrator:: +write(ostream &out, unsigned int indent) const { + #ifndef NDEBUG //[ + out.width(indent); out<<""; out<<"BaseIntegrator:\n"; + write_precomputed_linear_matrices(out, indent+2); + write_precomputed_angular_matrices(out, indent+2); + #endif //] NDEBUG } diff --git a/panda/src/physics/baseIntegrator.h b/panda/src/physics/baseIntegrator.h index 1fe01e76b3..a98a6048f1 100644 --- a/panda/src/physics/baseIntegrator.h +++ b/panda/src/physics/baseIntegrator.h @@ -19,10 +19,10 @@ #ifndef BASEINTEGRATOR_H #define BASEINTEGRATOR_H -#include -#include -#include -#include +#include "pandabase.h" +#include "pointerTo.h" +#include "referenceCount.h" +#include "luse.h" #include "linearForce.h" #include "angularForce.h" @@ -39,17 +39,22 @@ class Physical; //////////////////////////////////////////////////////////////////// class EXPCL_PANDAPHYSICS BaseIntegrator : public ReferenceCount { public: - typedef pvector< LMatrix4f > VectorOfMatrices; + typedef pvector< LMatrix4f > MatrixVector; virtual ~BaseIntegrator(); - virtual void output(ostream &out, unsigned int indent=0) const; + virtual void output(ostream &out) const; + virtual void write_precomputed_linear_matrices(ostream &out, + unsigned int indent=0) const; + virtual void write_precomputed_angular_matrices(ostream &out, + unsigned int indent=0) const; + virtual void write(ostream &out, unsigned int indent=0) const; protected: BaseIntegrator(); - INLINE const VectorOfMatrices &get_precomputed_linear_matrices() const; - INLINE const VectorOfMatrices &get_precomputed_angular_matrices() const; + INLINE const MatrixVector &get_precomputed_linear_matrices() const; + INLINE const MatrixVector &get_precomputed_angular_matrices() const; void precompute_linear_matrices(Physical *physical, const pvector< PT(LinearForce) > &forces); @@ -61,8 +66,8 @@ private: // and however many forces will be the same among one physical, // the transformation matrices can be pulled out of the inner loop // and precomputed. - VectorOfMatrices _precomputed_linear_matrices; - VectorOfMatrices _precomputed_angular_matrices; + MatrixVector _precomputed_linear_matrices; + MatrixVector _precomputed_angular_matrices; }; #include "baseIntegrator.I" diff --git a/panda/src/physics/config_physics.h b/panda/src/physics/config_physics.h index 446286dbf3..cccc10bfd1 100644 --- a/panda/src/physics/config_physics.h +++ b/panda/src/physics/config_physics.h @@ -19,13 +19,21 @@ #ifndef CONFIG_PHYSICS_H #define CONFIG_PHYSICS_H -#include -#include -#include +#include "pandabase.h" +#include "notifyCategoryProxy.h" +#include "dconfig.h" ConfigureDecl(config_physics, EXPCL_PANDAPHYSICS, EXPTP_PANDAPHYSICS); NotifyCategoryDecl(physics, EXPCL_PANDAPHYSICS, EXPTP_PANDAPHYSICS); extern EXPCL_PANDAPHYSICS void init_libphysics(); +#ifndef NDEBUG //[ + // Non-release build: + #define PHYSICS_DEBUG +#else //][ + // Release build: + #undef PHYSICS_DEBUG +#endif //] + #endif // CONFIG_PHYSICS_H diff --git a/panda/src/physics/forceNode.cxx b/panda/src/physics/forceNode.cxx index e7466e6676..d3465911f4 100644 --- a/panda/src/physics/forceNode.cxx +++ b/panda/src/physics/forceNode.cxx @@ -47,7 +47,7 @@ ForceNode(const ForceNode ©) : // Description : destructor //////////////////////////////////////////////////////////////////// ForceNode:: -~ForceNode(void) { +~ForceNode() { } //////////////////////////////////////////////////////////////////// @@ -56,7 +56,7 @@ ForceNode:: // Description : dynamic child copy //////////////////////////////////////////////////////////////////// PandaNode *ForceNode:: -make_copy(void) const { +make_copy() const { return new ForceNode(*this); } @@ -115,7 +115,41 @@ remove_force(int index) { // . //////////////////////////////////////////////////////////////////// void ForceNode:: -output(ostream &out, unsigned int indent) const { - out.width(indent); out<<""; out<<"ForceNode\n"; - //PandaNode::output(out, indent+2); +output(ostream &out) const { + #ifndef NDEBUG //[ + out<<"ForceNode"; + #endif //] NDEBUG +} + +//////////////////////////////////////////////////////////////////// +// Function : write_linear_forces +// Access : Public +// Description : Write a string representation of this instance to +// . +//////////////////////////////////////////////////////////////////// +void ForceNode:: +write_forces(ostream &out, unsigned int indent) const { + #ifndef NDEBUG //[ + out.width(indent); out<<""<<"_forces\n"; + for (ForceVector::const_iterator i=_forces.begin(); + i != _forces.end(); + ++i) { + (*i)->write(out, indent+2); + } + #endif //] NDEBUG +} + +//////////////////////////////////////////////////////////////////// +// Function : write +// Access : Public +// Description : Write a string representation of this instance to +// . +//////////////////////////////////////////////////////////////////// +void ForceNode:: +write(ostream &out, unsigned int indent) const { + #ifndef NDEBUG //[ + out.width(indent); out<<""; out<<"ForceNode\n"; + write_forces(out, indent+2); + //PandaNode::write(out, indent+2); + #endif //] NDEBUG } diff --git a/panda/src/physics/forceNode.h b/panda/src/physics/forceNode.h index f569ba359d..6d7676002e 100644 --- a/panda/src/physics/forceNode.h +++ b/panda/src/physics/forceNode.h @@ -43,7 +43,9 @@ PUBLISHED: void remove_force(BaseForce *f); void remove_force(int index); - virtual void output(ostream &out, unsigned int indent=0) const; + virtual void output(ostream &out) const; + virtual void write_forces(ostream &out, unsigned int indent=0) const; + virtual void write(ostream &out, unsigned int indent=0) const; public: virtual ~ForceNode(); @@ -54,7 +56,8 @@ protected: ForceNode(const ForceNode ©); private: - pvector< PT(BaseForce) > _forces; + typedef pvector< PT(BaseForce) > ForceVector; + ForceVector _forces; public: static TypeHandle get_class_type() { diff --git a/panda/src/physics/linearCylinderVortexForce.cxx b/panda/src/physics/linearCylinderVortexForce.cxx index 86259dca95..b5c455070b 100644 --- a/panda/src/physics/linearCylinderVortexForce.cxx +++ b/panda/src/physics/linearCylinderVortexForce.cxx @@ -53,7 +53,7 @@ LinearCylinderVortexForce(const LinearCylinderVortexForce ©) : // Description : Destructor //////////////////////////////////////////////////////////////////// LinearCylinderVortexForce:: -~LinearCylinderVortexForce(void) { +~LinearCylinderVortexForce() { } //////////////////////////////////////////////////////////////////// @@ -137,7 +137,22 @@ get_child_vector(const PhysicsObject *po) { // . //////////////////////////////////////////////////////////////////// void LinearCylinderVortexForce:: -output(ostream &out, unsigned int indent) const { - out.width(indent); out<<""; out<<"LinearCylinderVortexForce:\n"; - LinearForce::output(out, indent+2); +output(ostream &out) const { + #ifndef NDEBUG //[ + out<<"LinearCylinderVortexForce"; + #endif //] NDEBUG +} + +//////////////////////////////////////////////////////////////////// +// Function : write +// Access : Public +// Description : Write a string representation of this instance to +// . +//////////////////////////////////////////////////////////////////// +void LinearCylinderVortexForce:: +write(ostream &out, unsigned int indent) const { + #ifndef NDEBUG //[ + out.width(indent); out<<""; out<<"LinearCylinderVortexForce:\n"; + LinearForce::write(out, indent+2); + #endif //] NDEBUG } diff --git a/panda/src/physics/linearCylinderVortexForce.h b/panda/src/physics/linearCylinderVortexForce.h index 055a6628fd..72031a072a 100644 --- a/panda/src/physics/linearCylinderVortexForce.h +++ b/panda/src/physics/linearCylinderVortexForce.h @@ -39,37 +39,38 @@ PUBLISHED: float a = 1.0f, bool md = false); LinearCylinderVortexForce(const LinearCylinderVortexForce ©); - virtual ~LinearCylinderVortexForce(void); + virtual ~LinearCylinderVortexForce(); INLINE void set_coef(float coef); - INLINE float get_coef(void) const; + INLINE float get_coef() const; INLINE void set_radius(float radius); - INLINE float get_radius(void) const; + INLINE float get_radius() const; INLINE void set_length(float length); - INLINE float get_length(void) const; + INLINE float get_length() const; - virtual void output(ostream &out, unsigned int indent=0) const; + virtual void output(ostream &out) const; + virtual void write(ostream &out, unsigned int indent=0) const; private: float _radius; float _length; float _coef; - virtual LinearForce *make_copy(void); + virtual LinearForce *make_copy(); virtual LVector3f get_child_vector(const PhysicsObject *po); public: - static TypeHandle get_class_type(void) { + static TypeHandle get_class_type() { return _type_handle; } - static void init_type(void) { + static void init_type() { LinearForce::init_type(); register_type(_type_handle, "LinearCylinderVortexForce", LinearForce::get_class_type()); } - virtual TypeHandle get_type(void) const { + virtual TypeHandle get_type() const { return get_class_type(); } virtual TypeHandle force_init_type() {init_type(); return get_class_type();} diff --git a/panda/src/physics/linearDistanceForce.cxx b/panda/src/physics/linearDistanceForce.cxx index f13d14b646..00b3ee9658 100644 --- a/panda/src/physics/linearDistanceForce.cxx +++ b/panda/src/physics/linearDistanceForce.cxx @@ -61,7 +61,25 @@ LinearDistanceForce:: // . //////////////////////////////////////////////////////////////////// void LinearDistanceForce:: -output(ostream &out, unsigned int indent) const { - out.width(indent); out<<""; out<<"LinearDistanceForce:\n"; - LinearForce::output(out, indent+2); +output(ostream &out) const { + #ifndef NDEBUG //[ + out<<"LinearDistanceForce"; + #endif //] NDEBUG +} + +//////////////////////////////////////////////////////////////////// +// Function : write +// Access : Public +// Description : Write a string representation of this instance to +// . +//////////////////////////////////////////////////////////////////// +void LinearDistanceForce:: +write(ostream &out, unsigned int indent) const { + #ifndef NDEBUG //[ + out.width(indent); out<<""; out<<"LinearDistanceForce:\n"; + out.width(indent+2); out<<""; out<<"_force_center "<<_force_center<<"\n"; + out.width(indent+2); out<<""; out<<"_falloff "<<_falloff<<"\n"; + out.width(indent+2); out<<""; out<<"_radius "<<_radius<<"\n"; + LinearForce::write(out, indent+2); + #endif //] NDEBUG } diff --git a/panda/src/physics/linearDistanceForce.h b/panda/src/physics/linearDistanceForce.h index 7ce03178d6..aca15a755b 100644 --- a/panda/src/physics/linearDistanceForce.h +++ b/panda/src/physics/linearDistanceForce.h @@ -39,13 +39,14 @@ PUBLISHED: INLINE void set_falloff_type(FalloffType ft); INLINE void set_force_center(const LPoint3f& p); - INLINE float get_radius(void) const; - INLINE FalloffType get_falloff_type(void) const; - INLINE LPoint3f get_force_center(void) const; + INLINE float get_radius() const; + INLINE FalloffType get_falloff_type() const; + INLINE LPoint3f get_force_center() const; - INLINE float get_scalar_term(void) const; + INLINE float get_scalar_term() const; - virtual void output(ostream &out, unsigned int indent=0) const; + virtual void output(ostream &out) const; + virtual void write(ostream &out, unsigned int indent=0) const; private: LPoint3f _force_center; @@ -53,25 +54,25 @@ private: FalloffType _falloff; float _radius; - virtual LinearForce *make_copy(void) = 0; + virtual LinearForce *make_copy() = 0; virtual LVector3f get_child_vector(const PhysicsObject *po) = 0; protected: LinearDistanceForce(const LPoint3f& p, FalloffType ft, float r, float a, bool m); LinearDistanceForce(const LinearDistanceForce ©); - virtual ~LinearDistanceForce(void); + virtual ~LinearDistanceForce(); public: - static TypeHandle get_class_type(void) { + static TypeHandle get_class_type() { return _type_handle; } - static void init_type(void) { + static void init_type() { LinearForce::init_type(); register_type(_type_handle, "LinearDistanceForce", LinearForce::get_class_type()); } - virtual TypeHandle get_type(void) const { + virtual TypeHandle get_type() const { return get_class_type(); } virtual TypeHandle force_init_type() {init_type(); return get_class_type();} diff --git a/panda/src/physics/linearEulerIntegrator.cxx b/panda/src/physics/linearEulerIntegrator.cxx index 03182e1033..84ba6c12a7 100644 --- a/panda/src/physics/linearEulerIntegrator.cxx +++ b/panda/src/physics/linearEulerIntegrator.cxx @@ -65,7 +65,7 @@ child_integrate(Physical *physical, // another integrator, be sure to process your forces global, then local. // otherwise your transforms will be VERY bad. precompute_linear_matrices(physical, forces); - const VectorOfMatrices &matrices = get_precomputed_linear_matrices(); + const MatrixVector &matrices = get_precomputed_linear_matrices(); // Loop through each object in the set. This processing occurs in O(pf) time, // where p is the number of physical objects and f is the number of @@ -181,10 +181,25 @@ child_integrate(Physical *physical, // . //////////////////////////////////////////////////////////////////// void LinearEulerIntegrator:: -output(ostream &out, unsigned int indent) const { +output(ostream &out) const { + #ifndef NDEBUG //[ + out<<"LinearEulerIntegrator"; + #endif //] NDEBUG +} + +//////////////////////////////////////////////////////////////////// +// Function : write +// Access : Public +// Description : Write a string representation of this instance to +// . +//////////////////////////////////////////////////////////////////// +void LinearEulerIntegrator:: +write(ostream &out, unsigned int indent) const { + #ifndef NDEBUG //[ out.width(indent); out<<""<<"LinearEulerIntegrator:\n"; - LinearIntegrator::output(out, indent+2); + LinearIntegrator::write(out, indent+2); + #endif //] NDEBUG } diff --git a/panda/src/physics/linearEulerIntegrator.h b/panda/src/physics/linearEulerIntegrator.h index 59670221c2..31cf030b9a 100644 --- a/panda/src/physics/linearEulerIntegrator.h +++ b/panda/src/physics/linearEulerIntegrator.h @@ -31,7 +31,8 @@ PUBLISHED: LinearEulerIntegrator(); virtual ~LinearEulerIntegrator(); - virtual void output(ostream &out, unsigned int indent=0) const; + virtual void output(ostream &out) const; + virtual void write(ostream &out, unsigned int indent=0) const; private: virtual void child_integrate(Physical *physical, diff --git a/panda/src/physics/linearForce.I b/panda/src/physics/linearForce.I index 0fa288ca9a..c60132a059 100644 --- a/panda/src/physics/linearForce.I +++ b/panda/src/physics/linearForce.I @@ -30,7 +30,7 @@ set_amplitude(float a) { // Access : Public //////////////////////////////////////////////////////////////////// INLINE float LinearForce:: -get_amplitude(void) const { +get_amplitude() const { return _amplitude; } @@ -39,7 +39,7 @@ get_amplitude(void) const { // Access : Public //////////////////////////////////////////////////////////////////// INLINE bool LinearForce:: -get_mass_dependent(void) const { +get_mass_dependent() const { return _mass_dependent; } diff --git a/panda/src/physics/linearForce.cxx b/panda/src/physics/linearForce.cxx index 33fe8485b3..f25da6a934 100644 --- a/panda/src/physics/linearForce.cxx +++ b/panda/src/physics/linearForce.cxx @@ -97,13 +97,27 @@ is_linear() const { // . //////////////////////////////////////////////////////////////////// void LinearForce:: -output(ostream &out, unsigned int indent) const { - out.width(indent); out<<""; - out<<"LinearForce:"; - out<<" amplitude "<<_amplitude; - out<<", mass_dependent "<<_mass_dependent; - out<<", x_mask "<<_x_mask; - out<<", y_mask "<<_y_mask; - out<<", z_mask "<<_z_mask; - BaseForce::output(out, indent+2); +output(ostream &out) const { + #ifndef NDEBUG //[ + out<<"LinearForce"; + #endif //] NDEBUG +} + +//////////////////////////////////////////////////////////////////// +// Function : write +// Access : Public +// Description : Write a string representation of this instance to +// . +//////////////////////////////////////////////////////////////////// +void LinearForce:: +write(ostream &out, unsigned int indent) const { + #ifndef NDEBUG //[ + out.width(indent); out<<""; out<<"LinearForce:\n"; + out.width(indent+2); out<<""; out<<"_amplitude "<<_amplitude<<"\n"; + out.width(indent+2); out<<""; out<<"_mass_dependent "<<_mass_dependent<<"\n"; + out.width(indent+2); out<<""; out<<"_x_mask "<<_x_mask<<"\n"; + out.width(indent+2); out<<""; out<<"_y_mask "<<_y_mask<<"\n"; + out.width(indent+2); out<<""; out<<"_z_mask "<<_z_mask<<"\n"; + BaseForce::write(out, indent+2); + #endif //] NDEBUG } diff --git a/panda/src/physics/linearForce.h b/panda/src/physics/linearForce.h index f8aadc4250..dbb1fc18c0 100644 --- a/panda/src/physics/linearForce.h +++ b/panda/src/physics/linearForce.h @@ -44,7 +44,8 @@ PUBLISHED: virtual bool is_linear() const; - virtual void output(ostream &out, unsigned int indent=0) const; + virtual void output(ostream &out) const; + virtual void write(ostream &out, unsigned int indent=0) const; protected: LinearForce(float a, bool mass); diff --git a/panda/src/physics/linearFrictionForce.cxx b/panda/src/physics/linearFrictionForce.cxx index 967a66ed5c..d3ba029d41 100644 --- a/panda/src/physics/linearFrictionForce.cxx +++ b/panda/src/physics/linearFrictionForce.cxx @@ -92,7 +92,23 @@ get_child_vector(const PhysicsObject* po) { // . //////////////////////////////////////////////////////////////////// void LinearFrictionForce:: -output(ostream &out, unsigned int indent) const { - out.width(indent); out<<""; out<<"LinearFrictionForce:\n"; - LinearForce::output(out, indent+2); +output(ostream &out) const { + #ifndef NDEBUG //[ + out<<"LinearFrictionForce"; + #endif //] NDEBUG +} + +//////////////////////////////////////////////////////////////////// +// Function : write +// Access : Public +// Description : Write a string representation of this instance to +// . +//////////////////////////////////////////////////////////////////// +void LinearFrictionForce:: +write(ostream &out, unsigned int indent) const { + #ifndef NDEBUG //[ + out.width(indent); out<<""; out<<"LinearFrictionForce:\n"; + out.width(indent+2); out<<""; out<<"_coef "<<_coef<<":\n"; + LinearForce::write(out, indent+2); + #endif //] NDEBUG } diff --git a/panda/src/physics/linearFrictionForce.h b/panda/src/physics/linearFrictionForce.h index 53d85e9d65..b2dd869743 100644 --- a/panda/src/physics/linearFrictionForce.h +++ b/panda/src/physics/linearFrictionForce.h @@ -34,7 +34,8 @@ PUBLISHED: INLINE void set_coef(float coef); INLINE float get_coef(void) const; - virtual void output(ostream &out, unsigned int indent=0) const; + virtual void output(ostream &out) const; + virtual void write(ostream &out, unsigned int indent=0) const; private: float _coef; diff --git a/panda/src/physics/linearIntegrator.cxx b/panda/src/physics/linearIntegrator.cxx index 6e616d737f..2221765ded 100644 --- a/panda/src/physics/linearIntegrator.cxx +++ b/panda/src/physics/linearIntegrator.cxx @@ -79,7 +79,23 @@ integrate(Physical *physical, pvector< PT(LinearForce) > &forces, // . //////////////////////////////////////////////////////////////////// void LinearIntegrator:: -output(ostream &out, unsigned int indent) const { - out.width(indent); out<<""; out<<"LinearIntegrator:\n"; - BaseIntegrator::output(out, indent+2); +output(ostream &out) const { + #ifndef NDEBUG //[ + out<<"LinearIntegrator"; + #endif //] NDEBUG +} + +//////////////////////////////////////////////////////////////////// +// Function : write +// Access : Public +// Description : Write a string representation of this instance to +// . +//////////////////////////////////////////////////////////////////// +void LinearIntegrator:: +write(ostream &out, unsigned int indent) const { + #ifndef NDEBUG //[ + out.width(indent); out<<""; out<<"LinearIntegrator:\n"; + out.width(indent+2); out<<""; out<<"_max_linear_dt "<<_max_linear_dt<<" (class static)\n"; + BaseIntegrator::write(out, indent+2); + #endif //] NDEBUG } diff --git a/panda/src/physics/linearIntegrator.h b/panda/src/physics/linearIntegrator.h index a3ee27219d..4b38e0eaf8 100644 --- a/panda/src/physics/linearIntegrator.h +++ b/panda/src/physics/linearIntegrator.h @@ -36,7 +36,8 @@ public: void integrate(Physical *physical, pvector< PT(LinearForce) > &forces, float dt); - virtual void output(ostream &out, unsigned int indent=0) const; + virtual void output(ostream &out) const; + virtual void write(ostream &out, unsigned int indent=0) const; protected: LinearIntegrator(); diff --git a/panda/src/physics/linearJitterForce.cxx b/panda/src/physics/linearJitterForce.cxx index 68b895b83a..ddced91caa 100644 --- a/panda/src/physics/linearJitterForce.cxx +++ b/panda/src/physics/linearJitterForce.cxx @@ -76,7 +76,22 @@ get_child_vector(const PhysicsObject *) { // . //////////////////////////////////////////////////////////////////// void LinearJitterForce:: -output(ostream &out, unsigned int indent) const { - out.width(indent); out<<""; out<<"LinearJitterForce:\n"; - LinearRandomForce::output(out, indent+2); +output(ostream &out) const { + #ifndef NDEBUG //[ + out<<"LinearJitterForce"; + #endif //] NDEBUG +} + +//////////////////////////////////////////////////////////////////// +// Function : write +// Access : Public +// Description : Write a string representation of this instance to +// . +//////////////////////////////////////////////////////////////////// +void LinearJitterForce:: +write(ostream &out, unsigned int indent) const { + #ifndef NDEBUG //[ + out.width(indent); out<<""; out<<"LinearJitterForce:\n"; + LinearRandomForce::write(out, indent+2); + #endif //] NDEBUG } diff --git a/panda/src/physics/linearJitterForce.h b/panda/src/physics/linearJitterForce.h index a099b5667f..5b55b9699a 100644 --- a/panda/src/physics/linearJitterForce.h +++ b/panda/src/physics/linearJitterForce.h @@ -32,7 +32,8 @@ PUBLISHED: LinearJitterForce(const LinearJitterForce ©); virtual ~LinearJitterForce(void); - virtual void output(ostream &out, unsigned int indent=0) const; + virtual void output(ostream &out) const; + virtual void write(ostream &out, unsigned int indent=0) const; private: virtual LVector3f get_child_vector(const PhysicsObject *po); diff --git a/panda/src/physics/linearNoiseForce.cxx b/panda/src/physics/linearNoiseForce.cxx index da1b4b64cf..2ed8576799 100644 --- a/panda/src/physics/linearNoiseForce.cxx +++ b/panda/src/physics/linearNoiseForce.cxx @@ -155,12 +155,27 @@ get_child_vector(const PhysicsObject *po) { // . //////////////////////////////////////////////////////////////////// void LinearNoiseForce:: -output(ostream &out, unsigned int indent) const { +output(ostream &out) const { + #ifndef NDEBUG //[ + out<<""<<"LinearNoiseForce"; + #endif //] NDEBUG +} + +//////////////////////////////////////////////////////////////////// +// Function : write +// Access : Public +// Description : Write a string representation of this instance to +// . +//////////////////////////////////////////////////////////////////// +void LinearNoiseForce:: +write(ostream &out, unsigned int indent) const { + #ifndef NDEBUG //[ out.width(indent); out<<""<<"LinearNoiseForce:"; - out<<", _random_seed"<<_random_seed; - out<<", _initialized"<<_initialized; - out<<", _gradient_table"<<_gradient_table<<"\n"; - out.width(indent+2); out<<""; out<<"_prn_table"<<_prn_table; - out<. //////////////////////////////////////////////////////////////////// void LinearRandomForce:: -output(ostream &out, unsigned int indent) const { - out.width(indent); out<<""; out<<"LinearRandomForce:\n"; - LinearForce::output(out, indent+2); +output(ostream &out) const { + #ifndef NDEBUG //[ + out<<"LinearRandomForce"; + #endif //] NDEBUG +} + +//////////////////////////////////////////////////////////////////// +// Function : write +// Access : Public +// Description : Write a string representation of this instance to +// . +//////////////////////////////////////////////////////////////////// +void LinearRandomForce:: +write(ostream &out, unsigned int indent) const { + #ifndef NDEBUG //[ + out.width(indent); out<<""; out<<"LinearRandomForce:\n"; + LinearForce::write(out, indent+2); + #endif //] NDEBUG } diff --git a/panda/src/physics/linearRandomForce.h b/panda/src/physics/linearRandomForce.h index 33c775a949..119908d19b 100644 --- a/panda/src/physics/linearRandomForce.h +++ b/panda/src/physics/linearRandomForce.h @@ -30,30 +30,31 @@ //////////////////////////////////////////////////////////////////// class EXPCL_PANDAPHYSICS LinearRandomForce : public LinearForce { PUBLISHED: - virtual ~LinearRandomForce(void); + virtual ~LinearRandomForce(); - virtual void output(ostream &out, unsigned int indent=0) const; + virtual void output(ostream &out) const; + virtual void write(ostream &out, unsigned int indent=0) const; protected: - static float bounded_rand(void); - static LVector3f random_unit_vector(void); + static float bounded_rand(); + static LVector3f random_unit_vector(); LinearRandomForce(float a = 1.0f, bool m = false); LinearRandomForce(const LinearRandomForce ©); virtual LVector3f get_child_vector(const PhysicsObject *po) = 0; - virtual LinearForce *make_copy(void) = 0; + virtual LinearForce *make_copy() = 0; public: - static TypeHandle get_class_type(void) { + static TypeHandle get_class_type() { return _type_handle; } - static void init_type(void) { + static void init_type() { LinearForce::init_type(); register_type(_type_handle, "LinearRandomForce", LinearForce::get_class_type()); } - virtual TypeHandle get_type(void) const { + virtual TypeHandle get_type() const { return get_class_type(); } virtual TypeHandle force_init_type() {init_type(); return get_class_type();} diff --git a/panda/src/physics/linearSinkForce.cxx b/panda/src/physics/linearSinkForce.cxx index 05b249229d..0722ae30a8 100644 --- a/panda/src/physics/linearSinkForce.cxx +++ b/panda/src/physics/linearSinkForce.cxx @@ -27,7 +27,7 @@ TypeHandle LinearSinkForce::_type_handle; //////////////////////////////////////////////////////////////////// LinearSinkForce:: LinearSinkForce(const LPoint3f& p, FalloffType f, float r, float a, - bool mass) : + bool mass) : LinearDistanceForce(p, f, r, a, mass) { } @@ -37,9 +37,9 @@ LinearSinkForce(const LPoint3f& p, FalloffType f, float r, float a, // Description : Simple constructor //////////////////////////////////////////////////////////////////// LinearSinkForce:: -LinearSinkForce(void) : +LinearSinkForce() : LinearDistanceForce(LPoint3f(0.0f, 0.0f, 0.0f), FT_ONE_OVER_R_SQUARED, - 1.0f, 1.0f, true) { + 1.0f, 1.0f, true) { } //////////////////////////////////////////////////////////////////// @@ -58,7 +58,7 @@ LinearSinkForce(const LinearSinkForce ©) : // Description : Simple destructor //////////////////////////////////////////////////////////////////// LinearSinkForce:: -~LinearSinkForce(void) { +~LinearSinkForce() { } //////////////////////////////////////////////////////////////////// @@ -67,7 +67,7 @@ LinearSinkForce:: // Description : copier //////////////////////////////////////////////////////////////////// LinearForce *LinearSinkForce:: -make_copy(void) { +make_copy() { return new LinearSinkForce(*this); } @@ -88,7 +88,22 @@ get_child_vector(const PhysicsObject *po) { // . //////////////////////////////////////////////////////////////////// void LinearSinkForce:: -output(ostream &out, unsigned int indent) const { - out.width(indent); out<<""; out<<"LinearSinkForce:\n"; - LinearDistanceForce::output(out, indent+2); +output(ostream &out) const { + #ifndef NDEBUG //[ + out<<"LinearSinkForce"; + #endif //] NDEBUG +} + +//////////////////////////////////////////////////////////////////// +// Function : write +// Access : Public +// Description : Write a string representation of this instance to +// . +//////////////////////////////////////////////////////////////////// +void LinearSinkForce:: +write(ostream &out, unsigned int indent) const { + #ifndef NDEBUG //[ + out.width(indent); out<<""; out<<"LinearSinkForce:\n"; + LinearDistanceForce::write(out, indent+2); + #endif //] NDEBUG } diff --git a/panda/src/physics/linearSinkForce.h b/panda/src/physics/linearSinkForce.h index 2df7d6a3c4..a83d764e12 100644 --- a/panda/src/physics/linearSinkForce.h +++ b/panda/src/physics/linearSinkForce.h @@ -28,27 +28,28 @@ class EXPCL_PANDAPHYSICS LinearSinkForce : public LinearDistanceForce { PUBLISHED: LinearSinkForce(const LPoint3f& p, FalloffType f, float r, float a = 1.0f, - bool m = true); - LinearSinkForce(void); + bool m = true); + LinearSinkForce(); LinearSinkForce(const LinearSinkForce ©); - virtual ~LinearSinkForce(void); + virtual ~LinearSinkForce(); - virtual void output(ostream &out, unsigned int indent=0) const; + virtual void output(ostream &out) const; + virtual void write(ostream &out, unsigned int indent=0) const; private: virtual LVector3f get_child_vector(const PhysicsObject *po); - virtual LinearForce *make_copy(void); + virtual LinearForce *make_copy(); public: - static TypeHandle get_class_type(void) { + static TypeHandle get_class_type() { return _type_handle; } - static void init_type(void) { + static void init_type() { LinearDistanceForce::init_type(); register_type(_type_handle, "LinearSinkForce", LinearDistanceForce::get_class_type()); } - virtual TypeHandle get_type(void) const { + virtual TypeHandle get_type() const { return get_class_type(); } virtual TypeHandle force_init_type() {init_type(); return get_class_type();} diff --git a/panda/src/physics/linearSourceForce.cxx b/panda/src/physics/linearSourceForce.cxx index 89095a076d..a515a0006b 100644 --- a/panda/src/physics/linearSourceForce.cxx +++ b/panda/src/physics/linearSourceForce.cxx @@ -37,7 +37,7 @@ LinearSourceForce(const LPoint3f& p, FalloffType f, float r, float a, // Description : Simple constructor //////////////////////////////////////////////////////////////////// LinearSourceForce:: -LinearSourceForce(void) : +LinearSourceForce() : LinearDistanceForce(LPoint3f(0.0f, 0.0f, 0.0f), FT_ONE_OVER_R_SQUARED, 1.0f, 1.0f, true) { } @@ -58,7 +58,7 @@ LinearSourceForce(const LinearSourceForce ©) : // Description : Simple destructor //////////////////////////////////////////////////////////////////// LinearSourceForce:: -~LinearSourceForce(void) { +~LinearSourceForce() { } //////////////////////////////////////////////////////////////////// @@ -88,7 +88,22 @@ get_child_vector(const PhysicsObject *po) { // . //////////////////////////////////////////////////////////////////// void LinearSourceForce:: -output(ostream &out, unsigned int indent) const { - out.width(indent); out<<""; out<<"LinearSourceForce:\n"; - LinearDistanceForce::output(out, indent+2); +output(ostream &out) const { + #ifndef NDEBUG //[ + out<<"LinearSourceForce"; + #endif //] NDEBUG +} + +//////////////////////////////////////////////////////////////////// +// Function : write +// Access : Public +// Description : Write a string representation of this instance to +// . +//////////////////////////////////////////////////////////////////// +void LinearSourceForce:: +write(ostream &out, unsigned int indent) const { + #ifndef NDEBUG //[ + out.width(indent); out<<""; out<<"LinearSourceForce:\n"; + LinearDistanceForce::write(out, indent+2); + #endif //] NDEBUG } diff --git a/panda/src/physics/linearSourceForce.h b/panda/src/physics/linearSourceForce.h index 8dceea9888..ef34b78c1f 100644 --- a/panda/src/physics/linearSourceForce.h +++ b/panda/src/physics/linearSourceForce.h @@ -29,26 +29,27 @@ class EXPCL_PANDAPHYSICS LinearSourceForce : public LinearDistanceForce { PUBLISHED: LinearSourceForce(const LPoint3f& p, FalloffType f, float r, float a = 1.0f, bool mass = true); - LinearSourceForce(void); + LinearSourceForce(); LinearSourceForce(const LinearSourceForce ©); - virtual ~LinearSourceForce(void); + virtual ~LinearSourceForce(); - virtual void output(ostream &out, unsigned int indent=0) const; + virtual void output(ostream &out) const; + virtual void write(ostream &out, unsigned int indent=0) const; private: virtual LVector3f get_child_vector(const PhysicsObject *po); - virtual LinearForce *make_copy(void); + virtual LinearForce *make_copy(); public: - static TypeHandle get_class_type(void) { + static TypeHandle get_class_type() { return _type_handle; } - static void init_type(void) { + static void init_type() { LinearDistanceForce::init_type(); register_type(_type_handle, "LinearSourceForce", LinearDistanceForce::get_class_type()); } - virtual TypeHandle get_type(void) const { + virtual TypeHandle get_type() const { return get_class_type(); } virtual TypeHandle force_init_type() {init_type(); return get_class_type();} diff --git a/panda/src/physics/linearUserDefinedForce.cxx b/panda/src/physics/linearUserDefinedForce.cxx index cd704ce00e..42fdfcb1c3 100644 --- a/panda/src/physics/linearUserDefinedForce.cxx +++ b/panda/src/physics/linearUserDefinedForce.cxx @@ -80,7 +80,22 @@ get_child_vector(const PhysicsObject *po) { // . //////////////////////////////////////////////////////////////////// void LinearUserDefinedForce:: -output(ostream &out, unsigned int indent) const { - out.width(indent); out<<""; out<<"LinearUserDefinedForce:\n"; - LinearForce::output(out, indent+2); +output(ostream &out) const { + #ifndef NDEBUG //[ + out<<"LinearUserDefinedForce"; + #endif //] NDEBUG +} + +//////////////////////////////////////////////////////////////////// +// Function : write +// Access : Public +// Description : Write a string representation of this instance to +// . +//////////////////////////////////////////////////////////////////// +void LinearUserDefinedForce:: +write(ostream &out, unsigned int indent) const { + #ifndef NDEBUG //[ + out.width(indent); out<<""; out<<"LinearUserDefinedForce:\n"; + LinearForce::write(out, indent+2); + #endif //] NDEBUG } diff --git a/panda/src/physics/linearUserDefinedForce.h b/panda/src/physics/linearUserDefinedForce.h index 0ed85f48b4..cb2a55cfce 100644 --- a/panda/src/physics/linearUserDefinedForce.h +++ b/panda/src/physics/linearUserDefinedForce.h @@ -41,7 +41,8 @@ PUBLISHED: INLINE void set_proc(LVector3f (*proc)(const PhysicsObject *)); - virtual void output(ostream &out, unsigned int indent=0) const; + virtual void output(ostream &out) const; + virtual void write(ostream &out, unsigned int indent=0) const; private: LVector3f (*_proc)(const PhysicsObject *po); diff --git a/panda/src/physics/linearVectorForce.cxx b/panda/src/physics/linearVectorForce.cxx index cf2ad1760a..d8fb49d17d 100644 --- a/panda/src/physics/linearVectorForce.cxx +++ b/panda/src/physics/linearVectorForce.cxx @@ -33,8 +33,7 @@ TypeHandle LinearVectorForce::_type_handle; LinearVectorForce:: LinearVectorForce(const LVector3f& vec, float a, bool mass) : LinearForce(a, mass), - _fvec(vec) -{ + _fvec(vec) { } //////////////////////////////////////////////////////////////////// @@ -65,7 +64,7 @@ LinearVectorForce(const LinearVectorForce ©) : // Description : Destructor //////////////////////////////////////////////////////////////////// LinearVectorForce:: -~LinearVectorForce(void) { +~LinearVectorForce() { } //////////////////////////////////////////////////////////////////// @@ -74,7 +73,7 @@ LinearVectorForce:: // Description : copier //////////////////////////////////////////////////////////////////// LinearForce *LinearVectorForce:: -make_copy(void) { +make_copy() { return new LinearVectorForce(*this); } @@ -95,7 +94,23 @@ get_child_vector(const PhysicsObject *) { // . //////////////////////////////////////////////////////////////////// void LinearVectorForce:: -output(ostream &out, unsigned int indent) const { - out.width(indent); out<<""; out<<"LinearVectorForce:\n"; - LinearForce::output(out, indent+2); +output(ostream &out) const { + #ifndef NDEBUG //[ + out<<"LinearVectorForce"; + #endif //] NDEBUG +} + +//////////////////////////////////////////////////////////////////// +// Function : write +// Access : Public +// Description : Write a string representation of this instance to +// . +//////////////////////////////////////////////////////////////////// +void LinearVectorForce:: +write(ostream &out, unsigned int indent) const { + #ifndef NDEBUG //[ + out.width(indent); out<<""; out<<"LinearVectorForce:\n"; + out.width(indent+2); out<<""; out<<"_fvec "<<_fvec<<"\n"; + LinearForce::write(out, indent+2); + #endif //] NDEBUG } diff --git a/panda/src/physics/linearVectorForce.h b/panda/src/physics/linearVectorForce.h index a1b619a0a9..6a7247f0e0 100644 --- a/panda/src/physics/linearVectorForce.h +++ b/panda/src/physics/linearVectorForce.h @@ -37,26 +37,27 @@ PUBLISHED: INLINE void set_vector(const LVector3f& v); INLINE void set_vector(float x, float y, float z); - INLINE LVector3f get_local_vector(void) const; + INLINE LVector3f get_local_vector() const; - virtual void output(ostream &out, unsigned int indent=0) const; + virtual void output(ostream &out) const; + virtual void write(ostream &out, unsigned int indent=0) const; private: LVector3f _fvec; - virtual LinearForce *make_copy(void); + virtual LinearForce *make_copy(); virtual LVector3f get_child_vector(const PhysicsObject *po); public: - static TypeHandle get_class_type(void) { + static TypeHandle get_class_type() { return _type_handle; } - static void init_type(void) { + static void init_type() { LinearForce::init_type(); register_type(_type_handle, "LinearVectorForce", LinearForce::get_class_type()); } - virtual TypeHandle get_type(void) const { + virtual TypeHandle get_type() const { return get_class_type(); } virtual TypeHandle force_init_type() {init_type(); return get_class_type();} diff --git a/panda/src/physics/physical.cxx b/panda/src/physics/physical.cxx index 5d23cfc938..132424221a 100644 --- a/panda/src/physics/physical.cxx +++ b/panda/src/physics/physical.cxx @@ -121,57 +121,6 @@ Physical:: } } -//////////////////////////////////////////////////////////////////// -// Function : output_physics_objects -// Access : Public -// Description : Write a string representation of this instance to -// . -//////////////////////////////////////////////////////////////////// -void Physical:: -output_physics_objects(ostream &out, unsigned int indent) const { - out.width(indent); - out<<""<<"_physics_objects\n"; - for (PhysicsObjectVector::const_iterator i=_physics_objects.begin(); - i != _physics_objects.end(); - ++i) { - (*i)->output(out, indent+2); - } -} - -//////////////////////////////////////////////////////////////////// -// Function : output_linear_forces -// Access : Public -// Description : Write a string representation of this instance to -// . -//////////////////////////////////////////////////////////////////// -void Physical:: -output_linear_forces(ostream &out, unsigned int indent) const { - out.width(indent); - out<<""<<"_linear_forces\n"; - for (LinearForceVector::const_iterator i=_linear_forces.begin(); - i != _linear_forces.end(); - ++i) { - (*i)->output(out, indent+2); - } -} - -//////////////////////////////////////////////////////////////////// -// Function : output_angular_forces -// Access : Public -// Description : Write a string representation of this instance to -// . -//////////////////////////////////////////////////////////////////// -void Physical:: -output_angular_forces(ostream &out, unsigned int indent) const { - out.width(indent); - out<<""<<"_angular_forces\n"; - for (AngularForceVector::const_iterator i=_angular_forces.begin(); - i != _angular_forces.end(); - ++i) { - (*i)->output(out, indent+2); - } -} - //////////////////////////////////////////////////////////////////// // Function : output // Access : Public @@ -179,17 +128,86 @@ output_angular_forces(ostream &out, unsigned int indent) const { // . //////////////////////////////////////////////////////////////////// void Physical:: -output(ostream &out, unsigned int indent) const { +output(ostream &out) const { + #ifndef NDEBUG //[ + out<<"Physical"; + #endif //] NDEBUG +} + +//////////////////////////////////////////////////////////////////// +// Function : write_physics_objects +// Access : Public +// Description : Write a string representation of this instance to +// . +//////////////////////////////////////////////////////////////////// +void Physical:: +write_physics_objects(ostream &out, unsigned int indent) const { + #ifndef NDEBUG //[ + out.width(indent); + out<<""<<"_physics_objects\n"; + for (PhysicsObjectVector::const_iterator i=_physics_objects.begin(); + i != _physics_objects.end(); + ++i) { + (*i)->write(out, indent+2); + } + #endif //] NDEBUG +} + +//////////////////////////////////////////////////////////////////// +// Function : write_linear_forces +// Access : Public +// Description : Write a string representation of this instance to +// . +//////////////////////////////////////////////////////////////////// +void Physical:: +write_linear_forces(ostream &out, unsigned int indent) const { + #ifndef NDEBUG //[ + out.width(indent); + out<<""<<"_linear_forces\n"; + for (LinearForceVector::const_iterator i=_linear_forces.begin(); + i != _linear_forces.end(); + ++i) { + (*i)->write(out, indent+2); + } + #endif //] NDEBUG +} + +//////////////////////////////////////////////////////////////////// +// Function : write_angular_forces +// Access : Public +// Description : Write a string representation of this instance to +// . +//////////////////////////////////////////////////////////////////// +void Physical:: +write_angular_forces(ostream &out, unsigned int indent) const { + #ifndef NDEBUG //[ + out.width(indent); + out<<""<<"_angular_forces\n"; + for (AngularForceVector::const_iterator i=_angular_forces.begin(); + i != _angular_forces.end(); + ++i) { + (*i)->write(out, indent+2); + } + #endif //] NDEBUG +} + +//////////////////////////////////////////////////////////////////// +// Function : write +// Access : Public +// Description : Write a string representation of this instance to +// . +//////////////////////////////////////////////////////////////////// +void Physical:: +write(ostream &out, unsigned int indent) const { + #ifndef NDEBUG //[ out.width(indent); out<<""<<"Physical:\n"; - output_physics_objects(out, indent+2); - output_linear_forces(out, indent+2); - output_angular_forces(out, indent+2); + write_physics_objects(out, indent+2); + write_linear_forces(out, indent+2); + write_angular_forces(out, indent+2); if (_phys_body) { - _phys_body->output(out, indent+2); + _phys_body->write(out, indent+2); } else { out.width(indent+2); out<<""<<"_phys_body is null\n"; } + #endif //] NDEBUG } - - - diff --git a/panda/src/physics/physical.h b/panda/src/physics/physical.h index c192931e4f..6999f6c2fc 100644 --- a/panda/src/physics/physical.h +++ b/panda/src/physics/physical.h @@ -19,9 +19,9 @@ #ifndef PHYSICAL_H #define PHYSICAL_H -#include -#include -#include +#include "pandabase.h" +#include "pointerTo.h" +#include "typedReferenceCount.h" #include "pvector.h" #include "plist.h" @@ -65,10 +65,11 @@ PUBLISHED: INLINE int get_num_angular_forces() const; INLINE PT(AngularForce) get_angular_force(int index) const; - void output_physics_objects(ostream &out, unsigned int indent=0) const; - void output_linear_forces(ostream &out, unsigned int indent=0) const; - void output_angular_forces(ostream &out, unsigned int indent=0) const; - void output(ostream &out, unsigned int indent=0) const; + virtual void output(ostream &out) const; + void write_physics_objects(ostream &out, unsigned int indent=0) const; + void write_linear_forces(ostream &out, unsigned int indent=0) const; + void write_angular_forces(ostream &out, unsigned int indent=0) const; + virtual void write(ostream &out, unsigned int indent=0) const; public: typedef pvector< PT(PhysicsObject) > PhysicsObjectVector; diff --git a/panda/src/physics/physicalNode.cxx b/panda/src/physics/physicalNode.cxx index ccd5d12329..b68321122c 100644 --- a/panda/src/physics/physicalNode.cxx +++ b/panda/src/physics/physicalNode.cxx @@ -115,7 +115,22 @@ remove_physical(int index) { // . //////////////////////////////////////////////////////////////////// void PhysicalNode:: -output(ostream &out, unsigned int indent) const { - out.width(indent); out<<""; out<<"PhysicalNode:\n"; - //PandaNode::output(out, indent+2); +output(ostream &out) const { + #ifndef NDEBUG //[ + out<<"PhysicalNode"; + #endif //] NDEBUG +} + +//////////////////////////////////////////////////////////////////// +// Function : write +// Access : Public +// Description : Write a string representation of this instance to +// . +//////////////////////////////////////////////////////////////////// +void PhysicalNode:: +write(ostream &out, unsigned int indent) const { + #ifndef NDEBUG //[ + out.width(indent); out<<""; out<<"PhysicalNode:\n"; + //PandaNode::write(out, indent+2); + #endif //] NDEBUG } diff --git a/panda/src/physics/physicalNode.h b/panda/src/physics/physicalNode.h index 418ca7a510..31b6c2fa3a 100644 --- a/panda/src/physics/physicalNode.h +++ b/panda/src/physics/physicalNode.h @@ -44,7 +44,8 @@ PUBLISHED: void remove_physical(Physical *physical); void remove_physical(int index); - virtual void output(ostream &out, unsigned int indent=0) const; + virtual void output(ostream &out) const; + virtual void write(ostream &out, unsigned int indent=0) const; public: virtual ~PhysicalNode(); diff --git a/panda/src/physics/physicsManager.cxx b/panda/src/physics/physicsManager.cxx index dd91043639..093eee2b29 100644 --- a/panda/src/physics/physicsManager.cxx +++ b/panda/src/physics/physicsManager.cxx @@ -129,13 +129,27 @@ do_physics(float dt) { } //////////////////////////////////////////////////////////////////// -// Function : output_physicals +// Function : output // Access : Public // Description : Write a string representation of this instance to // . //////////////////////////////////////////////////////////////////// void PhysicsManager:: -output_physicals(ostream &out, unsigned int indent) const { +output(ostream &out) const { + #ifndef NDEBUG //[ + out<<""<<"PhysicsManager"; + #endif //] NDEBUG +} + +//////////////////////////////////////////////////////////////////// +// Function : write_physicals +// Access : Public +// Description : Write a string representation of this instance to +// . +//////////////////////////////////////////////////////////////////// +void PhysicsManager:: +write_physicals(ostream &out, unsigned int indent) const { + #ifndef NDEBUG //[ if (indent>10) { return; } @@ -145,76 +159,78 @@ output_physicals(ostream &out, unsigned int indent) const { for (pvector< Physical * >::const_iterator i=_physicals.begin(); i != _physicals.end(); ++i) { - (*i)->output(out, indent+2); + (*i)->write(out, indent+2); } + #endif //] NDEBUG } //////////////////////////////////////////////////////////////////// -// Function : _linear_forces +// Function : write_forces // Access : Public // Description : Write a string representation of this instance to // . //////////////////////////////////////////////////////////////////// void PhysicsManager:: -output_linear_forces(ostream &out, unsigned int indent) const { - if (indent>10) { - return; - } +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(); i != _linear_forces.end(); ++i) { - (*i)->output(out, indent+2); + (*i)->write(out, indent+2); } + #endif //] NDEBUG } //////////////////////////////////////////////////////////////////// -// Function : output_angular_forces +// Function : write_angular_forces // Access : Public // Description : Write a string representation of this instance to // . //////////////////////////////////////////////////////////////////// void PhysicsManager:: -output_angular_forces(ostream &out, unsigned int indent) const { - if (indent>10) { - return; - } +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(); i != _angular_forces.end(); ++i) { - (*i)->output(out, indent+2); + (*i)->write(out, indent+2); } + #endif //] NDEBUG } //////////////////////////////////////////////////////////////////// -// Function : output +// Function : write // Access : Public // Description : Write a string representation of this instance to // . //////////////////////////////////////////////////////////////////// void PhysicsManager:: -output(ostream &out, unsigned int indent) const { - if (indent>10) { +write(ostream &out, unsigned int indent) const { + #ifndef NDEBUG //[ + out.width(indent); out<<""<<"PhysicsManager:\n"; + if (indent>20) { + // ...indent limit is arbitrary, it limits recursion. + out.width(indent+2); out<<""<<"...\n"; return; } - out.width(indent); - out<<""<<"PhysicsManager:\n"; - output_physicals(out, indent+2); - output_linear_forces(out, indent+2); - output_angular_forces(out, indent+2); + write_physicals(out, indent+2); + write_linear_forces(out, indent+2); + write_angular_forces(out, indent+2); + out.width(indent+2); out<<""<<"_linear_integrator:\n"; if (_linear_integrator) { - _linear_integrator->output(out, indent+2); + _linear_integrator->write(out, indent+4); } else { - out.width(indent+2); - out<<""<<"_linear_integrator is null\n"; + out.width(indent+4); out<<""<<"null\n"; } + out.width(indent+2); out<<""<<"_angular_integrator:\n"; if (_angular_integrator) { - _angular_integrator->output(out, indent+2); + _angular_integrator->write(out, indent+4); } else { - out.width(indent+2); - out<<""<<"_angular_integrator is null\n"; + out.width(indent+4); out<<""<<"null\n"; } + #endif //] NDEBUG } diff --git a/panda/src/physics/physicsManager.h b/panda/src/physics/physicsManager.h index eb3452d3b5..f004abd0d9 100644 --- a/panda/src/physics/physicsManager.h +++ b/panda/src/physics/physicsManager.h @@ -19,8 +19,8 @@ #ifndef PHYSICSMANAGER_H #define PHYSICSMANAGER_H -#include -#include +#include "pandabase.h" +#include "pointerTo.h" #include "physical.h" #include "linearForce.h" @@ -58,10 +58,11 @@ PUBLISHED: void remove_angular_force(AngularForce *f); void do_physics(float dt); - virtual void output_physicals(ostream &out, unsigned int indent=0) const; - virtual void output_linear_forces(ostream &out, unsigned int indent=0) const; - virtual void output_angular_forces(ostream &out, unsigned int indent=0) const; - virtual void output(ostream &out, unsigned int indent=0) const; + virtual void output(ostream &out) 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; + virtual void write(ostream &out, unsigned int indent=0) const; public: friend class Physical; diff --git a/panda/src/physics/physicsObject.I b/panda/src/physics/physicsObject.I index db5f3add7b..8afc448bd3 100644 --- a/panda/src/physics/physicsObject.I +++ b/panda/src/physics/physicsObject.I @@ -115,7 +115,7 @@ set_terminal_velocity(float tv) { // Description : Mass Query //////////////////////////////////////////////////////////////////// INLINE float PhysicsObject:: -get_mass(void) const { +get_mass() const { return _mass; } @@ -125,7 +125,7 @@ get_mass(void) const { // Description : Position Query //////////////////////////////////////////////////////////////////// INLINE LPoint3f PhysicsObject:: -get_position(void) const { +get_position() const { return _position; } @@ -135,7 +135,7 @@ get_position(void) const { // Description : Last position Query //////////////////////////////////////////////////////////////////// INLINE LPoint3f PhysicsObject:: -get_last_position(void) const { +get_last_position() const { return _last_position; } @@ -145,7 +145,7 @@ get_last_position(void) const { // Description : Velocity Query //////////////////////////////////////////////////////////////////// INLINE LVector3f PhysicsObject:: -get_velocity(void) const { +get_velocity() const { return _velocity; } @@ -155,7 +155,7 @@ get_velocity(void) const { // Description : Process Flag Query //////////////////////////////////////////////////////////////////// INLINE bool PhysicsObject:: -get_active(void) const { +get_active() const { return _process_me; } @@ -165,7 +165,7 @@ get_active(void) const { // Description : tv query //////////////////////////////////////////////////////////////////// INLINE float PhysicsObject:: -get_terminal_velocity(void) const { +get_terminal_velocity() const { return _terminal_velocity; } @@ -195,7 +195,7 @@ set_rotation(const LVector3f &rotation) { // Description : //////////////////////////////////////////////////////////////////// INLINE LOrientationf PhysicsObject:: -get_orientation(void) const { +get_orientation() const { return _orientation; } @@ -205,7 +205,7 @@ get_orientation(void) const { // Description : //////////////////////////////////////////////////////////////////// INLINE LVector3f PhysicsObject:: -get_rotation(void) const { +get_rotation() const { return _rotation; } @@ -225,6 +225,6 @@ set_oriented(bool flag) { // Description : //////////////////////////////////////////////////////////////////// INLINE bool PhysicsObject:: -get_oriented(void) const { +get_oriented() const { return _oriented; } diff --git a/panda/src/physics/physicsObject.cxx b/panda/src/physics/physicsObject.cxx index 67943b1dc4..63c2b81368 100644 --- a/panda/src/physics/physicsObject.cxx +++ b/panda/src/physics/physicsObject.cxx @@ -122,7 +122,21 @@ get_inertial_tensor() const { // . //////////////////////////////////////////////////////////////////// void PhysicsObject:: -output(ostream &out, unsigned int indent) const { +output(ostream &out) const { + #ifndef NDEBUG //[ + out<<"PhysicsObject"; + #endif //] NDEBUG +} + +//////////////////////////////////////////////////////////////////// +// Function : write +// Access : Public +// Description : Write a string representation of this instance to +// . +//////////////////////////////////////////////////////////////////// +void PhysicsObject:: +write(ostream &out, unsigned int indent) const { + #ifndef NDEBUG //[ out.width(indent); out<<""<<"PhysicsObject:\n"; out.width(indent+2); out<<""; out<<"_position "<<_position<<"\n"; @@ -134,4 +148,5 @@ output(ostream &out, unsigned int indent) const { out.width(indent+2); out<<""; out<<"_mass "<<_mass<<"\n"; out.width(indent+2); out<<""; out<<"_process_me "<<_process_me<<"\n"; out.width(indent+2); out<<""; out<<"_oriented "<<_oriented<<"\n"; + #endif //] NDEBUG } diff --git a/panda/src/physics/physicsObject.h b/panda/src/physics/physicsObject.h index b9cedfcbe6..3c2a6937bd 100644 --- a/panda/src/physics/physicsObject.h +++ b/panda/src/physics/physicsObject.h @@ -19,9 +19,9 @@ #ifndef PHYSICS_OBJECT_H #define PHYSICS_OBJECT_H -#include -#include -#include +#include "pandabase.h" +#include "typedReferenceCount.h" +#include "luse.h" //////////////////////////////////////////////////////////////////// // Class : PhysicsObject @@ -73,7 +73,8 @@ PUBLISHED: virtual LMatrix4f get_lcs() const; virtual PhysicsObject *make_copy() const; - void output(ostream &out, unsigned int indent=0) const; + virtual void output(ostream &out) const; + virtual void write(ostream &out, unsigned int indent=0) const; private: // physical