[420] | 1 | #ifndef __RAYINFO_H__
|
---|
| 2 | #define __RAYINFO_H__
|
---|
| 3 |
|
---|
| 4 | #include <vector>
|
---|
| 5 | using namespace std;
|
---|
| 6 |
|
---|
| 7 | class VssRay;
|
---|
| 8 | class RayInfo;
|
---|
[437] | 9 | class Plane3;
|
---|
| 10 | class Vector3;
|
---|
[420] | 11 |
|
---|
| 12 | typedef vector<RayInfo> RayInfoContainer;
|
---|
| 13 | /** Structure holding additional info about
|
---|
| 14 | the ray during traversal.
|
---|
| 15 | */
|
---|
| 16 | class RayInfo
|
---|
| 17 | {
|
---|
| 18 | public:
|
---|
| 19 | /// pointer to the actual ray
|
---|
| 20 | VssRay *mRay;
|
---|
| 21 |
|
---|
| 22 | // endpoints - do we need them?
|
---|
| 23 | #if USE_FIXEDPOINT_T
|
---|
| 24 | short mMinT, mMaxT;
|
---|
| 25 | #else
|
---|
| 26 | float mMinT, mMaxT;
|
---|
| 27 | #endif
|
---|
| 28 |
|
---|
| 29 | RayInfo();
|
---|
| 30 |
|
---|
| 31 | RayInfo(VssRay *r);
|
---|
| 32 |
|
---|
| 33 | RayInfo(VssRay *r, const float _min, const float _max);
|
---|
| 34 |
|
---|
| 35 | RayInfo(VssRay *r, const short _min, const float _max);
|
---|
| 36 |
|
---|
| 37 | RayInfo(VssRay *r, const float _min, const short _max);
|
---|
| 38 |
|
---|
| 39 | friend bool operator<(const RayInfo &a, const RayInfo &b)
|
---|
| 40 | {
|
---|
| 41 | return a.mRay < b.mRay;
|
---|
| 42 | }
|
---|
| 43 |
|
---|
[437] | 44 | /** Extracts the scalar of the starting point of the ray segment
|
---|
| 45 | that lies in the axis.
|
---|
| 46 | */
|
---|
[420] | 47 | float ExtrapOrigin(const int axis) const;
|
---|
[437] | 48 | /** Extracts the scalar of the termination point of the ray segment
|
---|
| 49 | that lies in the axis.
|
---|
| 50 | */
|
---|
[420] | 51 | float ExtrapTermination(const int axis) const;
|
---|
| 52 |
|
---|
[437] | 53 | /** Extracts the starting point of the ray segment.
|
---|
| 54 | */
|
---|
| 55 | Vector3 ExtrapOrigin() const;
|
---|
| 56 |
|
---|
| 57 | /** Extracts the end point of the ray segment.
|
---|
| 58 | */
|
---|
| 59 | Vector3 ExtrapTermination() const;
|
---|
| 60 |
|
---|
[420] | 61 | float GetMinT () const;
|
---|
| 62 | float GetMaxT () const;
|
---|
| 63 |
|
---|
| 64 | void SetMinT (const float t);
|
---|
| 65 |
|
---|
| 66 | void SetMaxT (const float t);
|
---|
| 67 |
|
---|
[437] | 68 | float SegmentLength() const;
|
---|
| 69 | float SqrSegmentLength() const;
|
---|
| 70 |
|
---|
[420] | 71 | /** Computes intersection of this ray with the axis aligned split plane.
|
---|
[437] | 72 |
|
---|
[420] | 73 | @param axis axis of the split plane
|
---|
[437] | 74 | @param position scalar position of the split plane for the chosen axis
|
---|
| 75 | @param t returns the t parameter value of the ray intersection
|
---|
[420] | 76 |
|
---|
| 77 | @returns 0 if ray intersects plane, -1 if on back side of plane, 1 if on front side
|
---|
| 78 | */
|
---|
| 79 | int ComputeRayIntersection(const int axis, const float position, float &t) const;
|
---|
[437] | 80 |
|
---|
| 81 | /** Computes intersection of this ray with the split plane.
|
---|
| 82 |
|
---|
| 83 | @param splitPlane the split plane
|
---|
| 84 | @param t returns the t parameter value of the ray intersection
|
---|
| 85 |
|
---|
| 86 | @returns 0 if ray intersects plane, -1 if on back side of plane, 1 if on front side
|
---|
| 87 | */
|
---|
| 88 | int ComputeRayIntersection(const Plane3 &splitPlane, float &t) const;
|
---|
[420] | 89 | };
|
---|
| 90 |
|
---|
| 91 | #endif
|
---|
| 92 |
|
---|