Panda3D
|
Defines a set of physically modeled attributes. More...
#include "physical.h"
Public Types | |
typedef pvector< PT(AngularForce)> | AngularForceVector |
typedef pvector< PT(LinearForce)> | LinearForceVector |
Public Member Functions | |
Physical (int total_objects=1, bool pre_alloc=false) | |
Default Constructor. | |
Physical (const Physical ©) | |
copy constructor (note- does deep copy of pn's) but does NOT attach itself to its template's physicsmanager. | |
virtual | ~Physical () |
destructor | |
void | add_angular_force (AngularForce *f) |
Adds an angular force to the force list. | |
void | add_linear_force (LinearForce *f) |
Adds a linear force to the force list. | |
void | add_physics_object (PhysicsObject *po) |
Adds an object to the physics object vector. | |
void | clear_angular_forces () |
Erases the angular force list. | |
void | clear_linear_forces () |
Erases the linear force list. | |
void | clear_physics_objects () |
Erases the object list. | |
virtual TypeHandle | force_init_type () |
const AngularForceVector & | get_angular_forces () const |
const LinearForceVector & | get_linear_forces () const |
int | get_num_angular_forces () const |
int | get_num_linear_forces () const |
const PhysicsObject::Vector & | get_object_vector () const |
const PhysicsObjectCollection | get_objects () const |
PhysicsObject * | get_phys_body () const |
PhysicalNode * | get_physical_node () const |
NodePath | get_physical_node_path () const |
PhysicsManager * | get_physics_manager () const |
virtual TypeHandle | get_type () const |
PN_stdfloat | get_viscosity () const |
Get the local viscosity. | |
MAKE_SEQ (get_linear_forces, get_num_linear_forces, get_linear_force) | |
MAKE_SEQ (get_angular_forces, get_num_angular_forces, get_angular_force) | |
virtual void | output (ostream &out=cout) const |
Write a string representation of this instance to <out>. | |
PT (LinearForce) get_linear_force(int index) const | |
PT (AngularForce) get_angular_force(int index) const | |
void | remove_angular_force (AngularForce *f) |
removes an angular force from the force list | |
void | remove_linear_force (LinearForce *f) |
removes a linear force from the force list | |
void | set_viscosity (PN_stdfloat viscosity) |
Set the local viscosity. | |
virtual void | write (ostream &out=cout, unsigned int indent=0) const |
Write a string representation of this instance to <out>. | |
virtual void | write_angular_forces (ostream &out=cout, unsigned int indent=0) const |
Write a string representation of this instance to <out>. | |
virtual void | write_linear_forces (ostream &out=cout, unsigned int indent=0) const |
Write a string representation of this instance to <out>. | |
virtual void | write_physics_objects (ostream &out=cout, unsigned int indent=0) const |
Write a string representation of this instance to <out>. | |
Static Public Member Functions | |
static TypeHandle | get_class_type () |
static void | init_type () |
This function is declared non-inline to work around a compiler bug in g++ 2.96. | |
Protected Attributes | |
AngularForceVector | _angular_forces |
LinearForceVector | _linear_forces |
PhysicsObject * | _phys_body |
PhysicsObject::Vector | _physics_objects |
PN_stdfloat | _viscosity |
Friends | |
class | PhysicalNode |
class | PhysicsManager |
Defines a set of physically modeled attributes.
If you want physics applied to your class, derive it from this.
Definition at line 40 of file physical.h.
Physical::Physical | ( | int | total_objects = 1 , |
bool | pre_alloc = false |
||
) |
Default Constructor.
The idea here is that most physicals will NOT be collections of sets (i.e. particle systems and whatever else). Because of this, the default constructor, unless otherwise specified, will automatically allocate and initialize one PhysicalObject. This makes it easier for high-level work.
pre-alloc is ONLY for multiple-object physicals, and if true, fills the physics_object vector with dead nodes, pre-allocating for the speed end of the speed-vs-overhead deal.
Definition at line 41 of file physical.cxx.
References add_physics_object().
Physical::Physical | ( | const Physical & | copy | ) |
copy constructor (note- does deep copy of pn's) but does NOT attach itself to its template's physicsmanager.
Definition at line 69 of file physical.cxx.
Physical::~Physical | ( | ) | [virtual] |
destructor
Definition at line 109 of file physical.cxx.
References PhysicsManager::remove_physical().
void Physical::add_angular_force | ( | AngularForce * | f | ) | [inline] |
Adds an angular force to the force list.
Definition at line 66 of file physical.I.
void Physical::add_linear_force | ( | LinearForce * | f | ) | [inline] |
Adds a linear force to the force list.
Definition at line 56 of file physical.I.
void Physical::add_physics_object | ( | PhysicsObject * | po | ) | [inline] |
Adds an object to the physics object vector.
Definition at line 114 of file physical.I.
Referenced by Physical().
void Physical::clear_angular_forces | ( | ) | [inline] |
Erases the angular force list.
Definition at line 34 of file physical.I.
void Physical::clear_linear_forces | ( | ) | [inline] |
Erases the linear force list.
Definition at line 23 of file physical.I.
void Physical::clear_physics_objects | ( | ) | [inline] |
Erases the object list.
Definition at line 45 of file physical.I.
Referenced by ParticleSystem::ParticleSystem().
PN_stdfloat Physical::get_viscosity | ( | ) | const [inline] |
Get the local viscosity.
Definition at line 235 of file physical.I.
static void Physical::init_type | ( | ) | [inline, static] |
This function is declared non-inline to work around a compiler bug in g++ 2.96.
Making it inline seems to cause problems in the optimizer.
Reimplemented from TypedReferenceCount.
Reimplemented in ParticleSystem.
Definition at line 119 of file physical.h.
References TypedReferenceCount::init_type().
Referenced by ParticleSystem::init_type().
void Physical::output | ( | ostream & | out = cout | ) | const [virtual] |
Write a string representation of this instance to <out>.
Reimplemented in ParticleSystem.
Definition at line 143 of file physical.cxx.
void Physical::remove_angular_force | ( | AngularForce * | f | ) | [inline] |
removes an angular force from the force list
Definition at line 96 of file physical.I.
void Physical::remove_linear_force | ( | LinearForce * | f | ) | [inline] |
removes a linear force from the force list
Definition at line 76 of file physical.I.
void Physical::set_viscosity | ( | PN_stdfloat | viscosity | ) | [inline] |
Set the local viscosity.
Definition at line 225 of file physical.I.
void Physical::write | ( | ostream & | out = cout , |
unsigned int | indent = 0 |
||
) | const [virtual] |
Write a string representation of this instance to <out>.
Definition at line 213 of file physical.cxx.
References PhysicsObject::write(), write_angular_forces(), write_linear_forces(), and write_physics_objects().
void Physical::write_angular_forces | ( | ostream & | out = cout , |
unsigned int | indent = 0 |
||
) | const [virtual] |
Write a string representation of this instance to <out>.
Definition at line 194 of file physical.cxx.
Referenced by write().
void Physical::write_linear_forces | ( | ostream & | out = cout , |
unsigned int | indent = 0 |
||
) | const [virtual] |
Write a string representation of this instance to <out>.
Definition at line 175 of file physical.cxx.
Referenced by write().
void Physical::write_physics_objects | ( | ostream & | out = cout , |
unsigned int | indent = 0 |
||
) | const [virtual] |
Write a string representation of this instance to <out>.
Definition at line 156 of file physical.cxx.
Referenced by write().