output() and write() changes
This commit is contained in:
parent
03204e52b6
commit
a045e476e7
|
|
@ -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
|
||||
// <out>.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
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
|
||||
// <out>.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
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
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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() {
|
|||
// <out>.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
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
|
||||
// <out>.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -162,7 +162,22 @@ child_integrate(Physical *physical,
|
|||
// <out>.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
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
|
||||
// <out>.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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 {
|
|||
// <out>.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
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
|
||||
// <out>.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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,
|
|||
// <out>.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
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
|
||||
// <out>.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -88,7 +88,23 @@ get_child_vector(const PhysicsObject *) {
|
|||
// <out>.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
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
|
||||
// <out>.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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();}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -58,7 +58,24 @@ BaseForce::
|
|||
// <out>.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
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
|
||||
// <out>.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,9 +19,9 @@
|
|||
#ifndef BASEFORCE_H
|
||||
#define BASEFORCE_H
|
||||
|
||||
#include <pandabase.h>
|
||||
#include <typedReferenceCount.h>
|
||||
#include <luse.h>
|
||||
#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);
|
||||
|
|
|
|||
|
|
@ -150,6 +150,61 @@ precompute_angular_matrices(Physical *physical,
|
|||
// <out>.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
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
|
||||
// <out>.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
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
|
||||
// <out>.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
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
|
||||
// <out>.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,10 +19,10 @@
|
|||
#ifndef BASEINTEGRATOR_H
|
||||
#define BASEINTEGRATOR_H
|
||||
|
||||
#include <pandabase.h>
|
||||
#include <pointerTo.h>
|
||||
#include <referenceCount.h>
|
||||
#include <luse.h>
|
||||
#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"
|
||||
|
|
|
|||
|
|
@ -19,13 +19,21 @@
|
|||
#ifndef CONFIG_PHYSICS_H
|
||||
#define CONFIG_PHYSICS_H
|
||||
|
||||
#include <pandabase.h>
|
||||
#include <notifyCategoryProxy.h>
|
||||
#include <dconfig.h>
|
||||
#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
|
||||
|
|
|
|||
|
|
@ -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) {
|
|||
// <out>.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
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
|
||||
// <out>.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
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
|
||||
// <out>.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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() {
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ LinearCylinderVortexForce(const LinearCylinderVortexForce ©) :
|
|||
// Description : Destructor
|
||||
////////////////////////////////////////////////////////////////////
|
||||
LinearCylinderVortexForce::
|
||||
~LinearCylinderVortexForce(void) {
|
||||
~LinearCylinderVortexForce() {
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
|
@ -137,7 +137,22 @@ get_child_vector(const PhysicsObject *po) {
|
|||
// <out>.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
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
|
||||
// <out>.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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();}
|
||||
|
|
|
|||
|
|
@ -61,7 +61,25 @@ LinearDistanceForce::
|
|||
// <out>.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
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
|
||||
// <out>.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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();}
|
||||
|
|
|
|||
|
|
@ -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,
|
|||
// <out>.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
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
|
||||
// <out>.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
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
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -97,13 +97,27 @@ is_linear() const {
|
|||
// <out>.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
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
|
||||
// <out>.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -92,7 +92,23 @@ get_child_vector(const PhysicsObject* po) {
|
|||
// <out>.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
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
|
||||
// <out>.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -79,7 +79,23 @@ integrate(Physical *physical, pvector< PT(LinearForce) > &forces,
|
|||
// <out>.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
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
|
||||
// <out>.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -76,7 +76,22 @@ get_child_vector(const PhysicsObject *) {
|
|||
// <out>.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
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
|
||||
// <out>.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -155,12 +155,27 @@ get_child_vector(const PhysicsObject *po) {
|
|||
// <out>.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
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
|
||||
// <out>.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
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<<endl;
|
||||
out.width(indent+2); out<<""; out<<"_random_seed"<<_random_seed<<" (class)\n";
|
||||
out.width(indent+2); out<<""; out<<"_initialized"<<_initialized<<" (class)\n";
|
||||
out.width(indent+2); out<<""; out<<"_gradient_table"<<_gradient_table<<" (class)\n";
|
||||
out.width(indent+2); out<<""; out<<"_prn_table"<<_prn_table<<" (class)\n";
|
||||
LinearRandomForce::write(out, indent+2);
|
||||
#endif //] NDEBUG
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,7 +32,8 @@ PUBLISHED:
|
|||
LinearNoiseForce(const LinearNoiseForce ©);
|
||||
virtual ~LinearNoiseForce();
|
||||
|
||||
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:
|
||||
static int _random_seed;
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ LinearRandomForce(const LinearRandomForce ©) :
|
|||
// Description : destructor
|
||||
////////////////////////////////////////////////////////////////////
|
||||
LinearRandomForce::
|
||||
~LinearRandomForce(void) {
|
||||
~LinearRandomForce() {
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
|
@ -55,7 +55,7 @@ LinearRandomForce::
|
|||
// Description : Returns a float in [0, 1]
|
||||
////////////////////////////////////////////////////////////////////
|
||||
float LinearRandomForce::
|
||||
bounded_rand(void) {
|
||||
bounded_rand() {
|
||||
return ((float)rand() / (float)RAND_MAX);
|
||||
}
|
||||
|
||||
|
|
@ -66,7 +66,22 @@ bounded_rand(void) {
|
|||
// <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
|
||||
// <out>.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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();}
|
||||
|
|
|
|||
|
|
@ -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) {
|
|||
// <out>.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
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
|
||||
// <out>.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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();}
|
||||
|
|
|
|||
|
|
@ -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) {
|
|||
// <out>.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
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
|
||||
// <out>.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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();}
|
||||
|
|
|
|||
|
|
@ -80,7 +80,22 @@ get_child_vector(const PhysicsObject *po) {
|
|||
// <out>.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
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
|
||||
// <out>.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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 *) {
|
|||
// <out>.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
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
|
||||
// <out>.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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();}
|
||||
|
|
|
|||
|
|
@ -121,57 +121,6 @@ Physical::
|
|||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function : output_physics_objects
|
||||
// Access : Public
|
||||
// Description : Write a string representation of this instance to
|
||||
// <out>.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
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
|
||||
// <out>.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
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
|
||||
// <out>.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
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 {
|
|||
// <out>.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
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
|
||||
// <out>.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
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
|
||||
// <out>.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
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
|
||||
// <out>.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
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
|
||||
// <out>.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
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
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -19,9 +19,9 @@
|
|||
#ifndef PHYSICAL_H
|
||||
#define PHYSICAL_H
|
||||
|
||||
#include <pandabase.h>
|
||||
#include <pointerTo.h>
|
||||
#include <typedReferenceCount.h>
|
||||
#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;
|
||||
|
|
|
|||
|
|
@ -115,7 +115,22 @@ remove_physical(int index) {
|
|||
// <out>.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
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
|
||||
// <out>.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -129,13 +129,27 @@ do_physics(float dt) {
|
|||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function : output_physicals
|
||||
// Function : output
|
||||
// Access : Public
|
||||
// Description : Write a string representation of this instance to
|
||||
// <out>.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
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
|
||||
// <out>.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
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
|
||||
// <out>.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
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
|
||||
// <out>.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
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
|
||||
// <out>.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,8 +19,8 @@
|
|||
#ifndef PHYSICSMANAGER_H
|
||||
#define PHYSICSMANAGER_H
|
||||
|
||||
#include <pandabase.h>
|
||||
#include <pointerTo.h>
|
||||
#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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -122,7 +122,21 @@ get_inertial_tensor() const {
|
|||
// <out>.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
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
|
||||
// <out>.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,9 +19,9 @@
|
|||
#ifndef PHYSICS_OBJECT_H
|
||||
#define PHYSICS_OBJECT_H
|
||||
|
||||
#include <pandabase.h>
|
||||
#include <typedReferenceCount.h>
|
||||
#include <luse.h>
|
||||
#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
|
||||
|
|
|
|||
Loading…
Reference in New Issue