collisionSphere.I 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. // Filename: collisionSphere.I
  2. // Created by: drose (24Apr00)
  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: CollisionSphere::Constructor
  16. // Access: Public
  17. // Description:
  18. ////////////////////////////////////////////////////////////////////
  19. INLINE CollisionSphere::
  20. CollisionSphere(const LPoint3 &center, PN_stdfloat radius) :
  21. _center(center), _radius(radius)
  22. {
  23. nassertv(_radius >= 0.0f);
  24. }
  25. ////////////////////////////////////////////////////////////////////
  26. // Function: CollisionSphere::Constructor
  27. // Access: Public
  28. // Description:
  29. ////////////////////////////////////////////////////////////////////
  30. INLINE CollisionSphere::
  31. CollisionSphere(PN_stdfloat cx, PN_stdfloat cy, PN_stdfloat cz, PN_stdfloat radius) :
  32. _center(cx, cy, cz), _radius(radius)
  33. {
  34. nassertv(_radius >= 0.0f);
  35. }
  36. ////////////////////////////////////////////////////////////////////
  37. // Function: CollisionSphere::Default constructor
  38. // Access: Protected
  39. // Description: Creates an invalid sphere. Only used when reading
  40. // from a bam file.
  41. ////////////////////////////////////////////////////////////////////
  42. INLINE CollisionSphere::
  43. CollisionSphere() {
  44. }
  45. ////////////////////////////////////////////////////////////////////
  46. // Function: CollisionSphere::Copy Constructor
  47. // Access: Public
  48. // Description:
  49. ////////////////////////////////////////////////////////////////////
  50. INLINE CollisionSphere::
  51. CollisionSphere(const CollisionSphere &copy) :
  52. CollisionSolid(copy),
  53. _center(copy._center),
  54. _radius(copy._radius)
  55. {
  56. }
  57. ////////////////////////////////////////////////////////////////////
  58. // Function: CollisionSphere::flush_level
  59. // Access: Public, Static
  60. // Description: Flushes the PStatCollectors used during traversal.
  61. ////////////////////////////////////////////////////////////////////
  62. INLINE void CollisionSphere::
  63. flush_level() {
  64. _volume_pcollector.flush_level();
  65. _test_pcollector.flush_level();
  66. }
  67. ////////////////////////////////////////////////////////////////////
  68. // Function: CollisionSphere::set_center
  69. // Access: Published
  70. // Description:
  71. ////////////////////////////////////////////////////////////////////
  72. INLINE void CollisionSphere::
  73. set_center(const LPoint3 &center) {
  74. _center = center;
  75. mark_internal_bounds_stale();
  76. mark_viz_stale();
  77. }
  78. ////////////////////////////////////////////////////////////////////
  79. // Function: CollisionSphere::set_center
  80. // Access: Published
  81. // Description:
  82. ////////////////////////////////////////////////////////////////////
  83. INLINE void CollisionSphere::
  84. set_center(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z) {
  85. set_center(LPoint3(x, y, z));
  86. }
  87. ////////////////////////////////////////////////////////////////////
  88. // Function: CollisionSphere::get_center
  89. // Access: Published
  90. // Description:
  91. ////////////////////////////////////////////////////////////////////
  92. INLINE const LPoint3 &CollisionSphere::
  93. get_center() const {
  94. return _center;
  95. }
  96. ////////////////////////////////////////////////////////////////////
  97. // Function: CollisionSphere::set_radius
  98. // Access: Published
  99. // Description:
  100. ////////////////////////////////////////////////////////////////////
  101. INLINE void CollisionSphere::
  102. set_radius(PN_stdfloat radius) {
  103. nassertv(radius >= 0.0f);
  104. _radius = radius;
  105. mark_internal_bounds_stale();
  106. mark_viz_stale();
  107. }
  108. ////////////////////////////////////////////////////////////////////
  109. // Function: CollisionSphere::get_radius
  110. // Access: Published
  111. // Description:
  112. ////////////////////////////////////////////////////////////////////
  113. INLINE PN_stdfloat CollisionSphere::
  114. get_radius() const {
  115. return _radius;
  116. }