| 1 |
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 2 |
/** |
| 3 |
* Contains code for line-swept spheres. |
| 4 |
* \file IceLSS.h |
| 5 |
* \author Pierre Terdiman |
| 6 |
* \date April, 4, 2000 |
| 7 |
*/ |
| 8 |
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 9 |
|
| 10 |
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 11 |
// Include Guard |
| 12 |
#ifndef __ICELSS_H__ |
| 13 |
#define __ICELSS_H__ |
| 14 |
|
| 15 |
class ICEMATHS_API LSS : public Segment |
| 16 |
{ |
| 17 |
public: |
| 18 |
//! Constructor |
| 19 |
inline_ LSS() {} |
| 20 |
//! Constructor |
| 21 |
inline_ LSS(const Segment& seg, float radius) : Segment(seg), mRadius(radius) {} |
| 22 |
//! Destructor |
| 23 |
inline_ ~LSS() {} |
| 24 |
|
| 25 |
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 26 |
/** |
| 27 |
* Computes an OBB surrounding the LSS. |
| 28 |
* \param box [out] the OBB |
| 29 |
*/ |
| 30 |
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 31 |
void ComputeOBB(OBB& box); |
| 32 |
|
| 33 |
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 34 |
/** |
| 35 |
* Tests if a point is contained within the LSS. |
| 36 |
* \param pt [in] the point to test |
| 37 |
* \return true if inside the LSS |
| 38 |
* \warning point and LSS must be in same space |
| 39 |
*/ |
| 40 |
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 41 |
inline_ bool Contains(const Point& pt) const { return SquareDistance(pt) <= mRadius*mRadius; } |
| 42 |
|
| 43 |
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 44 |
/** |
| 45 |
* Tests if a sphere is contained within the LSS. |
| 46 |
* \param sphere [in] the sphere to test |
| 47 |
* \return true if inside the LSS |
| 48 |
* \warning sphere and LSS must be in same space |
| 49 |
*/ |
| 50 |
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 51 |
inline_ bool Contains(const Sphere& sphere) |
| 52 |
{ |
| 53 |
float d = mRadius - sphere.mRadius; |
| 54 |
if(d>=0.0f) return SquareDistance(sphere.mCenter) <= d*d; |
| 55 |
else return false; |
| 56 |
} |
| 57 |
|
| 58 |
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 59 |
/** |
| 60 |
* Tests if an LSS is contained within the LSS. |
| 61 |
* \param lss [in] the LSS to test |
| 62 |
* \return true if inside the LSS |
| 63 |
* \warning both LSS must be in same space |
| 64 |
*/ |
| 65 |
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 66 |
inline_ bool Contains(const LSS& lss) |
| 67 |
{ |
| 68 |
// We check the LSS contains the two spheres at the start and end of the sweep |
| 69 |
return Contains(Sphere(lss.mP0, lss.mRadius)) && Contains(Sphere(lss.mP0, lss.mRadius)); |
| 70 |
} |
| 71 |
|
| 72 |
float mRadius; //!< Sphere radius |
| 73 |
}; |
| 74 |
|
| 75 |
#endif // __ICELSS_H__ |