odeCollisionEntry.I 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. // Filename: odeCollisionEntry.cxx
  2. // Created by: pro-rsoft (13Mar09)
  3. //
  4. ////////////////////////////////////////////////////////////////////
  5. //
  6. // PANDA 3D SOFTWARE
  7. // Copyright (c) Carnegie Mellon University. All rights reserved.
  8. //
  9. // All use of this software is subject to the terms of the revised BSD
  10. // license. You should have received a copy of this license along
  11. // with this source code in a file named "LICENSE."
  12. //
  13. ////////////////////////////////////////////////////////////////////
  14. ////////////////////////////////////////////////////////////////////
  15. // Function: OdeCollisionEntry::Constructor
  16. // Access: Private
  17. // Description:
  18. ////////////////////////////////////////////////////////////////////
  19. INLINE OdeCollisionEntry::
  20. OdeCollisionEntry() {
  21. }
  22. ////////////////////////////////////////////////////////////////////
  23. // Function: OdeCollisionEntry::get_geom1
  24. // Access: Published
  25. // Description: Returns the first geom in the collision.
  26. ////////////////////////////////////////////////////////////////////
  27. INLINE const OdeGeom OdeCollisionEntry::
  28. get_geom1() const {
  29. return OdeGeom(_geom1);
  30. }
  31. ////////////////////////////////////////////////////////////////////
  32. // Function: OdeCollisionEntry::get_geom2
  33. // Access: Published
  34. // Description: Returns the second geom in the collision.
  35. ////////////////////////////////////////////////////////////////////
  36. INLINE const OdeGeom OdeCollisionEntry::
  37. get_geom2() const {
  38. return OdeGeom(_geom2);
  39. }
  40. ////////////////////////////////////////////////////////////////////
  41. // Function: OdeCollisionEntry::get_body1
  42. // Access: Published
  43. // Description: Returns the first body in the collision.
  44. ////////////////////////////////////////////////////////////////////
  45. INLINE const OdeBody OdeCollisionEntry::
  46. get_body1() const {
  47. return OdeBody(_body1);
  48. }
  49. ////////////////////////////////////////////////////////////////////
  50. // Function: OdeCollisionEntry::get_body2
  51. // Access: Published
  52. // Description: Returns the second body in the collision.
  53. ////////////////////////////////////////////////////////////////////
  54. INLINE const OdeBody OdeCollisionEntry::
  55. get_body2() const {
  56. return OdeBody(_body2);
  57. }
  58. ////////////////////////////////////////////////////////////////////
  59. // Function: OdeCollisionEntry::get_num_contacts
  60. // Access: Published
  61. // Description: Returns the number of contacts in the collision.
  62. ////////////////////////////////////////////////////////////////////
  63. INLINE const size_t OdeCollisionEntry::
  64. get_num_contacts() const {
  65. return _num_contacts;
  66. }
  67. ////////////////////////////////////////////////////////////////////
  68. // Function: OdeCollisionEntry::get_contact_geom
  69. // Access: Published
  70. // Description: Returns the nth contact geom in the collision.
  71. ////////////////////////////////////////////////////////////////////
  72. INLINE const OdeContactGeom OdeCollisionEntry::
  73. get_contact_geom(size_t n) const {
  74. nassertr(n >= 0 && n < _num_contacts, OdeContactGeom());
  75. return _contact_geoms[n];
  76. }
  77. ////////////////////////////////////////////////////////////////////
  78. // Function: OdeCollisionEntry::operator []
  79. // Access: Published
  80. // Description: Returns the nth contact geom in the collision.
  81. ////////////////////////////////////////////////////////////////////
  82. INLINE const OdeContactGeom OdeCollisionEntry::
  83. operator [] (size_t n) const {
  84. nassertr(n >= 0 && n < _num_contacts, OdeContactGeom());
  85. return _contact_geoms[n];
  86. }
  87. ////////////////////////////////////////////////////////////////////
  88. // Function: OdeCollisionEntry::get_contact_point
  89. // Access: Published
  90. // Description: Returns the nth contact point in the collision.
  91. // This does exactly the same as
  92. // get_contact_geom(n).get_pos().
  93. ////////////////////////////////////////////////////////////////////
  94. INLINE const LPoint3f OdeCollisionEntry::
  95. get_contact_point(size_t n) const {
  96. nassertr(n >= 0 && n < _num_contacts, LPoint3f::zero());
  97. return _contact_geoms[n].get_pos();
  98. }
  99. ////////////////////////////////////////////////////////////////////
  100. // Function: OdeCollisionEntry::operator bool
  101. // Access: Published
  102. // Description: An OdeCollisionEntry evaluates to False if it
  103. // holds no contacts.
  104. ////////////////////////////////////////////////////////////////////
  105. INLINE OdeCollisionEntry::
  106. operator bool () const {
  107. return (_num_contacts != 0);
  108. }
  109. ////////////////////////////////////////////////////////////////////
  110. // Function: OdeCollisionEntry::is_empty
  111. // Access: Published
  112. // Description: Returns true if the entry holds no contacts.
  113. ////////////////////////////////////////////////////////////////////
  114. INLINE bool OdeCollisionEntry::
  115. is_empty() const {
  116. return (_num_contacts == 0);
  117. }