This class manages the traversal through the scene graph to detect collisions. More...
#include "collisionTraverser.h"
Public Member Functions | |
CollisionTraverser (const std::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. More... | |
void | clear_colliders () |
Completely empties the set of collision nodes and their associated handlers. More... | |
NodePath | get_collider (int n) const |
CollisionHandler * | 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. More... | |
int | get_num_colliders () const |
bool | get_respect_prev_transform () const |
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. More... | |
void | output (std::ostream &out) const |
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. More... | |
void | set_respect_prev_transform (bool flag) |
void | traverse (const NodePath &root) |
void | write (std::ostream &out, int indent_level) const |
Public Member Functions inherited from Namable | |
Namable (const std::string &initial_name="") | |
void | clear_name () |
Resets the Namable's name to empty. More... | |
const std::string & | get_name () const |
bool | has_name () const |
Returns true if the Namable has a nonempty name set, false if the name is empty. More... | |
void | output (std::ostream &out) const |
Outputs the Namable. More... | |
void | set_name (const std::string &name) |
Static Public Member Functions | |
static TypeHandle | get_class_type () |
static void | init_type () |
Static Public Member Functions inherited from Namable | |
static TypeHandle | get_class_type () |
static void | init_type () |
Public Attributes | |
get_collider | |
Returns the nth CollisionNode that has been added to the traverser via add_collider(). More... | |
get_num_colliders | |
Returns the number of CollisionNodes that have been added to the traverser via add_collider(). More... | |
get_respect_prev_transform | |
Returns the flag that indicates whether the prev_transform stored on a node is respected to calculate collisions. More... | |
set_respect_prev_transform | |
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. More... | |
Public Attributes inherited from Namable | |
get_name | |
set_name | |
Friends | |
class | SortByColliderSort |
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 45 of file collisionTraverser.h.
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 102 of file collisionTraverser.cxx.
void CollisionTraverser::clear_colliders | ( | ) |
Completely empties the set of collision nodes and their associated handlers.
Definition at line 244 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 231 of file collisionTraverser.cxx.
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 199 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 158 of file collisionTraverser.cxx.
NodePath CollisionTraverser::get_collider |
Returns the nth CollisionNode that has been added to the traverser via add_collider().
Definition at line 60 of file collisionTraverser.h.
int CollisionTraverser::get_num_colliders |
Returns the number of CollisionNodes that have been added to the traverser via add_collider().
Definition at line 60 of file collisionTraverser.h.
|
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 53 of file collisionTraverser.h.
|
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 53 of file collisionTraverser.h.