| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
- //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
- #pragma once
- #include "Prerequisites/BsPrerequisitesUtil.h"
- #include "Math/BsVector3.h"
- #include "Math/BsLineSegment3.h"
- namespace bs
- {
- /** @addtogroup Math
- * @{
- */
- /** Represents a capsule with a line segment and a radius. */
- class BS_UTILITY_EXPORT Capsule
- {
- public:
- Capsule();
- Capsule(const LineSegment3& segment, float radius);
- /**
- * Ray/capsule intersection.
- *
- * @return Boolean result and distance to the nearest intersection point.
- */
- std::pair<bool, float> intersects(const Ray& ray) const;
- /**
- * Returns the line segment along which the capsule lies. All capsule points are at equal distance from this
- * segment.
- */
- const LineSegment3& getSegment() const { return mSegment; }
- /** Returns the radius of the capsule. It defines the distance of the capsule from its line segment. */
- float getRadius() const { return mRadius; }
- /**
- * Returns the height of the capsule. The height is the distance between centers of the hemispheres that form the
- * capsule's ends.
- */
- float getHeight() const { return mSegment.getLength(); }
- /** Returns the center point of the capsule. */
- Vector3 getCenter() const { return mSegment.getCenter(); }
- private:
- LineSegment3 mSegment;
- float mRadius;
- };
- /** @} */
- }
|