MezzanineEngine March 18, 2012

Mezzanine::PhysicsManager Class Reference

This is simply a place for storing all the Physics Related functions. More...

#include <physicsmanager.h>

Inheritance diagram for Mezzanine::PhysicsManager:
Mezzanine::ManagerBase Mezzanine::Singleton< PhysicsManager >

List of all members.

Public Types

typedef std::map< ObjectPair,
Collision * >::iterator 
CollisionIterator
 Used to make working with the Collisions easier.
typedef std::map< ObjectPair,
Collision * >::const_iterator 
ConstCollisionIterator
 Used to make working with the Collisions easier, and avoid the risk of accidentally changing them.

Public Member Functions

 PhysicsManager ()
 Simple Constructor.
 PhysicsManager (const PhysicsConstructionInfo &Info)
 Simple Constructor.
virtual ~PhysicsManager ()
 Deconstructor.
void AddAreaEffect (AreaEffect *AE)
 Adds an area effect to the world.
void AddConstraint (TypedConstraint *Constraint, bool DisableCollisions=false)
 Adds a constraint to the world.
void AddWorldTrigger (WorldTrigger *Trig)
 Adds a trigger to the world.
CollisionIterator BeginCollision ()
 Get an CollisionIterator to the first Collision.
ConstCollisionIterator BeginCollision () const
 Get a ConstCollisionIterator to the first Collision.
void ClearPhysicsMetaData ()
 Clears all data relating to actors and other simulation objects from the physics world.
void DestroyAllAreaEffects ()
 Destroys all area effects currently in the manager.
void DestroyAllCollisions ()
 Destroys all collisions currently being stored and processed in the manager.
void DestroyAllConstraints ()
 Destroys all constraints currently in the manager.
void DestroyAllWorldTriggers ()
 Destroys all triggers currently in the manager.
void DoMainLoopItems (const Real &TimeElapsed)
 This does all the work reuired for the main loop to process physics.
virtual void DoMainLoopItems ()
CollisionIterator EndCollision ()
 Get a CollisionIterator to one past the last Collision.
ConstCollisionIterator EndCollision () const
 Get a ConstCollisionIterator to one past the last Collision.
AreaEffectGetAreaEffect (const String &Name)
 Gets an Area Effect by name.
AreaEffectGetAreaEffect (const Whole &Index)
 Gets an Area Effect by index.
CollisionGetCollision (ObjectPair *Pair)
 Gets a Collision by object pair.
unsigned short int GetCollisionAge ()
 Gets the Collision Age limit.
TypedConstraintGetConstraint (const Whole &Index)
 Gets a constraint by index.
int GetDebugPhysicsRendering ()
 Is Physics Debug Drawing currently enabled?
Whole GetDebugPhysicsWireCount ()
 This gets how many WireFrames are being drawn.
Vector3 GetGravity ()
 Gets the gravity.
Real GetImpulse ()
 Gets the Collision Impulse limit.
Whole GetNumAreaEffects ()
 Gets the number of Area Effects currently in the world.
Whole GetNumCollisions ()
 Gets the number of Collisions currently in the world.
Whole GetNumConstraints ()
 Gets the number of constraints currently in the world.
Whole GetNumWorldTriggers ()
 Gets the number of triggers currently in the world.
btSoftRigidDynamicsWorld * GetPhysicsWorldPointer ()
 This returns a pointer to the bullet physics world. This is for internal use only.
Vector3 GetSoftGravity ()
 Gets the soft body gravity.
virtual
ManagerBase::ManagerTypeName 
GetType () const
WorldTriggerGetWorldTrigger (const Whole &Index)
 Gets a trigger by index.
WorldTriggerGetWorldTrigger (const String &Name)
 Gets a trigger by name.
virtual void Initialize ()
void PauseSimulation (bool Pause)
 Pauses the simulation, preventing the physics world from taking action.
void RemoveAreaEffect (AreaEffect *AE)
 Removes an area effect from the world.
void RemoveCollision (Collision *Col)
 Removes an existing collision from the world.
void RemoveCollisionsContainingObject (WorldObject *Object)
 Removes all stored collisions that involve the specified Object.
void RemoveConstraint (TypedConstraint *Constraint)
 Removes a constraint from the world.
void RemoveWorldTrigger (WorldTrigger *Trig)
 Removes a trigger from the world.
void ResetPhysicsWorld (PhysicsConstructionInfo *Info=0)
 Resets all the internal physics structures in this manager.
void SetCollisionParams (const unsigned short int Age, Real Force)
 Sets the Collision Parameters.
void SetDebugPhysicsRendering (int ToBeEnabled)
 Enables and Disables Physics Debug Drawing.
void SetDebugPhysicsWireCount (Whole WireFrameCount_)
 How many Wireframes do you want drawn from previous events.
void SetGravity (const Vector3 &pgrav)
 Sets the gravity.
void SetIndividualGravity (ActorBase *Actor, const Vector3 &igrav)
 Sets the gravity to be applied to a single object.
void SetSimulationSubstepModifier (const Whole &Modifier)
 Sets the modifier to be used when stepping the physics simulation.
void SetSoftGravity (const Vector3 &sgrav)
 Sets the gravity for soft bodies.
bool SimulationIsPaused ()
 Gets Whether or not the simulation is currently paused.

Friends

class CollisionDispatcher

Detailed Description

This is simply a place for storing all the Physics Related functions.

This is a place for storing items related to Debug physics drawing, Adding constraints, screwing with gravity and doing other physics Related features.

Definition at line 144 of file physicsmanager.h.


Constructor & Destructor Documentation

Mezzanine::PhysicsManager::PhysicsManager ( )

Simple Constructor.

This constructor will assign some sane default values and will create a physics world that can be used immediately

Definition at line 426 of file physicsmanager.cpp.

Mezzanine::PhysicsManager::PhysicsManager ( const PhysicsConstructionInfo Info)

Simple Constructor.

This constructor will assign some sane default values and will create a physics world that can be used immediately

Parameters:
InfoThe construction info class with all the settings you wish the world to have.

Definition at line 436 of file physicsmanager.cpp.

Mezzanine::PhysicsManager::~PhysicsManager ( ) [virtual]

Deconstructor.

This deletes all those crazy pointers that Bullet, the physics subsystem need.

Definition at line 444 of file physicsmanager.cpp.


Member Function Documentation

void Mezzanine::PhysicsManager::AddAreaEffect ( AreaEffect AE)

Adds an area effect to the world.

Adds an area effect to the world so that it can/will take effect.

Parameters:
AEThe area effect to be added.

Definition at line 700 of file physicsmanager.cpp.

void Mezzanine::PhysicsManager::AddConstraint ( TypedConstraint Constraint,
bool  DisableCollisions = false 
)

Adds a constraint to the world.

Adds the constraint to the world so that it can/will take effect.

Parameters:
ConstraintThe constraint to be added.
DisableCollisionsSets whether or not the linked bodies collide with each other.

Definition at line 661 of file physicsmanager.cpp.

void Mezzanine::PhysicsManager::AddWorldTrigger ( WorldTrigger Trig)

Adds a trigger to the world.

Adds a trigger to the world so that it can/will take effect.

Parameters:
TrigThe trigger to be added.

Definition at line 751 of file physicsmanager.cpp.

PhysicsManager::ConstCollisionIterator Mezzanine::PhysicsManager::BeginCollision ( ) const

Get a ConstCollisionIterator to the first Collision.

Returns:
A ConstCollisionIterator to the first Collision.

Definition at line 866 of file physicsmanager.cpp.

PhysicsManager::CollisionIterator Mezzanine::PhysicsManager::BeginCollision ( )

Get an CollisionIterator to the first Collision.

Returns:
An CollisionIterator to the first Collision.

Definition at line 856 of file physicsmanager.cpp.

void Mezzanine::PhysicsManager::ClearPhysicsMetaData ( )

Clears all data relating to actors and other simulation objects from the physics world.

This is best used with simulation cleanup.

Definition at line 965 of file physicsmanager.cpp.

void Mezzanine::PhysicsManager::DestroyAllConstraints ( )

Destroys all constraints currently in the manager.

In practice it is cleaner to remove constraints from the world before removing any constrained actors.

Definition at line 690 of file physicsmanager.cpp.

void Mezzanine::PhysicsManager::DoMainLoopItems ( const Real TimeElapsed)

This does all the work reuired for the main loop to process physics.

Parameters:
TimeElapsedThis is a real that represents the amount of time we need to simulate

Definition at line 995 of file physicsmanager.cpp.

void Mezzanine::PhysicsManager::DoMainLoopItems ( ) [virtual]

The main loop calls this once per frame.

This is where each manager is expected to put anything that needs to be run each iteration of the main loop

Implements Mezzanine::ManagerBase.

Definition at line 1119 of file physicsmanager.cpp.

PhysicsManager::ConstCollisionIterator Mezzanine::PhysicsManager::EndCollision ( ) const

Get a ConstCollisionIterator to one past the last Collision.

Returns:
A ConstCollisionIterator to one past the last Collision.

Definition at line 871 of file physicsmanager.cpp.

PhysicsManager::CollisionIterator Mezzanine::PhysicsManager::EndCollision ( )

Get a CollisionIterator to one past the last Collision.

Returns:
A CollisionIterator to one past the last Collision.

Definition at line 861 of file physicsmanager.cpp.

AreaEffect * Mezzanine::PhysicsManager::GetAreaEffect ( const String Name)

Gets an Area Effect by name.

Parameters:
NameThe name of the area effect to find.
Returns:
Returns a pointer to the named area effect, or NULL if it doesn't exist.

Definition at line 706 of file physicsmanager.cpp.

AreaEffect * Mezzanine::PhysicsManager::GetAreaEffect ( const Whole Index)

Gets an Area Effect by index.

Parameters:
IndexThe index of the area effect you want.
Returns:
Returns a pointer to the area effect at the specified index.

Definition at line 718 of file physicsmanager.cpp.

Collision * Mezzanine::PhysicsManager::GetCollision ( ObjectPair Pair)

Gets a Collision by object pair.

Parameters:
PairA pair of objects.
Returns:
Returns a pointer to the Collision if a collision for the provided pair exists, NULL otherwise.

Definition at line 797 of file physicsmanager.cpp.

unsigned short int Mezzanine::PhysicsManager::GetCollisionAge ( )

Gets the Collision Age limit.

Gets the CollisionAge used in filtering out collision contacts used to make events.

Returns:
This function will return the number of physics ticks the collision has to have existed to be used.

Definition at line 882 of file physicsmanager.cpp.

TypedConstraint * Mezzanine::PhysicsManager::GetConstraint ( const Whole Index)

Gets a constraint by index.

Parameters:
IndexThe index of the constraint you want.
Returns:
Returns a pointer to the specified constraint.

Definition at line 667 of file physicsmanager.cpp.

int Mezzanine::PhysicsManager::GetDebugPhysicsRendering ( )

Is Physics Debug Drawing currently enabled?

lets you check if Physics Debug Drawing is enabled or not.

Returns:
1 for it is on, and 0 for it is not. The may be other options later for selectively cnacking certain features

Definition at line 909 of file physicsmanager.cpp.

Whole Mezzanine::PhysicsManager::GetDebugPhysicsWireCount ( )

This gets how many WireFrames are being drawn.

This will tell you how many frames worth of previous in game events are being drawn.

Returns:
This returns either 2 or the last amount passed into World::SetDebugPhysicsWireCount .

Definition at line 933 of file physicsmanager.cpp.

Vector3 Mezzanine::PhysicsManager::GetGravity ( )

Gets the gravity.

Gets the currently set world gravity.

Returns:
Returns the currently set world gravity.

Definition at line 635 of file physicsmanager.cpp.

Real Mezzanine::PhysicsManager::GetImpulse ( )

Gets the Collision Impulse limit.

Gets the Collision Impulse used in filtering out collision contacts used to make events.

Returns:
This function will return the lower limit of the allowed force of the collision to generate an event.

Definition at line 887 of file physicsmanager.cpp.

Whole Mezzanine::PhysicsManager::GetNumAreaEffects ( )

Gets the number of Area Effects currently in the world.

Returns:
Returns a whole representing the number of Area Effects in the world.

Definition at line 723 of file physicsmanager.cpp.

Whole Mezzanine::PhysicsManager::GetNumCollisions ( )

Gets the number of Collisions currently in the world.

Returns:
Returns a whole representing the number of Collisions in the world.

Definition at line 804 of file physicsmanager.cpp.

Whole Mezzanine::PhysicsManager::GetNumConstraints ( )

Gets the number of constraints currently in the world.

Returns:
Returns a whole representing the number of constraints in the world.

Definition at line 672 of file physicsmanager.cpp.

Whole Mezzanine::PhysicsManager::GetNumWorldTriggers ( )

Gets the number of triggers currently in the world.

Returns:
Returns a whole representing the number of triggers in the world.

Definition at line 773 of file physicsmanager.cpp.

Vector3 Mezzanine::PhysicsManager::GetSoftGravity ( )

Gets the soft body gravity.

Gets the currently set soft body world gravity.

Returns:
Returns the currently set soft body world gravity.

Definition at line 646 of file physicsmanager.cpp.

ManagerBase::ManagerTypeName Mezzanine::PhysicsManager::GetType ( ) const [virtual]

This returns the type of this manager.

This is intended to make using and casting from Manager base easier. With this is is possible to cast from ManagerBase to the correct Manager Type.

Returns:
This returns a ManagerTypeName to identify what this can be safely cast to.

Implements Mezzanine::ManagerBase.

Definition at line 1124 of file physicsmanager.cpp.

WorldTrigger * Mezzanine::PhysicsManager::GetWorldTrigger ( const String Name)

Gets a trigger by name.

Parameters:
NameThe name of the trigger to find.
Returns:
Returns a pointer to the named trigger, or NULL if it doesn't exist.

Definition at line 756 of file physicsmanager.cpp.

WorldTrigger * Mezzanine::PhysicsManager::GetWorldTrigger ( const Whole Index)

Gets a trigger by index.

Parameters:
IndexThe index of the trigger you want.
Returns:
Returns a pointer to the trigger at the specified index.

Definition at line 768 of file physicsmanager.cpp.

void Mezzanine::PhysicsManager::Initialize ( ) [virtual]

Configure Items requiring other Managers.

If you are using the Mezzanine::World this is called when Mezzanine::World::GameInit() is called. It is expected that by the time this is called either ManagerBase::ManagerBase(World*) or ManagerBase::SetGameWorld(World*) will have been called. This is where all configuration that requires atleast one other manager on the Mezzanine::World to exist.

Yes we know it is spelled wrong, but are Zs cooler anyway.

Implements Mezzanine::ManagerBase.

Definition at line 1114 of file physicsmanager.cpp.

void Mezzanine::PhysicsManager::PauseSimulation ( bool  Pause)

Pauses the simulation, preventing the physics world from taking action.

Parameters:
PauseWether or not to pause the simulation.

Definition at line 620 of file physicsmanager.cpp.

void Mezzanine::PhysicsManager::RemoveAreaEffect ( AreaEffect AE)

Removes an area effect from the world.

Removes an area effect from the world so that it will have no effect.

Parameters:
AEThe area effect to be removed.

Definition at line 728 of file physicsmanager.cpp.

void Mezzanine::PhysicsManager::RemoveCollision ( Collision Col)

Removes an existing collision from the world.

Remarks:
In general it's not a great idea to call on this manually, but there are some situations where you would. Mostly this function exists to facilitate removal of objects from the world before the simulation ends. In such cases you have to clean up traces of the collision.
Parameters:
ColThe collision to be removed.

Definition at line 809 of file physicsmanager.cpp.

void Mezzanine::PhysicsManager::RemoveCollisionsContainingObject ( WorldObject Object)

Removes all stored collisions that involve the specified Object.

Parameters:
ObjectThe Object which will have all of it's collisions removed.

Definition at line 823 of file physicsmanager.cpp.

void Mezzanine::PhysicsManager::RemoveConstraint ( TypedConstraint Constraint)

Removes a constraint from the world.

Removes a constraint from the world so that it will have no effect.

Parameters:
ConstraintThe constraint to be removed.

Definition at line 677 of file physicsmanager.cpp.

void Mezzanine::PhysicsManager::RemoveWorldTrigger ( WorldTrigger Trig)

Removes a trigger from the world.

Removes a trigger from the world so that it will have no effect.

Parameters:
TrigThe trigger to be removed.

Definition at line 778 of file physicsmanager.cpp.

void Mezzanine::PhysicsManager::ResetPhysicsWorld ( PhysicsConstructionInfo Info = 0)

Resets all the internal physics structures in this manager.

Warning:
This should only be called while the world is emtpy and objects have be unloaded from it.
Parameters:
InfoIf you want to change the configuration of the world when restarting, you can optionally provide a new set of parameters to build the world with.

Definition at line 941 of file physicsmanager.cpp.

void Mezzanine::PhysicsManager::SetCollisionParams ( const unsigned short int  Age,
Real  Force 
)

Sets the Collision Parameters.

Sets the Collision Age and Force Filters used in filtering out collision contacts used to make events. The lower these numbers, the more events will be generated.
These numbers both default to 1.

Parameters:
AgeThe number of physics ticks the collision has to have existed to be used. Usually you want 1 or 2. Default: 1
ForceThe amount of force applied in the collision to filter by. This amount can vary more then the other param based on what you need. Default: 1.0

Definition at line 876 of file physicsmanager.cpp.

void Mezzanine::PhysicsManager::SetDebugPhysicsRendering ( int  ToBeEnabled)

Enables and Disables Physics Debug Drawing.

Enables and Disables Physics Debug Drawing using default wireframes. This will force renderings that match the physics subsytem pixel for pixel.

Parameters:
ToBeEnabled1 to turn it on, 0 to turn it off. There may be other options in the future, to enable fine tuned control

Definition at line 893 of file physicsmanager.cpp.

void Mezzanine::PhysicsManager::SetDebugPhysicsWireCount ( Whole  WireFrameCount_)

How many Wireframes do you want drawn from previous events.

Each frame of the action gets its own wire frame, and how many of those back did you want to see? To see a minimal amount set this to 2, as the first wireframe is commonly entirely inside the the rendered 3d mesh. You can use World::GetTargetFrameTime() In conjunction with this to specify an amout of seconds worth of wireframes.

Parameters:
WireFrameCount_This is a whole number that is the amount of wire frames you wan to see. Don't forget to be mindful of the framerate, Any amount more than just a few seconds worth can be cumbersome.

Definition at line 922 of file physicsmanager.cpp.

void Mezzanine::PhysicsManager::SetGravity ( const Vector3 pgrav)

Sets the gravity.

Sets the strength and direction of gravity within the world.

Parameters:
pgravVector3 representing the strength and direction of gravity.

Definition at line 630 of file physicsmanager.cpp.

void Mezzanine::PhysicsManager::SetIndividualGravity ( ActorBase Actor,
const Vector3 igrav 
)

Sets the gravity to be applied to a single object.

This function does not change the global gravity, only how gravity behaves for this specific object. Note: This function only works on ActorRigid's.

Parameters:
ActorThe actor whos gravity is to be changed.
igravThe value of the gravity to be applied.

Definition at line 652 of file physicsmanager.cpp.

void Mezzanine::PhysicsManager::SetSimulationSubstepModifier ( const Whole Modifier)

Sets the modifier to be used when stepping the physics simulation.

Remarks:
For the most part, the simulation tick is determined by your target framerate set on Mezzanine::World. However there are some occasions when you will want to have it tick more often, in particular with sensative simulation setups involving many constraints, or small objects, or fast moving objects, or any combination of those. In order to make your simulation more stable you have to tick in smaller intervals, making it less likely for the engine to miss something or become unstable. When you pass in a modifier it'll ensure it ticks faster by that amount. For example, if you pass in 2 to this as the modifier, the physics simulation will take 2 smaller steps (the time being based on the target framerate) instead of one big one during the course of one frame.
Parameters:
ModifierThe amount of substeps per frame to perform.

Definition at line 990 of file physicsmanager.cpp.

void Mezzanine::PhysicsManager::SetSoftGravity ( const Vector3 sgrav)

Sets the gravity for soft bodies.

Gravity for soft bodies is stored separately from rigid bodies. So if you plan to use soft bodies in your game/simulation you need to call this function otherwise they won't fall.

Parameters:
sgravVector3 representing the strength and direction of gravity.

Definition at line 641 of file physicsmanager.cpp.

bool Mezzanine::PhysicsManager::SimulationIsPaused ( )

Gets Whether or not the simulation is currently paused.

Returns:
Returns whether or not the simulation is paused.

Definition at line 625 of file physicsmanager.cpp.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines