[420] | 1 | #ifndef __RAYINFO_H__
|
---|
| 2 | #define __RAYINFO_H__
|
---|
| 3 |
|
---|
| 4 | #include <vector>
|
---|
[2237] | 5 | #include "VssRay.h"
|
---|
[420] | 6 |
|
---|
[2176] | 7 |
|
---|
[860] | 8 | namespace GtpVisibilityPreprocessor {
|
---|
| 9 |
|
---|
[2237] | 10 | //class VssRay;
|
---|
[420] | 11 | class RayInfo;
|
---|
[437] | 12 | class Plane3;
|
---|
| 13 | class Vector3;
|
---|
[420] | 14 |
|
---|
[1133] | 15 |
|
---|
[2176] | 16 | typedef std::vector<RayInfo> RayInfoContainer;
|
---|
[1133] | 17 |
|
---|
| 18 |
|
---|
[420] | 19 | /** Structure holding additional info about
|
---|
| 20 | the ray during traversal.
|
---|
| 21 | */
|
---|
| 22 | class RayInfo
|
---|
| 23 | {
|
---|
| 24 | public:
|
---|
| 25 | /// pointer to the actual ray
|
---|
| 26 | VssRay *mRay;
|
---|
| 27 |
|
---|
| 28 | // endpoints - do we need them?
|
---|
| 29 | #if USE_FIXEDPOINT_T
|
---|
| 30 | short mMinT, mMaxT;
|
---|
| 31 | #else
|
---|
| 32 | float mMinT, mMaxT;
|
---|
| 33 | #endif
|
---|
| 34 |
|
---|
| 35 | RayInfo();
|
---|
| 36 |
|
---|
| 37 | RayInfo(VssRay *r);
|
---|
| 38 |
|
---|
| 39 | RayInfo(VssRay *r, const float _min, const float _max);
|
---|
| 40 |
|
---|
| 41 | RayInfo(VssRay *r, const short _min, const float _max);
|
---|
| 42 |
|
---|
| 43 | RayInfo(VssRay *r, const float _min, const short _max);
|
---|
| 44 |
|
---|
| 45 | friend bool operator<(const RayInfo &a, const RayInfo &b)
|
---|
| 46 | {
|
---|
| 47 | return a.mRay < b.mRay;
|
---|
| 48 | }
|
---|
| 49 |
|
---|
[437] | 50 | /** Extracts the scalar of the starting point of the ray segment
|
---|
| 51 | that lies in the axis.
|
---|
| 52 | */
|
---|
[2234] | 53 | inline float ExtrapOrigin(const int axis) const;
|
---|
[437] | 54 | /** Extracts the scalar of the termination point of the ray segment
|
---|
| 55 | that lies in the axis.
|
---|
| 56 | */
|
---|
[2234] | 57 | inline float ExtrapTermination(const int axis) const;
|
---|
[420] | 58 |
|
---|
[437] | 59 | /** Extracts the starting point of the ray segment.
|
---|
| 60 | */
|
---|
[2237] | 61 | inline Vector3 ExtrapOrigin() const;
|
---|
[437] | 62 |
|
---|
| 63 | /** Extracts the end point of the ray segment.
|
---|
| 64 | */
|
---|
[2237] | 65 | inline Vector3 ExtrapTermination() const;
|
---|
[437] | 66 |
|
---|
[2237] | 67 | inline float GetMinT () const;
|
---|
| 68 | inline float GetMaxT () const;
|
---|
[420] | 69 |
|
---|
[2237] | 70 | inline void SetMinT (const float t);
|
---|
| 71 | inline void SetMaxT (const float t);
|
---|
[420] | 72 |
|
---|
[437] | 73 | float SegmentLength() const;
|
---|
| 74 | float SqrSegmentLength() const;
|
---|
| 75 |
|
---|
[420] | 76 | /** Computes intersection of this ray with the axis aligned split plane.
|
---|
[437] | 77 |
|
---|
[420] | 78 | @param axis axis of the split plane
|
---|
[437] | 79 | @param position scalar position of the split plane for the chosen axis
|
---|
| 80 | @param t returns the t parameter value of the ray intersection
|
---|
[420] | 81 |
|
---|
| 82 | @returns 0 if ray intersects plane, -1 if on back side of plane, 1 if on front side
|
---|
| 83 | */
|
---|
| 84 | int ComputeRayIntersection(const int axis, const float position, float &t) const;
|
---|
[437] | 85 |
|
---|
| 86 | /** Computes intersection of this ray with the split plane.
|
---|
| 87 |
|
---|
| 88 | @param splitPlane the split plane
|
---|
| 89 | @param t returns the t parameter value of the ray intersection
|
---|
| 90 |
|
---|
| 91 | @returns 0 if ray intersects plane, -1 if on back side of plane, 1 if on front side
|
---|
| 92 | */
|
---|
| 93 | int ComputeRayIntersection(const Plane3 &splitPlane, float &t) const;
|
---|
[1147] | 94 |
|
---|
[1149] | 95 | friend void GetRayInfoSets(const RayInfoContainer &sourceRays,
|
---|
[1692] | 96 | const int maxSize,
|
---|
| 97 | RayInfoContainer &usedRays,
|
---|
| 98 | RayInfoContainer *savedRays = NULL);
|
---|
[420] | 99 | };
|
---|
| 100 |
|
---|
[2237] | 101 |
|
---|
| 102 | float RayInfo::ExtrapOrigin(const int axis) const
|
---|
| 103 | {
|
---|
| 104 | return mRay->GetOrigin(axis) + GetMinT() * mRay->GetDir(axis);
|
---|
[860] | 105 | }
|
---|
[2237] | 106 |
|
---|
| 107 | float RayInfo::ExtrapTermination(const int axis) const
|
---|
| 108 | {
|
---|
| 109 | return mRay->GetOrigin(axis) + GetMaxT() * mRay->GetDir(axis);
|
---|
| 110 | }
|
---|
| 111 |
|
---|
| 112 | Vector3 RayInfo::ExtrapOrigin() const
|
---|
| 113 | {
|
---|
| 114 | return mRay->GetOrigin() + GetMinT() * mRay->GetDir();
|
---|
| 115 | }
|
---|
| 116 |
|
---|
| 117 | Vector3 RayInfo::ExtrapTermination() const
|
---|
| 118 | {
|
---|
| 119 | return mRay->GetOrigin() + GetMaxT() * mRay->GetDir();
|
---|
| 120 | }
|
---|
| 121 |
|
---|
[2347] | 122 |
|
---|
| 123 |
|
---|
[2239] | 124 | #if USE_FIXEDPOINT_T
|
---|
| 125 | float RayInfo::GetMinT () const
|
---|
| 126 | {
|
---|
| 127 | return mMinT/(float)(FIXEDPOINT_ONE);
|
---|
| 128 | }
|
---|
| 129 |
|
---|
| 130 | float RayInfo::GetMaxT() const
|
---|
| 131 | {
|
---|
| 132 | return mMaxT / (float)(FIXEDPOINT_ONE);
|
---|
| 133 | }
|
---|
| 134 |
|
---|
| 135 | void RayInfo::SetMinT (const float t)
|
---|
| 136 | {
|
---|
| 137 | mMinT = (short) (t * (float)(FIXEDPOINT_ONE));
|
---|
| 138 | }
|
---|
| 139 |
|
---|
| 140 | void RayInfo::SetMaxT (const float t)
|
---|
| 141 | {
|
---|
| 142 | mMaxT = (short) (t*(float)(FIXEDPOINT_ONE));
|
---|
| 143 | ++ mMaxT;
|
---|
| 144 | // if (mMaxT!=0xFFFF)
|
---|
| 145 | // mMaxT++;
|
---|
| 146 | }
|
---|
| 147 | #else
|
---|
| 148 | float RayInfo::GetMinT () const
|
---|
| 149 | {
|
---|
| 150 | return mMinT;
|
---|
| 151 | }
|
---|
| 152 |
|
---|
| 153 | float RayInfo::GetMaxT () const
|
---|
| 154 | {
|
---|
| 155 | return mMaxT;
|
---|
| 156 | }
|
---|
| 157 |
|
---|
| 158 | void RayInfo::SetMinT (const float t)
|
---|
| 159 | {
|
---|
| 160 | mMinT = t;
|
---|
| 161 | }
|
---|
| 162 |
|
---|
| 163 | void RayInfo::SetMaxT (const float t)
|
---|
| 164 | {
|
---|
| 165 | mMaxT = t;
|
---|
| 166 | }
|
---|
| 167 | #endif
|
---|
[2332] | 168 |
|
---|
| 169 |
|
---|
| 170 |
|
---|
[2237] | 171 | }
|
---|
[420] | 172 | #endif
|
---|
| 173 |
|
---|