Panda3D
Public Types | Public Member Functions | Static Public Attributes | Friends | List of all members
PhysicsManager Class Reference

Physics don't get much higher-level than this. More...

#include "physicsManager.h"

Public Types

typedef pvector< PT(AngularForce)> AngularForceVector
 
typedef pvector< PT(LinearForce)> LinearForceVector
 
typedef pvector< Physical * > PhysicalsVector
 

Public Member Functions

 PhysicsManager ()
 Default Constructor. More...
 
virtual ~PhysicsManager ()
 Simple Destructor. More...
 
void add_angular_force (AngularForce *f)
 Adds a global angular force to the physics manager. More...
 
void add_linear_force (LinearForce *f)
 Adds a global linear force to the physics manager. More...
 
void attach_angular_integrator (AngularIntegrator *i)
 Hooks an angular integrator into the manager. More...
 
void attach_linear_integrator (LinearIntegrator *i)
 Hooks a linear integrator into the manager. More...
 
void attach_physical (Physical *p)
 Registers a Physical class with the manager. More...
 
void attach_physical_node (PhysicalNode *p)
 Registers a physicalnode with the manager. More...
 
void attach_physicalnode (PhysicalNode *p)
 Please call attach_physical_node instead. More...
 
void clear_angular_forces ()
 Resets the physics manager force vector. More...
 
void clear_linear_forces ()
 Resets the physics manager force vector. More...
 
void clear_physicals ()
 Resets the physics manager objects vector. More...
 
virtual void debug_output (ostream &out, unsigned int indent=0) const
 Write a string representation of this instance to <out>. More...
 
void do_physics (PN_stdfloat dt)
 This is the main high-level API call. More...
 
void do_physics (PN_stdfloat dt, Physical *p)
 This is the main high-level API call. More...
 
PN_stdfloat get_viscosity () const
 Get the global viscosity. More...
 
void init_random_seed ()
 One-time config function, sets up the random seed used by the physics and particle systems. More...
 
virtual void output (ostream &out) const
 Write a string representation of this instance to <out>. More...
 
void remove_angular_force (AngularForce *f)
 takes an angular force out of the physics list More...
 
void remove_linear_force (LinearForce *f)
 takes a linear force out of the physics list More...
 
void remove_physical (Physical *p)
 takes a physical out of the object list More...
 
void remove_physical_node (PhysicalNode *p)
 Removes a physicalnode from the manager. More...
 
void set_viscosity (PN_stdfloat viscosity)
 Set the global viscosity. More...
 
virtual void write (ostream &out, unsigned int indent=0) const
 Write a string representation of this instance to <out>. More...
 
virtual void write_angular_forces (ostream &out, unsigned int indent=0) const
 Write a string representation of this instance to <out>. More...
 
virtual void write_linear_forces (ostream &out, unsigned int indent=0) const
 Write a string representation of this instance to <out>. More...
 
virtual void write_physicals (ostream &out, unsigned int indent=0) const
 Write a string representation of this instance to <out>. More...
 

Static Public Attributes

static ConfigVariableInt _random_seed
 

Friends

class Physical
 

Detailed Description

Physics don't get much higher-level than this.

Attach as many Physicals (particle systems, etc..) as you want, pick an integrator and go.

Definition at line 39 of file physicsManager.h.

Constructor & Destructor Documentation

◆ PhysicsManager()

PhysicsManager::PhysicsManager ( )

Default Constructor.

NOTE: EulerIntegrator is the standard default.

Definition at line 31 of file physicsManager.cxx.

References ~PhysicsManager().

◆ ~PhysicsManager()

PhysicsManager::~PhysicsManager ( )
virtual

Simple Destructor.

Definition at line 43 of file physicsManager.cxx.

References init_random_seed().

Referenced by PhysicsManager().

Member Function Documentation

◆ add_angular_force()

void PhysicsManager::add_angular_force ( AngularForce f)
inline

Adds a global angular force to the physics manager.

Definition at line 90 of file physicsManager.I.

References clear_angular_forces().

Referenced by clear_linear_forces().

◆ add_linear_force()

void PhysicsManager::add_linear_force ( LinearForce f)
inline

Adds a global linear force to the physics manager.

Definition at line 37 of file physicsManager.I.

References attach_physicalnode().

Referenced by attach_physical().

◆ attach_angular_integrator()

void PhysicsManager::attach_angular_integrator ( AngularIntegrator i)
inline

Hooks an angular integrator into the manager.

Definition at line 156 of file physicsManager.I.

Referenced by attach_linear_integrator().

◆ attach_linear_integrator()

void PhysicsManager::attach_linear_integrator ( LinearIntegrator i)
inline

Hooks a linear integrator into the manager.

Definition at line 145 of file physicsManager.I.

References attach_angular_integrator().

Referenced by get_viscosity().

◆ attach_physical()

void PhysicsManager::attach_physical ( Physical p)
inline

Registers a Physical class with the manager.

Definition at line 21 of file physicsManager.I.

References add_linear_force().

Referenced by attach_physical_node(), and ParticleSystem::~ParticleSystem().

◆ attach_physical_node()

void PhysicsManager::attach_physical_node ( PhysicalNode p)
inline

Registers a physicalnode with the manager.

Definition at line 67 of file physicsManager.I.

References attach_physical(), and clear_linear_forces().

Referenced by attach_physicalnode().

◆ attach_physicalnode()

void PhysicsManager::attach_physicalnode ( PhysicalNode p)
inline

Please call attach_physical_node instead.

Definition at line 53 of file physicsManager.I.

References attach_physical_node().

Referenced by add_linear_force().

◆ clear_angular_forces()

void PhysicsManager::clear_angular_forces ( )
inline

Resets the physics manager force vector.

Definition at line 105 of file physicsManager.I.

References clear_physicals().

Referenced by add_angular_force().

◆ clear_linear_forces()

void PhysicsManager::clear_linear_forces ( )
inline

Resets the physics manager force vector.

Definition at line 80 of file physicsManager.I.

References add_angular_force().

Referenced by attach_physical_node().

◆ clear_physicals()

void PhysicsManager::clear_physicals ( )
inline

Resets the physics manager objects vector.

Definition at line 115 of file physicsManager.I.

References set_viscosity().

Referenced by clear_angular_forces().

◆ debug_output()

void PhysicsManager::debug_output ( ostream &  out,
unsigned int  indent = 0 
) const
virtual

Write a string representation of this instance to <out>.

Definition at line 315 of file physicsManager.cxx.

Referenced by write().

◆ do_physics() [1/2]

void PhysicsManager::do_physics ( PN_stdfloat  dt)

This is the main high-level API call.

Performs integration on every attached Physical.

Definition at line 142 of file physicsManager.cxx.

References TypedObject::is_of_type(), and ActorNode::update_transform().

Referenced by remove_physical_node().

◆ do_physics() [2/2]

void PhysicsManager::do_physics ( PN_stdfloat  dt,
Physical physical 
)

This is the main high-level API call.

Performs integration on a single physical. Make sure its associated forces are active.

Definition at line 178 of file physicsManager.cxx.

References TypedObject::is_of_type(), output(), and ActorNode::update_transform().

◆ get_viscosity()

PN_stdfloat PhysicsManager::get_viscosity ( ) const
inline

Get the global viscosity.

Definition at line 135 of file physicsManager.I.

References attach_linear_integrator().

Referenced by set_viscosity().

◆ init_random_seed()

void PhysicsManager::init_random_seed ( )

One-time config function, sets up the random seed used by the physics and particle systems.

For synchronizing across distributed computers

Definition at line 59 of file physicsManager.cxx.

References remove_linear_force().

Referenced by ~PhysicsManager().

◆ output()

void PhysicsManager::output ( ostream &  out) const
virtual

Write a string representation of this instance to <out>.

Definition at line 208 of file physicsManager.cxx.

References write_physicals().

Referenced by do_physics().

◆ remove_angular_force()

void PhysicsManager::remove_angular_force ( AngularForce f)

takes an angular force out of the physics list

Definition at line 90 of file physicsManager.cxx.

References remove_physical().

Referenced by remove_linear_force().

◆ remove_linear_force()

void PhysicsManager::remove_linear_force ( LinearForce f)

takes a linear force out of the physics list

Definition at line 71 of file physicsManager.cxx.

References remove_angular_force().

Referenced by init_random_seed().

◆ remove_physical()

void PhysicsManager::remove_physical ( Physical p)

takes a physical out of the object list

Definition at line 109 of file physicsManager.cxx.

References remove_physical_node().

Referenced by remove_angular_force(), remove_physical_node(), and Physical::~Physical().

◆ remove_physical_node()

void PhysicsManager::remove_physical_node ( PhysicalNode p)

Removes a physicalnode from the manager.

Definition at line 128 of file physicsManager.cxx.

References do_physics(), and remove_physical().

Referenced by remove_physical().

◆ set_viscosity()

void PhysicsManager::set_viscosity ( PN_stdfloat  viscosity)
inline

Set the global viscosity.

Definition at line 125 of file physicsManager.I.

References get_viscosity().

Referenced by clear_physicals().

◆ write()

void PhysicsManager::write ( ostream &  out,
unsigned int  indent = 0 
) const
virtual

Write a string representation of this instance to <out>.

Definition at line 282 of file physicsManager.cxx.

References debug_output(), write_angular_forces(), write_linear_forces(), and write_physicals().

Referenced by write_angular_forces().

◆ write_angular_forces()

void PhysicsManager::write_angular_forces ( ostream &  out,
unsigned int  indent = 0 
) const
virtual

Write a string representation of this instance to <out>.

Definition at line 263 of file physicsManager.cxx.

References write().

Referenced by write(), and write_linear_forces().

◆ write_linear_forces()

void PhysicsManager::write_linear_forces ( ostream &  out,
unsigned int  indent = 0 
) const
virtual

Write a string representation of this instance to <out>.

Definition at line 244 of file physicsManager.cxx.

References write_angular_forces().

Referenced by write(), and write_physicals().

◆ write_physicals()

void PhysicsManager::write_physicals ( ostream &  out,
unsigned int  indent = 0 
) const
virtual

Write a string representation of this instance to <out>.

Definition at line 221 of file physicsManager.cxx.

References write_linear_forces().

Referenced by output(), and write().


The documentation for this class was generated from the following files: