collisionHandlerEvent.I 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. // Filename: collisionHandlerEvent.I
  2. // Created by: drose (27Jun00)
  3. //
  4. ////////////////////////////////////////////////////////////////////
  5. //
  6. // PANDA 3D SOFTWARE
  7. // Copyright (c) 2001, Disney Enterprises, Inc. All rights reserved
  8. //
  9. // All use of this software is subject to the terms of the Panda 3d
  10. // Software license. You should have received a copy of this license
  11. // along with this source code; you will also find a current copy of
  12. // the license at http://www.panda3d.org/license.txt .
  13. //
  14. // To contact the maintainers of this program write to
  15. // [email protected] .
  16. //
  17. ////////////////////////////////////////////////////////////////////
  18. ////////////////////////////////////////////////////////////////////
  19. // Function: CollisionHandlerEvent::SortEntries::operator ()
  20. // Access: Public
  21. // Description: Orders the CollisionEntries in the set so that there
  22. // is one entry for each node/node intersection
  23. // detected.
  24. ////////////////////////////////////////////////////////////////////
  25. INLINE bool CollisionHandlerEvent::SortEntries::
  26. operator () (const PT(CollisionEntry) &a,
  27. const PT(CollisionEntry) &b) const {
  28. if (a->get_from_node() != b->get_from_node()) {
  29. return a->get_from_node() < b->get_from_node();
  30. }
  31. if (a->get_into_node() != b->get_into_node()) {
  32. return a->get_into_node() < b->get_into_node();
  33. }
  34. return false;
  35. }
  36. ////////////////////////////////////////////////////////////////////
  37. // Function: CollisionHandlerEvent::SortEntries::operator =
  38. // Access: Public
  39. // Description: The assignment operator does absolutely nothing,
  40. // since this is just a function object class that
  41. // stores no data. We define it just to quiet up g++ in
  42. // -Wall mode.
  43. ////////////////////////////////////////////////////////////////////
  44. INLINE void CollisionHandlerEvent::SortEntries::
  45. operator = (const CollisionHandlerEvent::SortEntries &) {
  46. }
  47. ////////////////////////////////////////////////////////////////////
  48. // Function: CollisionHandlerEvent::set_in_pattern
  49. // Access: Public
  50. // Description: Sets the pattern string that indicates how the event
  51. // names are generated for each collision detected.
  52. // This is a string that may contain any of the
  53. // following:
  54. //
  55. // %fn - the name of the "from" object's node
  56. // %in - the name of the "into" object's node
  57. // %ft - 't' if "from" is tangible, 'i' if intangible
  58. // %it - 't' if "into" is tangible, 'i' if intangible
  59. //
  60. // The event name will be based on the in_pattern
  61. // string specified here, with all occurrences of the
  62. // above strings replaced with the corresponding values.
  63. //
  64. // In general, the in_pattern event is thrown on the
  65. // first detection of a collision between two particular
  66. // nodes. In subsequent passes, as long as a collision
  67. // between those two nodes continues to be detected each
  68. // frame, the again_pattern is thrown. The first frame
  69. // in which the collision is no longer detected, the
  70. // out_pattern event is thrown.
  71. ////////////////////////////////////////////////////////////////////
  72. INLINE void CollisionHandlerEvent::
  73. set_in_pattern(const string &in_pattern) {
  74. _in_pattern = in_pattern;
  75. }
  76. ////////////////////////////////////////////////////////////////////
  77. // Function: CollisionHandlerEvent::get_in_pattern
  78. // Access: Public
  79. // Description: Returns the pattern string that indicates how the
  80. // event names are generated for each collision
  81. // detected. See set_in_pattern().
  82. ////////////////////////////////////////////////////////////////////
  83. INLINE string CollisionHandlerEvent::
  84. get_in_pattern() const {
  85. return _in_pattern;
  86. }
  87. ////////////////////////////////////////////////////////////////////
  88. // Function: CollisionHandlerEvent::set_again_pattern
  89. // Access: Public
  90. // Description: Sets the pattern string that indicates how the event
  91. // names are generated when a collision between two
  92. // particular nodes is *still* detected. This event is
  93. // thrown each consecutive time a collision between two
  94. // particular nodes is detected, starting with the
  95. // second time.
  96. //
  97. // In general, the in_pattern event is thrown on the
  98. // first detection of a collision between two particular
  99. // nodes. In subsequent passes, as long as a collision
  100. // between those two nodes continues to be detected each
  101. // frame, the again_pattern is thrown. The first frame
  102. // in which the collision is no longer detected, the
  103. // out_pattern event is thrown.
  104. ////////////////////////////////////////////////////////////////////
  105. INLINE void CollisionHandlerEvent::
  106. set_again_pattern(const string &again_pattern) {
  107. _again_pattern = again_pattern;
  108. }
  109. ////////////////////////////////////////////////////////////////////
  110. // Function: CollisionHandlerEvent::get_again_pattern
  111. // Access: Public
  112. // Description: Returns the pattern string that indicates how the
  113. // event names are generated when a collision between
  114. // two particular nodes is *still* detected. See
  115. // set_again_pattern() and set_in_pattern().
  116. ////////////////////////////////////////////////////////////////////
  117. INLINE string CollisionHandlerEvent::
  118. get_again_pattern() const {
  119. return _again_pattern;
  120. }
  121. ////////////////////////////////////////////////////////////////////
  122. // Function: CollisionHandlerEvent::set_out_pattern
  123. // Access: Public
  124. // Description: Sets the pattern string that indicates how the event
  125. // names are generated when a collision between two
  126. // particular nodes is *no longer* detected.
  127. //
  128. // In general, the in_pattern event is thrown on the
  129. // first detection of a collision between two particular
  130. // nodes. In subsequent passes, as long as a collision
  131. // between those two nodes continues to be detected each
  132. // frame, the again_pattern is thrown. The first frame
  133. // in which the collision is no longer detected, the
  134. // out_pattern event is thrown.
  135. ////////////////////////////////////////////////////////////////////
  136. INLINE void CollisionHandlerEvent::
  137. set_out_pattern(const string &out_pattern) {
  138. _out_pattern = out_pattern;
  139. }
  140. ////////////////////////////////////////////////////////////////////
  141. // Function: CollisionHandlerEvent::get_out_pattern
  142. // Access: Public
  143. // Description: Returns the pattern string that indicates how the
  144. // event names are generated when a collision between
  145. // two particular nodes is *no longer* detected. See
  146. // set_out_pattern() and set_in_pattern().
  147. ////////////////////////////////////////////////////////////////////
  148. INLINE string CollisionHandlerEvent::
  149. get_out_pattern() const {
  150. return _out_pattern;
  151. }