Panda3D
Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
CollisionTraverser Class Reference

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

Inheritance diagram for CollisionTraverser:
Namable

Public Member Functions

 __init__ (const CollisionTraverser)
 
 __init__ (str name)
 
 addCollider (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...
 
 clearColliders ()
 Completely empties the set of collision nodes and their associated handlers. More...
 
 clearRecorder ()
 Removes the CollisionRecorder from the traverser and restores normal low- overhead operation. More...
 
NodePath getCollider (int n)
 Returns the nth CollisionNode that has been added to the traverser via add_collider(). More...
 
list getColliders ()
 
CollisionHandler getHandler (const NodePath collider)
 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 getNumColliders ()
 Returns the number of CollisionNodes that have been added to the traverser via add_collider(). More...
 
CollisionRecorder getRecorder ()
 Returns the CollisionRecorder currently assigned, or NULL if no recorder is assigned. More...
 
bool getRespectPrevTransform ()
 Returns the flag that indicates whether the prev_transform stored on a node is respected to calculate collisions. More...
 
bool hasCollider (const NodePath collider)
 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...
 
bool hasRecorder ()
 Returns true if the CollisionTraverser has a CollisionRecorder object currently assigned, false otherwise. More...
 
 hideCollisions ()
 Undoes the effect of a previous call to show_collisions(). More...
 
 output (Ostream out)
 
bool removeCollider (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...
 
 setRecorder (CollisionRecorder recorder)
 Uses the indicated CollisionRecorder object to start recording the intersection tests made by each subsequent call to traverse() on this object. More...
 
 setRespectPrevTransform (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. More...
 
CollisionVisualizer showCollisions (const NodePath root)
 This is a high-level function to create a CollisionVisualizer object to render the collision tests performed by this traverser. More...
 
 traverse (const NodePath root)
 
 write (Ostream out, int indent_level)
 
- Public Member Functions inherited from Namable
 __init__ (const Namable)
 
 __init__ (str initial_name)
 
 clearName ()
 Resets the Namable's name to empty. More...
 
str getName ()
 
bool hasName ()
 Returns true if the Namable has a nonempty name set, false if the name is empty. More...
 
 output (Ostream out)
 Outputs the Namable. More...
 
 setName (str name)
 

Static Public Member Functions

static TypeHandle getClassType ()
 
- Static Public Member Functions inherited from Namable
static TypeHandle getClassType ()
 

Public Attributes

NodePath colliders []
 
CollisionRecorder recorder
 Returns the CollisionRecorder currently assigned, or NULL if no recorder is assigned. More...
 
bool respect_preV_transform
 Returns the flag that indicates whether the prev_transform stored on a node is respected to calculate collisions. More...
 
- Public Attributes inherited from Namable
const String name
 

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.

Member Function Documentation

◆ __init__() [1/2]

__init__ ( const  CollisionTraverser)

◆ __init__() [2/2]

__init__ ( str  name)

◆ addCollider()

addCollider ( 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.

◆ clearColliders()

clearColliders ( )

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

◆ clearRecorder()

clearRecorder ( )

Removes the CollisionRecorder from the traverser and restores normal low- overhead operation.

◆ getClassType()

static TypeHandle getClassType ( )
static

◆ getCollider()

NodePath getCollider ( int  n)

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

◆ getColliders()

list getColliders ( )

◆ getHandler()

CollisionHandler getHandler ( const NodePath  collider)

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 getNumColliders ( )

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

◆ getRecorder()

CollisionRecorder getRecorder ( )

Returns the CollisionRecorder currently assigned, or NULL if no recorder is assigned.

◆ getRespectPrevTransform()

bool getRespectPrevTransform ( )

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 hasCollider ( const NodePath  collider)

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 hasRecorder ( )

Returns true if the CollisionTraverser has a CollisionRecorder object currently assigned, false otherwise.

◆ hideCollisions()

hideCollisions ( )

Undoes the effect of a previous call to show_collisions().

◆ output()

output ( Ostream  out)

◆ removeCollider()

bool removeCollider ( 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.

◆ setRecorder()

setRecorder ( CollisionRecorder  recorder)

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()

setRespectPrevTransform ( 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.

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 showCollisions ( const NodePath  root)

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()

traverse ( const NodePath  root)

◆ write()

write ( Ostream  out,
int  indent_level 
)

Member Data Documentation

◆ colliders

NodePath colliders[]

◆ recorder

Returns the CollisionRecorder currently assigned, or NULL if no recorder is assigned.

◆ respect_preV_transform

bool respect_preV_transform

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

See set_respect_prev_transform().