CollisionTraverser

from panda3d.core import CollisionTraverser
class CollisionTraverser

Bases: Namable

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 diagram

Inheritance diagram of CollisionTraverser

__init__(*args, **kwargs)
addCollider()

C++ Interface: add_collider(const CollisionTraverser self, 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.

*/

add_collider()

C++ Interface: add_collider(const CollisionTraverser self, 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()

C++ Interface: clear_colliders(const CollisionTraverser self)

/**
  • Completely empties the set of collision nodes and their associated

  • handlers.

*/

clearRecorder()

C++ Interface: clear_recorder(const CollisionTraverser self)

/**
  • Removes the CollisionRecorder from the traverser and restores normal low-

  • overhead operation.

*/

clear_colliders()

C++ Interface: clear_colliders(const CollisionTraverser self)

/**
  • Completely empties the set of collision nodes and their associated

  • handlers.

*/

clear_recorder()

C++ Interface: clear_recorder(const CollisionTraverser self)

/**
  • Removes the CollisionRecorder from the traverser and restores normal low-

  • overhead operation.

*/

colliders
getClassType()

C++ Interface: get_class_type()

getCollider()

C++ Interface: get_collider(CollisionTraverser self, int n)

/**
  • Returns the nth CollisionNode that has been added to the traverser via

  • add_collider().

*/

getColliders()
getHandler()

C++ Interface: get_handler(CollisionTraverser self, 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()

C++ Interface: get_num_colliders(CollisionTraverser self)

/**
  • Returns the number of CollisionNodes that have been added to the traverser

  • via add_collider().

*/

getRecorder()

C++ Interface: get_recorder(CollisionTraverser self)

/**
  • Returns the CollisionRecorder currently assigned, or NULL if no recorder is

  • assigned.

*/

getRespectPrevTransform()

C++ Interface: get_respect_prev_transform(CollisionTraverser self)

/**
  • Returns the flag that indicates whether the prev_transform stored on a node

  • is respected to calculate collisions. See set_respect_prev_transform().

*/

get_class_type()

C++ Interface: get_class_type()

get_collider()

C++ Interface: get_collider(CollisionTraverser self, int n)

/**
  • Returns the nth CollisionNode that has been added to the traverser via

  • add_collider().

*/

get_colliders()
get_handler()

C++ Interface: get_handler(CollisionTraverser self, 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.

*/

get_num_colliders()

C++ Interface: get_num_colliders(CollisionTraverser self)

/**
  • Returns the number of CollisionNodes that have been added to the traverser

  • via add_collider().

*/

get_recorder()

C++ Interface: get_recorder(CollisionTraverser self)

/**
  • Returns the CollisionRecorder currently assigned, or NULL if no recorder is

  • assigned.

*/

get_respect_prev_transform()

C++ Interface: get_respect_prev_transform(CollisionTraverser self)

/**
  • Returns the flag that indicates whether the prev_transform stored on a node

  • is respected to calculate collisions. See set_respect_prev_transform().

*/

hasCollider()

C++ Interface: has_collider(CollisionTraverser self, 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()

C++ Interface: has_recorder(CollisionTraverser self)

/**
  • Returns true if the CollisionTraverser has a CollisionRecorder object

  • currently assigned, false otherwise.

*/

has_collider()

C++ Interface: has_collider(CollisionTraverser self, 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.

*/

has_recorder()

C++ Interface: has_recorder(CollisionTraverser self)

/**
  • Returns true if the CollisionTraverser has a CollisionRecorder object

  • currently assigned, false otherwise.

*/

hideCollisions()

C++ Interface: hide_collisions(const CollisionTraverser self)

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

*/

hide_collisions()

C++ Interface: hide_collisions(const CollisionTraverser self)

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

*/

output()

C++ Interface: output(CollisionTraverser self, ostream out)

/**

*/

recorder
removeCollider()

C++ Interface: remove_collider(const CollisionTraverser self, 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.

*/

remove_collider()

C++ Interface: remove_collider(const CollisionTraverser self, 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.

*/

respect_prev_transform
setRecorder()

C++ Interface: set_recorder(const CollisionTraverser self, 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()

C++ Interface: set_respect_prev_transform(const CollisionTraverser self, 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.

*/

set_recorder()

C++ Interface: set_recorder(const CollisionTraverser self, 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.

*/

set_respect_prev_transform()

C++ Interface: set_respect_prev_transform(const CollisionTraverser self, 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()

C++ Interface: show_collisions(const CollisionTraverser self, 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.

*/

show_collisions()

C++ Interface: show_collisions(const CollisionTraverser self, 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()

C++ Interface: traverse(const CollisionTraverser self, const NodePath root)

/**
  • Perform the traversal. 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.

*/

write()

C++ Interface: write(CollisionTraverser self, ostream out, int indent_level)

/**

*/