Panda3D
Classes | Public Member Functions | Static Public Member Functions | Friends

CollisionTraverser Class Reference

This class manages the traversal through the scene graph to detect collisions. More...

#include "collisionTraverser.h"

Inheritance diagram for CollisionTraverser:
Namable MemoryBase

List of all members.

Classes

class  OrderedColliderDef

Public Member Functions

 CollisionTraverser (const string &name="ctrav")
void add_collider (const NodePath &collider, CollisionHandler *handler)
 Adds a new CollisionNode, representing an object that will be tested for collisions into other objects, along with the handler that will serve each detected collision.
void clear_colliders ()
 Completely empties the set of collision nodes and their associated handlers.
NodePath get_collider (int n) const
 Returns the nth CollisionNode that has been added to the traverser via add_collider().
CollisionHandlerget_handler (const NodePath &collider) const
 Returns the handler that is currently assigned to serve the indicated collision node, or NULL if the node is not on the traverser's set of active nodes.
int get_num_colliders () const
 Returns the number of CollisionNodes that have been added to the traverser via add_collider().
bool get_respect_prev_transform () const
 Returns the flag that indicates whether the prev_transform stored on a node is respected to calculate collisions.
bool has_collider (const NodePath &collider) const
 Returns true if the indicated node is current in the set of nodes that will be tested each frame for collisions into other objects.
 MAKE_SEQ (get_colliders, get_num_colliders, get_collider)
void output (ostream &out) const
 Outputs the Namable.
bool remove_collider (const NodePath &collider)
 Removes the collider (and its associated handler) from the set of CollisionNodes that will be tested each frame for collisions into other objects.
void set_respect_prev_transform (bool flag)
 Sets the flag that indicates whether the prev_transform stored on a node (as updated via set_fluid_pos(), etc.) is respected to calculate collisions.
void traverse (const NodePath &root)
void write (ostream &out, int indent_level) const

Static Public Member Functions

static TypeHandle get_class_type ()
static void init_type ()

Friends

class SortByColliderSort

Detailed Description

This class manages the traversal through the scene graph to detect collisions.

It holds ownership of a number of collider objects, each of which is a CollisionNode and an associated CollisionHandler.

When traverse() is called, it begins at the indicated root and detects all collisions with any of its collider objects against nodes at or below the indicated root, calling the appropriate CollisionHandler for each detected collision.

Definition at line 49 of file collisionTraverser.h.


Member Function Documentation

void CollisionTraverser::add_collider ( const NodePath collider,
CollisionHandler handler 
)

Adds a new CollisionNode, representing an object that will be tested for collisions into other objects, along with the handler that will serve each detected collision.

Each CollisionNode may be served by only one handler at a time, but a given handler may serve many CollisionNodes.

The handler that serves a particular node may be changed from time to time by calling add_collider() again on the same node.

Definition at line 110 of file collisionTraverser.cxx.

References PandaNode::is_collision_node(), NodePath::is_empty(), and NodePath::node().

void CollisionTraverser::clear_colliders ( )

Completely empties the set of collision nodes and their associated handlers.

Definition at line 266 of file collisionTraverser.cxx.

NodePath CollisionTraverser::get_collider ( int  n) const

Returns the nth CollisionNode that has been added to the traverser via add_collider().

Definition at line 237 of file collisionTraverser.cxx.

CollisionHandler * CollisionTraverser::get_handler ( const NodePath collider) const

Returns the handler that is currently assigned to serve the indicated collision node, or NULL if the node is not on the traverser's set of active nodes.

Definition at line 251 of file collisionTraverser.cxx.

int CollisionTraverser::get_num_colliders ( ) const

Returns the number of CollisionNodes that have been added to the traverser via add_collider().

Definition at line 225 of file collisionTraverser.cxx.

Referenced by CollisionLevelState< MaskType >::any_in_bounds(), and CollisionLevelState< MaskType >::apply_transform().

bool CollisionTraverser::get_respect_prev_transform ( ) const [inline]

Returns the flag that indicates whether the prev_transform stored on a node is respected to calculate collisions.

See set_respect_prev_transform().

Definition at line 42 of file collisionTraverser.I.

bool CollisionTraverser::has_collider ( const NodePath collider) const

Returns true if the indicated node is current in the set of nodes that will be tested each frame for collisions into other objects.

Definition at line 213 of file collisionTraverser.cxx.

Referenced by CollisionLevelState< MaskType >::any_in_bounds(), and CollisionLevelState< MaskType >::apply_transform().

void CollisionTraverser::output ( ostream &  out) const

Outputs the Namable.

This function simply writes the name to the output stream; most Namable derivatives will probably redefine this.

Reimplemented from Namable.

Definition at line 465 of file collisionTraverser.cxx.

bool CollisionTraverser::remove_collider ( const NodePath collider)

Removes the collider (and its associated handler) from the set of CollisionNodes that will be tested each frame for collisions into other objects.

Returns true if the definition was found and removed, false if it wasn't present to begin with.

Definition at line 169 of file collisionTraverser.cxx.

void CollisionTraverser::set_respect_prev_transform ( bool  flag) [inline]

Sets the flag that indicates whether the prev_transform stored on a node (as updated via set_fluid_pos(), etc.) is respected to calculate collisions.

If this is true, certain types of collision tests will be enhanced by the information about objects in motion. If this is false, objects are always considered to be static. The default is false.

Definition at line 29 of file collisionTraverser.I.


The documentation for this class was generated from the following files:
 All Classes Functions Variables Enumerations