2
0

BsCapsule.h 959 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #pragma once
  2. #include "BsPrerequisitesUtil.h"
  3. #include "BsVector3.h"
  4. #include "BsLineSegment3.h"
  5. namespace BansheeEngine
  6. {
  7. /**
  8. * @brief Represents a capsule represented by a line segment and
  9. * a radius.
  10. */
  11. class BS_UTILITY_EXPORT Capsule
  12. {
  13. public:
  14. Capsule();
  15. Capsule(const LineSegment3& segment, float radius);
  16. /**
  17. * @brief Ray/capsule intersection.
  18. *
  19. * @return Boolean result and distance to the nearest intersection point.
  20. */
  21. std::pair<bool, float> intersects(const Ray& ray) const;
  22. /**
  23. * @brief Returns the line segment along which the capsule lies.
  24. * All capsule points are at equal distance from this segment.
  25. */
  26. const LineSegment3& getSegment() const { return mSegment; }
  27. /**
  28. * @brief Returns the radius of the capsule. It defines the distance
  29. * of the capsule from its line segment.
  30. */
  31. float getRadius() const { return mRadius; }
  32. private:
  33. LineSegment3 mSegment;
  34. float mRadius;
  35. };
  36. }