Panda3D
Classes | 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...

#include "collisionHandlerEvent.h"

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

Public Member Functions

 CollisionHandlerEvent ()
 The default CollisionHandlerEvent will throw no events. More...
 
void add_again_pattern (const std::string &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...
 
virtual void add_entry (CollisionEntry *entry)
 Called between a begin_group() . More...
 
void add_in_pattern (const std::string &in_pattern)
 Adds a pattern string to the list of events that will be generated in response to a collision. More...
 
void add_out_pattern (const std::string &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...
 
virtual void begin_group ()
 Will be called by the CollisionTraverser before a new traversal is begun. More...
 
void clear ()
 Empties the list of elements that all colliders are known to be colliding with. More...
 
void clear_again_patterns ()
 Removes all of the previously-added in patterns. More...
 
void clear_in_patterns ()
 Removes all of the previously-added in patterns. More...
 
void clear_out_patterns ()
 Removes all of the previously-added in patterns. More...
 
virtual bool end_group ()
 Called by the CollisionTraverser at the completion of all collision detections for this traversal. More...
 
void flush ()
 Same as clear() except "out" events are thrown. More...
 
virtual TypeHandle force_init_type ()
 
std::string get_again_pattern (int n) const
 
std::string get_in_pattern (int n) const
 
int get_num_again_patterns () const
 
int get_num_in_patterns () const
 
int get_num_out_patterns () const
 
std::string get_out_pattern (int n) const
 
virtual TypeHandle get_type () const
 
void set_again_pattern (const std::string &again_pattern)
 This method is deprecated; it completely replaces all the in patterns that have previously been set with the indicated pattern. More...
 
void set_in_pattern (const std::string &in_pattern)
 This method is deprecated; it completely replaces all the in patterns that have previously been set with the indicated pattern. More...
 
void set_out_pattern (const std::string &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
void set_root (const NodePath &root)
 Sets the root of the collision traversal. More...
 
bool wants_all_potential_collidees () const
 Returns true if handler wants to know about all solids that are within the collider's bounding volume. More...
 
- Public Member Functions inherited from TypedReferenceCount
 TypedReferenceCount (const TypedReferenceCount &copy)
 
void operator= (const TypedReferenceCount &copy)
 
- Public Member Functions inherited from TypedObject
 TypedObject (const TypedObject &copy)=default
 
TypedObjectas_typed_object ()
 Returns the object, upcast (if necessary) to a TypedObject pointer. More...
 
const TypedObjectas_typed_object () const
 Returns the object, upcast (if necessary) to a TypedObject pointer. More...
 
int get_best_parent_from_Set (const std::set< int > &) const
 
int get_type_index () const
 Returns the internal index number associated with this object's TypeHandle, a unique number for each different type. More...
 
bool is_exact_type (TypeHandle handle) const
 Returns true if the current object is the indicated type exactly. More...
 
bool is_of_type (TypeHandle handle) const
 Returns true if the current object is or derives from the indicated type. More...
 
TypedObjectoperator= (const TypedObject &copy)=default
 
- Public Member Functions inherited from ReferenceCount
int get_ref_count () const
 
WeakReferenceListget_weak_list () const
 Returns the WeakReferenceList associated with this ReferenceCount object. More...
 
bool has_weak_list () const
 Returns true if this particular ReferenceCount object has a WeakReferenceList created, false otherwise. More...
 
void local_object ()
 This function should be called, once, immediately after creating a new instance of some ReferenceCount-derived object on the stack. More...
 
void ref () const
 Explicitly increments the reference count. More...
 
bool ref_if_nonzero () const
 Atomically increases the reference count of this object if it is not zero. More...
 
bool test_ref_count_integrity () const
 Does some easy checks to make sure that the reference count isn't completely bogus. More...
 
bool test_ref_count_nonzero () const
 Does some easy checks to make sure that the reference count isn't zero, or completely bogus. More...
 
virtual bool unref () const
 Explicitly decrements the reference count. More...
 
WeakReferenceListweak_ref ()
 Adds the indicated PointerToVoid as a weak reference to this object. More...
 
void weak_unref ()
 Removes the indicated PointerToVoid as a weak reference to this object. More...
 

Static Public Member Functions

static TypeHandle get_class_type ()
 
static void init_type ()
 
- Static Public Member Functions inherited from CollisionHandler
static TypeHandle get_class_type ()
 
static void init_type ()
 
- Static Public Member Functions inherited from TypedReferenceCount
static TypeHandle get_class_type ()
 
static void init_type ()
 
- Static Public Member Functions inherited from TypedObject
static TypeHandle get_class_type ()
 
static void init_type ()
 This function is declared non-inline to work around a compiler bug in g++ 2.96. More...
 
- Static Public Member Functions inherited from ReferenceCount
static TypeHandle get_class_type ()
 
static void init_type ()
 

Public Attributes

 get_again_pattern
 Returns the nth pattern string that indicates how the event names are generated for each collision detected. More...
 
 get_in_pattern
 Returns the nth pattern string that indicates how the event names are generated for each collision detected. More...
 
 get_num_again_patterns
 Returns the number of in pattern strings that have been added. More...
 
 get_num_in_patterns
 Returns the number of in pattern strings that have been added. More...
 
 get_num_out_patterns
 Returns the number of in pattern strings that have been added. More...
 
 get_out_pattern
 Returns the nth pattern string that indicates how the event names are generated for each collision detected. More...
 
- Public Attributes inherited from TypedObject
 get_type
 
- Public Attributes inherited from ReferenceCount
 get_ref_count
 Returns 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.

Definition at line 32 of file collisionHandlerEvent.h.

Constructor & Destructor Documentation

◆ CollisionHandlerEvent()

CollisionHandlerEvent::CollisionHandlerEvent ( )

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

Definition at line 31 of file collisionHandlerEvent.cxx.

Member Function Documentation

◆ add_again_pattern()

void CollisionHandlerEvent::add_again_pattern ( const std::string &  again_pattern)
inline

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.

Definition at line 129 of file collisionHandlerEvent.I.

Referenced by set_again_pattern().

◆ add_entry()

void CollisionHandlerEvent::add_entry ( CollisionEntry entry)
virtual

Called between a begin_group() .

. end_group() sequence for each collision that is detected.

Reimplemented from CollisionHandler.

Reimplemented in CollisionHandlerHighestEvent, CollisionHandlerPhysical, and CollisionHandlerFluidPusher.

Definition at line 54 of file collisionHandlerEvent.cxx.

◆ add_in_pattern()

void CollisionHandlerEvent::add_in_pattern ( const std::string &  in_pattern)
inline

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.

Definition at line 76 of file collisionHandlerEvent.I.

Referenced by set_in_pattern().

◆ add_out_pattern()

void CollisionHandlerEvent::add_out_pattern ( const std::string &  out_pattern)
inline

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.

Definition at line 180 of file collisionHandlerEvent.I.

Referenced by set_out_pattern().

◆ begin_group()

void CollisionHandlerEvent::begin_group ( )
virtual

Will be called by the CollisionTraverser before a new traversal is begun.

It instructs the handler to reset itself in preparation for a number of CollisionEntries to be sent.

Reimplemented from CollisionHandler.

Reimplemented in CollisionHandlerHighestEvent, and CollisionHandlerPhysical.

Definition at line 40 of file collisionHandlerEvent.cxx.

Referenced by CollisionHandlerPhysical::begin_group(), and flush().

◆ clear()

void CollisionHandlerEvent::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.

Definition at line 142 of file collisionHandlerEvent.cxx.

◆ clear_again_patterns()

void CollisionHandlerEvent::clear_again_patterns ( )
inline

Removes all of the previously-added in patterns.

See add_again_pattern.

Definition at line 112 of file collisionHandlerEvent.I.

Referenced by set_again_pattern().

◆ clear_in_patterns()

void CollisionHandlerEvent::clear_in_patterns ( )
inline

Removes all of the previously-added in patterns.

See add_in_pattern.

Definition at line 41 of file collisionHandlerEvent.I.

Referenced by set_in_pattern().

◆ clear_out_patterns()

void CollisionHandlerEvent::clear_out_patterns ( )
inline

Removes all of the previously-added in patterns.

See add_out_pattern.

Definition at line 165 of file collisionHandlerEvent.I.

Referenced by set_out_pattern().

◆ end_group()

bool CollisionHandlerEvent::end_group ( )
virtual

Called by the CollisionTraverser at the completion of all collision detections for this traversal.

It should do whatever finalization is required for the handler.

Reimplemented from CollisionHandler.

Reimplemented in CollisionHandlerHighestEvent, and CollisionHandlerPhysical.

Definition at line 75 of file collisionHandlerEvent.cxx.

Referenced by CollisionHandlerPhysical::end_group(), CollisionHandlerHighestEvent::end_group(), and flush().

◆ flush()

void CollisionHandlerEvent::flush ( void  )

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

Definition at line 151 of file collisionHandlerEvent.cxx.

References begin_group(), and end_group().

◆ set_again_pattern()

void CollisionHandlerEvent::set_again_pattern ( const std::string &  again_pattern)
inline

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

Definition at line 138 of file collisionHandlerEvent.I.

References add_again_pattern(), and clear_again_patterns().

◆ set_in_pattern()

void CollisionHandlerEvent::set_in_pattern ( const std::string &  in_pattern)
inline

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

Definition at line 85 of file collisionHandlerEvent.I.

References add_in_pattern(), and clear_in_patterns().

◆ set_out_pattern()

void CollisionHandlerEvent::set_out_pattern ( const std::string &  out_pattern)
inline

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

Definition at line 189 of file collisionHandlerEvent.I.

References add_out_pattern(), and clear_out_patterns().

Member Data Documentation

◆ get_again_pattern

std::string CollisionHandlerEvent::get_again_pattern
inline

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

See add_again_pattern().

Definition at line 54 of file collisionHandlerEvent.h.

◆ get_in_pattern

std::string CollisionHandlerEvent::get_in_pattern
inline

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

See add_in_pattern().

Definition at line 47 of file collisionHandlerEvent.h.

◆ get_num_again_patterns

int CollisionHandlerEvent::get_num_again_patterns
inline

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

Definition at line 54 of file collisionHandlerEvent.h.

◆ get_num_in_patterns

int CollisionHandlerEvent::get_num_in_patterns
inline

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

Definition at line 47 of file collisionHandlerEvent.h.

◆ get_num_out_patterns

int CollisionHandlerEvent::get_num_out_patterns
inline

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

Definition at line 61 of file collisionHandlerEvent.h.

◆ get_out_pattern

std::string CollisionHandlerEvent::get_out_pattern
inline

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

See add_out_pattern().

Definition at line 61 of file collisionHandlerEvent.h.


The documentation for this class was generated from the following files: