Panda3D
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Friends | List of all members
Physical Class Reference

Defines a set of physically modeled attributes. More...

#include "physical.h"

Inheritance diagram for Physical:
TypedReferenceCount TypedObject ReferenceCount MemoryBase MemoryBase ParticleSystem

Public Types

typedef pvector< PT(AngularForce)> AngularForceVector
 
typedef pvector< PT(LinearForce)> LinearForceVector
 

Public Member Functions

 Physical (const Physical &copy)
 copy constructor (note- does deep copy of pn's) but does NOT attach itself to its template's physicsmanager.
 
 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.
 
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 AngularForceVectorget_angular_forces () const
 
const LinearForceVectorget_linear_forces () const
 
int get_num_angular_forces () const
 
int get_num_linear_forces () const
 
const PhysicsObject::Vectorget_object_vector () const
 
const PhysicsObjectCollection get_objects () const
 
PhysicsObjectget_phys_body () const
 
PhysicalNodeget_physical_node () const
 
NodePath get_physical_node_path () const
 
PhysicsManagerget_physics_manager () const
 
virtual TypeHandle get_type () const
 
PN_stdfloat get_viscosity () const
 
virtual void output (std::ostream &out=std::cout) const
 Write a string representation of this instance to <out>.
 
 PT (AngularForce) get_angular_force(int index) const
 
 PT (LinearForce) get_linear_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)
 
virtual void write (std::ostream &out=std::cout, int indent=0) const
 Write a string representation of this instance to <out>.
 
virtual void write_angular_forces (std::ostream &out=std::cout, int indent=0) const
 Write a string representation of this instance to <out>.
 
virtual void write_linear_forces (std::ostream &out=std::cout, int indent=0) const
 Write a string representation of this instance to <out>.
 
virtual void write_physics_objects (std::ostream &out=std::cout, int indent=0) const
 Write a string representation of this instance to <out>.
 
- Public Member Functions inherited from TypedReferenceCount
 TypedReferenceCount (const TypedReferenceCount &copy)
 
void operator= (const TypedReferenceCount &copy)
 
- Public Member Functions inherited from TypedObject
 TypedObject (const TypedObject &copy)=default
 
TypedObjectas_typed_object ()
 Returns the object, upcast (if necessary) to a TypedObject pointer.
 
const TypedObjectas_typed_object () const
 Returns the object, upcast (if necessary) to a TypedObject pointer.
 
int get_best_parent_from_Set (const std::set< int > &) const
 
int get_type_index () const
 Returns the internal index number associated with this object's TypeHandle, a unique number for each different type.
 
bool is_exact_type (TypeHandle handle) const
 Returns true if the current object is the indicated type exactly.
 
bool is_of_type (TypeHandle handle) const
 Returns true if the current object is or derives from the indicated type.
 
TypedObjectoperator= (const TypedObject &copy)=default
 
- Public Member Functions inherited from MemoryBase
void operator delete (void *, void *)
 
void operator delete (void *ptr)
 
void operator delete[] (void *, void *)
 
void operator delete[] (void *ptr)
 
void * operator new (size_t size)
 
void * operator new (size_t size, void *ptr)
 
void * operator new[] (size_t size)
 
void * operator new[] (size_t size, void *ptr)
 
- Public Member Functions inherited from ReferenceCount
int get_ref_count () const
 
WeakReferenceListget_weak_list () const
 Returns the WeakReferenceList associated with this ReferenceCount object.
 
bool has_weak_list () const
 Returns true if this particular ReferenceCount object has a WeakReferenceList created, false otherwise.
 
void local_object ()
 This function should be called, once, immediately after creating a new instance of some ReferenceCount-derived object on the stack.
 
void ref () const
 Explicitly increments the reference count.
 
bool ref_if_nonzero () const
 Atomically increases the reference count of this object if it is not zero.
 
bool test_ref_count_integrity () const
 Does some easy checks to make sure that the reference count isn't completely bogus.
 
bool test_ref_count_nonzero () const
 Does some easy checks to make sure that the reference count isn't zero, or completely bogus.
 
virtual bool unref () const
 Explicitly decrements the reference count.
 
bool unref_if_one () const
 Atomically decreases the reference count of this object if it is one.
 
WeakReferenceListweak_ref ()
 Adds the indicated PointerToVoid as a weak reference to this object.
 
void weak_unref ()
 Removes the indicated PointerToVoid as a weak reference to this object.
 

Static Public Member Functions

static TypeHandle get_class_type ()
 
static void init_type ()
 
- Static Public Member Functions inherited from TypedReferenceCount
static TypeHandle get_class_type ()
 
static void init_type ()
 
- Static Public Member Functions inherited from TypedObject
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.
 
- Static Public Member Functions inherited from ReferenceCount
static TypeHandle get_class_type ()
 
static void init_type ()
 

Public Attributes

 get_angular_force
 
 get_linear_force
 
 get_num_angular_forces
 
 get_num_linear_forces
 
 get_objects
 
 get_viscosity
 Get the local viscosity.
 
- Public Attributes inherited from TypedObject
 get_type
 
- Public Attributes inherited from ReferenceCount
 get_ref_count
 Returns the current reference count.
 

Friends

class PhysicalNode
 
class PhysicsManager
 

Detailed Description

Defines a set of physically modeled attributes.

If you want physics applied to your class, derive it from this.

Definition at line 37 of file physical.h.

Member Typedef Documentation

◆ AngularForceVector

Definition at line 41 of file physical.h.

◆ LinearForceVector

Definition at line 40 of file physical.h.

Constructor & Destructor Documentation

◆ Physical() [1/2]

Physical::Physical ( int total_objects = 1,
bool pre_alloc = false )
explicit

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 34 of file physical.cxx.

References add_physics_object().

◆ Physical() [2/2]

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 59 of file physical.cxx.

◆ ~Physical()

Physical::~Physical ( )
virtual

destructor

Definition at line 98 of file physical.cxx.

References PhysicsManager::remove_physical().

Member Function Documentation

◆ add_angular_force()

void Physical::add_angular_force ( AngularForce * f)
inline

Adds an angular force to the force list.

Definition at line 54 of file physical.I.

◆ add_linear_force()

void Physical::add_linear_force ( LinearForce * f)
inline

Adds a linear force to the force list.

Definition at line 46 of file physical.I.

◆ add_physics_object()

void Physical::add_physics_object ( PhysicsObject * po)
inline

Adds an object to the physics object vector.

Definition at line 96 of file physical.I.

Referenced by Physical().

◆ clear_angular_forces()

void Physical::clear_angular_forces ( )
inline

Erases the angular force list.

Definition at line 28 of file physical.I.

◆ clear_linear_forces()

void Physical::clear_linear_forces ( )
inline

Erases the linear force list.

Definition at line 19 of file physical.I.

◆ clear_physics_objects()

void Physical::clear_physics_objects ( )
inline

Erases the object list.

Definition at line 37 of file physical.I.

Referenced by ParticleSystem::ParticleSystem().

◆ force_init_type()

virtual TypeHandle Physical::force_init_type ( )
inlinevirtual

Reimplemented from TypedReferenceCount.

Definition at line 127 of file physical.h.

◆ get_angular_forces()

const Physical::AngularForceVector & Physical::get_angular_forces ( ) const
inline

Definition at line 152 of file physical.I.

◆ get_class_type()

static TypeHandle Physical::get_class_type ( )
inlinestatic

Definition at line 116 of file physical.h.

◆ get_linear_forces()

const Physical::LinearForceVector & Physical::get_linear_forces ( ) const
inline

Definition at line 144 of file physical.I.

◆ get_object_vector()

const PhysicsObject::Vector & Physical::get_object_vector ( ) const
inline

Definition at line 136 of file physical.I.

◆ get_phys_body()

PhysicsObject * Physical::get_phys_body ( ) const
inline

Definition at line 112 of file physical.I.

◆ get_physical_node()

PhysicalNode * Physical::get_physical_node ( ) const
inline

Definition at line 120 of file physical.I.

◆ get_physical_node_path()

NodePath Physical::get_physical_node_path ( ) const
inline

Definition at line 128 of file physical.I.

◆ get_physics_manager()

PhysicsManager * Physical::get_physics_manager ( ) const
inline

Definition at line 104 of file physical.I.

◆ get_type()

virtual TypeHandle Physical::get_type ( ) const
inlinevirtual

Reimplemented from TypedReferenceCount.

Definition at line 124 of file physical.h.

◆ init_type()

static void Physical::init_type ( )
inlinestatic

Definition at line 119 of file physical.h.

◆ output()

void Physical::output ( std::ostream & out = std::cout) const
virtual

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

Reimplemented in ParticleSystem.

Definition at line 128 of file physical.cxx.

◆ remove_angular_force()

void Physical::remove_angular_force ( AngularForce * f)
inline

removes an angular force from the force list

Definition at line 80 of file physical.I.

◆ remove_linear_force()

void Physical::remove_linear_force ( LinearForce * f)
inline

removes a linear force from the force list

Definition at line 62 of file physical.I.

◆ write()

void Physical::write ( std::ostream & out = std::cout,
int indent = 0 ) const
virtual

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

Reimplemented in ParticleSystem.

Definition at line 186 of file physical.cxx.

References indent(), PhysicsObject::write(), write_angular_forces(), write_linear_forces(), and write_physics_objects().

Referenced by ParticleSystem::write().

◆ write_angular_forces()

void Physical::write_angular_forces ( std::ostream & out = std::cout,
int indent = 0 ) const
virtual

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

Definition at line 170 of file physical.cxx.

References indent().

Referenced by write().

◆ write_linear_forces()

void Physical::write_linear_forces ( std::ostream & out = std::cout,
int indent = 0 ) const
virtual

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

Definition at line 154 of file physical.cxx.

References indent().

Referenced by write().

◆ write_physics_objects()

void Physical::write_physics_objects ( std::ostream & out = std::cout,
int indent = 0 ) const
virtual

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

Definition at line 138 of file physical.cxx.

References indent().

Referenced by write().

Friends And Related Symbol Documentation

◆ PhysicalNode

friend class PhysicalNode
friend

Definition at line 95 of file physical.h.

◆ PhysicsManager

friend class PhysicsManager
friend

Definition at line 94 of file physical.h.

Member Data Documentation

◆ get_angular_force

Physical::get_angular_force

Definition at line 70 of file physical.h.

◆ get_linear_force

Physical::get_linear_force

Definition at line 66 of file physical.h.

◆ get_num_angular_forces

Physical::get_num_angular_forces

Definition at line 70 of file physical.h.

◆ get_num_linear_forces

int Physical::get_num_linear_forces
inline

Definition at line 66 of file physical.h.

◆ get_objects

const PhysicsObjectCollection Physical::get_objects

Definition at line 78 of file physical.h.

◆ get_viscosity

PN_stdfloat Physical::get_viscosity
inline

Get the local viscosity.

Definition at line 75 of file physical.h.


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