BsCapsule.h 1.2 KB

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