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

A specialized kind of CollisionHandler that throws an event for each collision detected. More...

Inheritance diagram for CollisionHandlerEvent:
CollisionHandler TypedReferenceCount TypedObject ReferenceCount CollisionHandlerHighestEvent CollisionHandlerPhysical CollisionHandlerFloor CollisionHandlerGravity CollisionHandlerPusher CollisionHandlerFluidPusher PhysicsCollisionHandler

Public Member Functions

 __init__ ()
 The default CollisionHandlerEvent will throw no events. More...
 
 __init__ (const CollisionHandlerEvent)
 
 addAgainPattern (str again_pattern)
 Adds the pattern string that indicates how the event names are generated when a collision between two particular nodes is still detected. More...
 
 addInPattern (str in_pattern)
 Adds a pattern string to the list of events that will be generated in response to a collision. More...
 
 addOutPattern (str out_pattern)
 Adds the pattern string that indicates how the event names are generated when a collision between two particular nodes is no longer detected. More...
 
 clear ()
 Empties the list of elements that all colliders are known to be colliding with. More...
 
 clearAgainPatterns ()
 Removes all of the previously-added in patterns. More...
 
 clearInPatterns ()
 Removes all of the previously-added in patterns. More...
 
 clearOutPatterns ()
 Removes all of the previously-added in patterns. More...
 
 flush ()
 Same as clear() except "out" events are thrown. More...
 
str getAgainPattern (int n)
 Returns the nth pattern string that indicates how the event names are generated for each collision detected. More...
 
list getAgainPatterns ()
 
str getInPattern (int n)
 Returns the nth pattern string that indicates how the event names are generated for each collision detected. More...
 
list getInPatterns ()
 
int getNumAgainPatterns ()
 Returns the number of in pattern strings that have been added. More...
 
int getNumInPatterns ()
 Returns the number of in pattern strings that have been added. More...
 
int getNumOutPatterns ()
 Returns the number of in pattern strings that have been added. More...
 
str getOutPattern (int n)
 Returns the nth pattern string that indicates how the event names are generated for each collision detected. More...
 
list getOutPatterns ()
 
 setAgainPattern (str again_pattern)
 This method is deprecated; it completely replaces all the in patterns that have previously been set with the indicated pattern. More...
 
 setInPattern (str in_pattern)
 This method is deprecated; it completely replaces all the in patterns that have previously been set with the indicated pattern. More...
 
 setOutPattern (str out_pattern)
 This method is deprecated; it completely replaces all the in patterns that have previously been set with the indicated pattern. More...
 
- Public Member Functions inherited from CollisionHandler
 __init__ (const CollisionHandler)
 
- Public Member Functions inherited from TypedObject
TypeHandle getType ()
 
int getTypeIndex ()
 Returns the internal index number associated with this object's TypeHandle, a unique number for each different type. More...
 
bool isExactType (TypeHandle handle)
 Returns true if the current object is the indicated type exactly. More...
 
bool isOfType (TypeHandle handle)
 Returns true if the current object is or derives from the indicated type. More...
 
- Public Member Functions inherited from ReferenceCount
int getRefCount ()
 Returns the current reference count. More...
 
 ref ()
 Explicitly increments the reference count. More...
 
bool testRefCountIntegrity ()
 Does some easy checks to make sure that the reference count isn't completely bogus. More...
 
bool testRefCountNonzero ()
 Does some easy checks to make sure that the reference count isn't zero, or completely bogus. More...
 
bool unref ()
 Explicitly decrements the reference count. More...
 

Static Public Member Functions

static TypeHandle getClassType ()
 
- Static Public Member Functions inherited from CollisionHandler
static TypeHandle getClassType ()
 
- Static Public Member Functions inherited from TypedReferenceCount
static TypeHandle getClassType ()
 
- Static Public Member Functions inherited from TypedObject
static TypeHandle getClassType ()
 
- Static Public Member Functions inherited from ReferenceCount
static TypeHandle getClassType ()
 

Public Attributes

String again_patterns []
 
String in_patterns []
 
String out_patterns []
 
- Public Attributes inherited from TypedObject
TypeHandle type
 Returns the TypeHandle representing this object's type. More...
 
- Public Attributes inherited from ReferenceCount
int ref_count
 The current reference count. More...
 

Detailed Description

A specialized kind of CollisionHandler that throws an event for each collision detected.

The event thrown may be based on the name of the moving object or the struck object, or both. The first parameter of the event will be a pointer to the CollisionEntry that triggered it.

Member Function Documentation

◆ __init__() [1/2]

__init__ ( )

The default CollisionHandlerEvent will throw no events.

Its pattern strings must first be set via a call to add_in_pattern() and/or add_out_pattern().

◆ __init__() [2/2]

__init__ ( const  CollisionHandlerEvent)

◆ addAgainPattern()

addAgainPattern ( str  again_pattern)

Adds the pattern string that indicates how the event names are generated when a collision between two particular nodes is still detected.

This event is thrown each consecutive time a collision between two particular nodes is detected, starting with the second time.

In general, the in_pattern event is thrown on the first detection of a collision between two particular nodes. In subsequent passes, as long as a collision between those two nodes continues to be detected each frame, the again_pattern is thrown. The first frame in which the collision is no longer detected, the out_pattern event is thrown.

◆ addInPattern()

addInPattern ( str  in_pattern)

Adds a pattern string to the list of events that will be generated in response to a collision.

The pattern string describes how the event name will be composed. It is a string that may contain any of the following:

fn - the name of the "from" object's node in - the name of the "into" object's node fs - 't' if "from" is tangible, 'i' if intangible is - 't' if "into" is tangible, 'i' if intangible ig - 'c' if the collision is into a CollisionNode, 'g' if it is a geom.

%(tag)fh - generate event only if "from" node has the indicated net tag. %(tag)fx - generate event only if "from" node does not have the indicated net tag. %(tag)ih - generate event only if "into" node has the indicated net tag. %(tag)ix - generate event only if "into" node does not have the indicated net tag. %(tag)ft - the indicated net tag value of the "from" node. %(tag)it - the indicated net tag value of the "into" node.

Parentheses in the above are literal and should be included in the actual pattern.

The event name will be based on the in_pattern string specified here, with all occurrences of the above strings replaced with the corresponding values.

In general, the in_pattern event is thrown on the first detection of a collision between two particular nodes. In subsequent passes, as long as a collision between those two nodes continues to be detected each frame, the again_pattern is thrown. The first frame in which the collision is no longer detected, the out_pattern event is thrown.

◆ addOutPattern()

addOutPattern ( str  out_pattern)

Adds the pattern string that indicates how the event names are generated when a collision between two particular nodes is no longer detected.

In general, the in_pattern event is thrown on the first detection of a collision between two particular nodes. In subsequent passes, as long as a collision between those two nodes continues to be detected each frame, the again_pattern is thrown. The first frame in which the collision is no longer detected, the out_pattern event is thrown.

◆ clear()

clear ( )

Empties the list of elements that all colliders are known to be colliding with.

No "out" events will be thrown; if the same collision is detected next frame, a new "in" event will be thrown for each collision.

This can be called each frame to defeat the persistent "in" event mechanism, which prevents the same "in" event from being thrown repeatedly. However, also see add_again_pattern(), which can be used to set the event that is thrown when a collision is detected for two or more consecutive frames.

◆ clearAgainPatterns()

clearAgainPatterns ( )

Removes all of the previously-added in patterns.

See add_again_pattern.

◆ clearInPatterns()

clearInPatterns ( )

Removes all of the previously-added in patterns.

See add_in_pattern.

◆ clearOutPatterns()

clearOutPatterns ( )

Removes all of the previously-added in patterns.

See add_out_pattern.

◆ flush()

flush ( )

Same as clear() except "out" events are thrown.

◆ getAgainPattern()

str getAgainPattern ( int  n)

Returns the nth pattern string that indicates how the event names are generated for each collision detected.

See add_again_pattern().

◆ getAgainPatterns()

list getAgainPatterns ( )

◆ getClassType()

static TypeHandle getClassType ( )
static

◆ getInPattern()

str getInPattern ( int  n)

Returns the nth pattern string that indicates how the event names are generated for each collision detected.

See add_in_pattern().

◆ getInPatterns()

list getInPatterns ( )

◆ getNumAgainPatterns()

int getNumAgainPatterns ( )

Returns the number of in pattern strings that have been added.

◆ getNumInPatterns()

int getNumInPatterns ( )

Returns the number of in pattern strings that have been added.

◆ getNumOutPatterns()

int getNumOutPatterns ( )

Returns the number of in pattern strings that have been added.

◆ getOutPattern()

str getOutPattern ( int  n)

Returns the nth pattern string that indicates how the event names are generated for each collision detected.

See add_out_pattern().

◆ getOutPatterns()

list getOutPatterns ( )

◆ setAgainPattern()

setAgainPattern ( str  again_pattern)

This method is deprecated; it completely replaces all the in patterns that have previously been set with the indicated pattern.

◆ setInPattern()

setInPattern ( str  in_pattern)

This method is deprecated; it completely replaces all the in patterns that have previously been set with the indicated pattern.

◆ setOutPattern()

setOutPattern ( str  out_pattern)

This method is deprecated; it completely replaces all the in patterns that have previously been set with the indicated pattern.

Member Data Documentation

◆ again_patterns

String again_patterns[]

◆ in_patterns

String in_patterns[]

◆ out_patterns

String out_patterns[]