Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

oxygen::CollisionHandler Class Reference

interface for handlers that take action in response to a collision. More...

#include <collisionhandler.h>

Inheritance diagram for oxygen::CollisionHandler:

Inheritance graph
[legend]
Collaboration diagram for oxygen::CollisionHandler:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 CollisionHandler ()
virtual ~CollisionHandler ()
virtual void HandleCollision (boost::shared_ptr< Collider > collidee, dContact &contact)=0
 HandleCollision is called from the Collider to which this CollisionHandler is registered to.
virtual bool IsSymmetricHandler ()
 returns true if a class of CollisionHandlers wants to handle both- a collision and it's symmetric counterpart.

Protected Member Functions

virtual void OnLink ()
 This method is called, when the hierarchy object has been linked to a parent.
virtual void OnUnlink ()
 This rountine is called, before the hierarchy object is removed from the parent.

Protected Attributes

boost::shared_ptr< CollidermCollider
 the collider this CollisionHandler is associated with
boost::shared_ptr< WorldmWorld
 the world this CollisionHandler is associated with
boost::shared_ptr< SpacemSpace
 the space this CollisionHandler is associated with

Detailed Description

interface for handlers that take action in response to a collision.

To each Collider instance one ore more CollisionHandlers are registered. When the collision system detects a collision between two geoms the HandleCollision() method of each registered CollisionHandler is called. An example implementation is the derived ContactJoint class that constructs an ODE contact joint, covering the most common response to a collision.

Definition at line 43 of file collisionhandler.h.


Constructor & Destructor Documentation

oxygen::CollisionHandler::CollisionHandler  )  [inline]
 

Definition at line 49 of file collisionhandler.h.

virtual oxygen::CollisionHandler::~CollisionHandler  )  [inline, virtual]
 

Definition at line 50 of file collisionhandler.h.


Member Function Documentation

virtual void oxygen::CollisionHandler::HandleCollision boost::shared_ptr< Collider collidee,
dContact &  contact
[pure virtual]
 

HandleCollision is called from the Collider to which this CollisionHandler is registered to.

Derived classes implement this callback to react in response to a collision.

Parameters:
collidee is the geom ID of the colliders collision partner
holds the contact points between the two affected geoms as returned from the ODE dCollide function

Implemented in oxygen::ContactJointHandler, oxygen::RecorderHandler, and PerceptorHandler.

virtual bool oxygen::CollisionHandler::IsSymmetricHandler  )  [inline, virtual]
 

returns true if a class of CollisionHandlers wants to handle both- a collision and it's symmetric counterpart.

ODE reports us the set of colliding geoms, for example {(a,b),(b,c)} for two collisions between three involved geoms a,b and c. For each collision two symmetric pairs exist, for example (a,b) and (b,a). ODE consideres both equal and only reports one of them.

For the first pair (a,b) of the example above the CollisionHandlers of a are notified about the collision with b. In the symmetric case (b,a) the CollisionHandlers of b are notified about the collision with a.

For some CollisionHandler, e.g. the ContactJointHandler this behaviour is fine, as it is required to create exactly one contact joint between the two colliding geoms. This can be done by either one of the two involved CollisionHandlers. Therefore the ContactJointHandler is not a symmetric handler.

For other CollisionHandlers, e.g. the CollisionRecorder this behaviour does not suffice and both CollisionHandlers must be notified if a collision occurs as both involved colliders want to record a collision as it happens. In any case the collision should be reported to both CollisionHandlers. The CollisionRecorder therefore is a symmetric handler.

The default implementation returns true to indicate a symmetric handler.

Reimplemented in oxygen::ContactJointHandler.

Definition at line 96 of file collisionhandler.h.

void CollisionHandler::OnLink  )  [protected, virtual]
 

This method is called, when the hierarchy object has been linked to a parent.

At that point, traversal can commence. It can be overridden to support custom 'link' behavior.

Reimplemented from zeitgeist::Leaf.

Definition at line 33 of file collisionhandler.cpp.

References zeitgeist::Object::GetLog(), zeitgeist::Leaf::GetParent(), oxygen::BaseNode::GetScene(), mCollider, mSpace, and mWorld.

Here is the call graph for this function:

void CollisionHandler::OnUnlink  )  [protected, virtual]
 

This rountine is called, before the hierarchy object is removed from the parent.

It can be overridden to support custom 'unlink' behavior.

Reimplemented from zeitgeist::Leaf.

Definition at line 61 of file collisionhandler.cpp.

References mCollider, mSpace, and mWorld.


Member Data Documentation

boost::shared_ptr<Collider> oxygen::CollisionHandler::mCollider [protected]
 

the collider this CollisionHandler is associated with

Definition at line 107 of file collisionhandler.h.

Referenced by OnLink(), and OnUnlink().

boost::shared_ptr<Space> oxygen::CollisionHandler::mSpace [protected]
 

the space this CollisionHandler is associated with

Definition at line 113 of file collisionhandler.h.

Referenced by OnLink(), and OnUnlink().

boost::shared_ptr<World> oxygen::CollisionHandler::mWorld [protected]
 

the world this CollisionHandler is associated with

Definition at line 110 of file collisionhandler.h.

Referenced by OnLink(), and OnUnlink().


The documentation for this class was generated from the following files:
Generated on Thu Apr 6 15:45:29 2006 for rcssserver3d by  doxygen 1.4.4