|
|
@@ -49,12 +49,23 @@ operator = (const CollisionHandlerEvent::SortEntries &) {
|
|
|
}
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
|
-// Function: CollisionHandlerEvent::set_in_pattern
|
|
|
+// Function: CollisionHandlerEvent::clear_in_patterns
|
|
|
+// Access: Public
|
|
|
+// Description: Removes all of the previously-added in patterns. See
|
|
|
+// add_in_pattern.
|
|
|
+////////////////////////////////////////////////////////////////////
|
|
|
+INLINE void CollisionHandlerEvent::
|
|
|
+clear_in_patterns() {
|
|
|
+ _in_patterns.clear();
|
|
|
+}
|
|
|
+
|
|
|
+////////////////////////////////////////////////////////////////////
|
|
|
+// Function: CollisionHandlerEvent::add_in_pattern
|
|
|
// Access: Public
|
|
|
-// Description: Sets the pattern string that indicates how the event
|
|
|
-// names are generated for each collision detected.
|
|
|
-// This is a string that may contain any of the
|
|
|
-// following:
|
|
|
+// Description: 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
|
|
|
@@ -63,15 +74,16 @@ operator = (const CollisionHandlerEvent::SortEntries &) {
|
|
|
// %ig - 'c' if the collision is into a
|
|
|
// CollisionNode, 'g' if it is a geom.
|
|
|
//
|
|
|
-// %(tag)fh - '1' if "from" has the indicated tag,
|
|
|
-// '0' if it does not.
|
|
|
-// %(tag)ih - '1' if "into" has the indicated tag,
|
|
|
-// '0' if it does not.
|
|
|
-// %(tag)iH - '1' if "into" has the indicated net tag,
|
|
|
-// '0' if it does not.
|
|
|
+// %(tag)fh - generate event only if "from" node has
|
|
|
+// the indicated tag.
|
|
|
+// %(tag)fx - generate event only if "from" node does
|
|
|
+// not have the indicated 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 tag value of the "from" node.
|
|
|
-// %(tag)it - the indicated tag value of the "to" node.
|
|
|
-// %(tag)iT - the indicated net tag value of the "to" 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.
|
|
|
@@ -89,26 +101,62 @@ operator = (const CollisionHandlerEvent::SortEntries &) {
|
|
|
// out_pattern event is thrown.
|
|
|
////////////////////////////////////////////////////////////////////
|
|
|
INLINE void CollisionHandlerEvent::
|
|
|
+add_in_pattern(const string &in_pattern) {
|
|
|
+ _in_patterns.push_back(in_pattern);
|
|
|
+}
|
|
|
+
|
|
|
+////////////////////////////////////////////////////////////////////
|
|
|
+// Function: CollisionHandlerEvent::set_in_pattern
|
|
|
+// Access: Public
|
|
|
+// Description: This method is deprecated; it completely replaces all
|
|
|
+// the in patterns that have previously been set with
|
|
|
+// the indicated pattern.
|
|
|
+////////////////////////////////////////////////////////////////////
|
|
|
+INLINE void CollisionHandlerEvent::
|
|
|
set_in_pattern(const string &in_pattern) {
|
|
|
- _in_pattern = in_pattern;
|
|
|
+ clear_in_patterns();
|
|
|
+ add_in_pattern(in_pattern);
|
|
|
+}
|
|
|
+
|
|
|
+////////////////////////////////////////////////////////////////////
|
|
|
+// Function: CollisionHandlerEvent::get_num_in_patterns
|
|
|
+// Access: Public
|
|
|
+// Description: Returns the number of in pattern strings that have
|
|
|
+// been added.
|
|
|
+////////////////////////////////////////////////////////////////////
|
|
|
+INLINE int CollisionHandlerEvent::
|
|
|
+get_num_in_patterns() const {
|
|
|
+ return _in_patterns.size();
|
|
|
}
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
|
// Function: CollisionHandlerEvent::get_in_pattern
|
|
|
// Access: Public
|
|
|
-// Description: Returns the pattern string that indicates how the
|
|
|
+// Description: Returns the nth pattern string that indicates how the
|
|
|
// event names are generated for each collision
|
|
|
-// detected. See set_in_pattern().
|
|
|
+// detected. See add_in_pattern().
|
|
|
////////////////////////////////////////////////////////////////////
|
|
|
INLINE string CollisionHandlerEvent::
|
|
|
-get_in_pattern() const {
|
|
|
- return _in_pattern;
|
|
|
+get_in_pattern(int n) const {
|
|
|
+ nassertr(n >= 0 && n < (int)_in_patterns.size(), string());
|
|
|
+ return _in_patterns[n];
|
|
|
}
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
|
-// Function: CollisionHandlerEvent::set_again_pattern
|
|
|
+// Function: CollisionHandlerEvent::clear_again_patterns
|
|
|
// Access: Public
|
|
|
-// Description: Sets the pattern string that indicates how the event
|
|
|
+// Description: Removes all of the previously-added in patterns. See
|
|
|
+// add_again_pattern.
|
|
|
+////////////////////////////////////////////////////////////////////
|
|
|
+INLINE void CollisionHandlerEvent::
|
|
|
+clear_again_patterns() {
|
|
|
+ _again_patterns.clear();
|
|
|
+}
|
|
|
+
|
|
|
+////////////////////////////////////////////////////////////////////
|
|
|
+// Function: CollisionHandlerEvent::add_again_pattern
|
|
|
+// Access: Public
|
|
|
+// Description: 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
|
|
|
@@ -124,28 +172,62 @@ get_in_pattern() const {
|
|
|
// out_pattern event is thrown.
|
|
|
////////////////////////////////////////////////////////////////////
|
|
|
INLINE void CollisionHandlerEvent::
|
|
|
+add_again_pattern(const string &again_pattern) {
|
|
|
+ _again_patterns.push_back(again_pattern);
|
|
|
+}
|
|
|
+
|
|
|
+////////////////////////////////////////////////////////////////////
|
|
|
+// Function: CollisionHandlerEvent::set_again_pattern
|
|
|
+// Access: Public
|
|
|
+// Description: This method is deprecated; it completely replaces all
|
|
|
+// the in patterns that have previously been set with
|
|
|
+// the indicated pattern.
|
|
|
+////////////////////////////////////////////////////////////////////
|
|
|
+INLINE void CollisionHandlerEvent::
|
|
|
set_again_pattern(const string &again_pattern) {
|
|
|
- _again_pattern = again_pattern;
|
|
|
+ clear_again_patterns();
|
|
|
+ add_again_pattern(again_pattern);
|
|
|
+}
|
|
|
+
|
|
|
+////////////////////////////////////////////////////////////////////
|
|
|
+// Function: CollisionHandlerEvent::get_num_again_patterns
|
|
|
+// Access: Public
|
|
|
+// Description: Returns the number of in pattern strings that have
|
|
|
+// been added.
|
|
|
+////////////////////////////////////////////////////////////////////
|
|
|
+INLINE int CollisionHandlerEvent::
|
|
|
+get_num_again_patterns() const {
|
|
|
+ return _again_patterns.size();
|
|
|
}
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
|
// Function: CollisionHandlerEvent::get_again_pattern
|
|
|
// Access: Public
|
|
|
-// Description: Returns the pattern string that indicates how the
|
|
|
-// event names are generated when a collision between
|
|
|
-// two particular nodes is *still* detected. See
|
|
|
-// set_again_pattern() and set_in_pattern().
|
|
|
+// Description: Returns the nth pattern string that indicates how the
|
|
|
+// event names are generated for each collision
|
|
|
+// detected. See add_again_pattern().
|
|
|
////////////////////////////////////////////////////////////////////
|
|
|
INLINE string CollisionHandlerEvent::
|
|
|
-get_again_pattern() const {
|
|
|
- return _again_pattern;
|
|
|
+get_again_pattern(int n) const {
|
|
|
+ nassertr(n >= 0 && n < (int)_again_patterns.size(), string());
|
|
|
+ return _again_patterns[n];
|
|
|
}
|
|
|
|
|
|
+////////////////////////////////////////////////////////////////////
|
|
|
+// Function: CollisionHandlerEvent::clear_out_patterns
|
|
|
+// Access: Public
|
|
|
+// Description: Removes all of the previously-added in patterns. See
|
|
|
+// add_out_pattern.
|
|
|
+////////////////////////////////////////////////////////////////////
|
|
|
+INLINE void CollisionHandlerEvent::
|
|
|
+clear_out_patterns() {
|
|
|
+ _out_patterns.clear();
|
|
|
+}
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
|
-// Function: CollisionHandlerEvent::set_out_pattern
|
|
|
+// Function: CollisionHandlerEvent::add_out_pattern
|
|
|
// Access: Public
|
|
|
-// Description: Sets the pattern string that indicates how the event
|
|
|
+// Description: Adds the pattern string that indicates how the event
|
|
|
// names are generated when a collision between two
|
|
|
// particular nodes is *no longer* detected.
|
|
|
//
|
|
|
@@ -158,20 +240,43 @@ get_again_pattern() const {
|
|
|
// out_pattern event is thrown.
|
|
|
////////////////////////////////////////////////////////////////////
|
|
|
INLINE void CollisionHandlerEvent::
|
|
|
+add_out_pattern(const string &out_pattern) {
|
|
|
+ _out_patterns.push_back(out_pattern);
|
|
|
+}
|
|
|
+
|
|
|
+////////////////////////////////////////////////////////////////////
|
|
|
+// Function: CollisionHandlerEvent::set_out_pattern
|
|
|
+// Access: Public
|
|
|
+// Description: This method is deprecated; it completely replaces all
|
|
|
+// the in patterns that have previously been set with
|
|
|
+// the indicated pattern.
|
|
|
+////////////////////////////////////////////////////////////////////
|
|
|
+INLINE void CollisionHandlerEvent::
|
|
|
set_out_pattern(const string &out_pattern) {
|
|
|
- _out_pattern = out_pattern;
|
|
|
+ clear_out_patterns();
|
|
|
+ add_out_pattern(out_pattern);
|
|
|
+}
|
|
|
+
|
|
|
+////////////////////////////////////////////////////////////////////
|
|
|
+// Function: CollisionHandlerEvent::get_num_out_patterns
|
|
|
+// Access: Public
|
|
|
+// Description: Returns the number of in pattern strings that have
|
|
|
+// been added.
|
|
|
+////////////////////////////////////////////////////////////////////
|
|
|
+INLINE int CollisionHandlerEvent::
|
|
|
+get_num_out_patterns() const {
|
|
|
+ return _out_patterns.size();
|
|
|
}
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
|
// Function: CollisionHandlerEvent::get_out_pattern
|
|
|
// Access: Public
|
|
|
-// Description: Returns the pattern string that indicates how the
|
|
|
-// event names are generated when a collision between
|
|
|
-// two particular nodes is *no longer* detected. See
|
|
|
-// set_out_pattern() and set_in_pattern().
|
|
|
+// Description: Returns the nth pattern string that indicates how the
|
|
|
+// event names are generated for each collision
|
|
|
+// detected. See add_out_pattern().
|
|
|
////////////////////////////////////////////////////////////////////
|
|
|
INLINE string CollisionHandlerEvent::
|
|
|
-get_out_pattern() const {
|
|
|
- return _out_pattern;
|
|
|
+get_out_pattern(int n) const {
|
|
|
+ nassertr(n >= 0 && n < (int)_out_patterns.size(), string());
|
|
|
+ return _out_patterns[n];
|
|
|
}
|
|
|
-
|