# CollisionTraverser

from pandac.PandaModules import CollisionTraverser

Class : CollisionTraverser
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.

## Inheritance:

CollisionTraverser: Namable
Namable:

## Methods of CollisionTraverser:

addCollider
clearColliders
clearRecorder
getCollider
getHandler
getNumColliders
getRecorder
getRespectPrevTransform
hasCollider
hasRecorder
hideCollisions
output
removeCollider
resetPrevTransform
setRecorder
setRespectPrevTransform
showCollisions
traverse
write

## Methods of Namable:

clearName
getClassType
getName
hasName
operator =
output
setName

addCollider void CollisionTraverser::add_collider(NodePath const &collider, CollisionHandler *handler); Description: 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.

clearColliders void CollisionTraverser::clear_colliders(void); Description: Completely empties the set of collision nodes and their associated handlers.

clearRecorder void CollisionTraverser::clear_recorder(void); Description: Removes the CollisionRecorder from the traverser and restores normal low-overhead operation.

getCollider NodePath CollisionTraverser::get_collider(int n) const; Description: Returns the nth CollisionNode that has been added to the traverser via add_collider().

getHandler CollisionHandler *CollisionTraverser::get_handler(NodePath const &collider) const; Description: 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.

getNumColliders int CollisionTraverser::get_num_colliders(void) const; Description: Returns the number of CollisionNodes that have been added to the traverser via add_collider().

getRecorder CollisionRecorder *CollisionTraverser::get_recorder(void) const; Description: Returns the CollisionRecorder currently assigned, or NULL if no recorder is assigned.

getRespectPrevTransform bool CollisionTraverser::get_respect_prev_transform(void) const; Description: Returns the flag that indicates whether the prev_transform stored on a node is respected to calculate collisions. See set_respect_prev_transform().

hasCollider bool CollisionTraverser::has_collider(NodePath const &collider) const; Description: Returns true if the indicated node is current in the set of nodes that will be tested each frame for collisions into other objects.

hasRecorder bool CollisionTraverser::has_recorder(void) const; Description: Returns true if the CollisionTraverser has a CollisionRecorder object currently assigned, false otherwise.

hideCollisions void CollisionTraverser::hide_collisions(void); Description: Undoes the effect of a previous call to show_collisions().

output void CollisionTraverser::output(ostream &out) const; DO_COLLISION_RECORDING Description:

removeCollider bool CollisionTraverser::remove_collider(NodePath const &collider); Description: 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.

resetPrevTransform void CollisionTraverser::reset_prev_transform(NodePath const &root); Description: Once the collision traversal has finished, resets all of the velocity deltas in the scene graph by setting the "previous" transform to the current transform. This must be called at least once per frame for collisions to respect this velocity setting properly.

setRecorder void CollisionTraverser::set_recorder(CollisionRecorder *recorder); Description: Uses the indicated CollisionRecorder object to start recording the intersection tests made by each subsequent call to traverse() on this object. A particular CollisionRecorder object can only record one traverser at a time; if this object has already been assigned to another traverser, that assignment is broken. This is intended to be used in a debugging mode to try to determine what work is being performed by the collision traversal. Usually, attaching a recorder will impose significant runtime overhead. This does not transfer ownership of the CollisionRecorder pointer; maintenance of that remains the caller's responsibility. If the CollisionRecorder is destructed, it will cleanly remove itself from the traverser.

setRespectPrevTransform void CollisionTraverser::set_respect_prev_transform(bool flag); Filename: collisionTraverser.I Created by: drose (16Mar02) PANDA 3D SOFTWARE Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved All use of this software is subject to the terms of the Panda 3d Software license. You should have received a copy of this license along with this source code; you will also find a current copy of the license at http://etc.cmu.edu/panda3d/docs/license/ . To contact the maintainers of this program write to panda3d-general@lists.sourceforge.net . Description: 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.

showCollisions CollisionVisualizer *CollisionTraverser::show_collisions(NodePath const &root); Description: This is a high-level function to create a CollisionVisualizer object to render the collision tests performed by this traverser. The supplied root should be any node in the scene graph; typically, the top node (e.g. render). The CollisionVisualizer will be attached to this node.

traverse void CollisionTraverser::traverse(NodePath const &root); Description:

write void CollisionTraverser::write(ostream &out, int indent_level) const; Description:

clearName void Namable::clear_name(void); Description: Resets the Namable's name to empty.

getClassType static TypeHandle Namable::get_class_type(void); Undocumented function.

getName string const &Namable::get_name(void) const; Description:

hasName bool Namable::has_name(void) const; Description: Returns true if the Namable has a nonempty name set, false if the name is empty.

operator = Namable &Namable::operator =(Namable const &other); Description:

output void Namable::output(ostream &out) const; In the absence of any definition to the contrary, outputting a Namable will write out its name. Description: Outputs the Namable. This function simply writes the name to the output stream; most Namable derivatives will probably redefine this.

setName void Namable::set_name(string const &name); Description: