1 | #ifndef _RayCaster_H__
|
---|
2 | #define _RayCaster_H__
|
---|
3 |
|
---|
4 | #include "Containers.h"
|
---|
5 | #include <string>
|
---|
6 | #include "Vector3.h"
|
---|
7 |
|
---|
8 | using namespace std;
|
---|
9 |
|
---|
10 |
|
---|
11 | namespace GtpVisibilityPreprocessor {
|
---|
12 |
|
---|
13 |
|
---|
14 | class Intersectable;
|
---|
15 | class VssRay;
|
---|
16 | class SimpleRayContainer;
|
---|
17 | class AxisAlignedBox3;
|
---|
18 | //class Vector3;
|
---|
19 | struct VssRayContainer;
|
---|
20 | class Preprocessor;
|
---|
21 | struct SimpleRay;
|
---|
22 |
|
---|
23 |
|
---|
24 | /** This class provides an interface for ray casting.
|
---|
25 | */
|
---|
26 | class RayCaster
|
---|
27 | {
|
---|
28 |
|
---|
29 | public:
|
---|
30 |
|
---|
31 | enum {
|
---|
32 | INTERNAL_RAYCASTER = 0,
|
---|
33 | INTEL_RAYCASTER
|
---|
34 | };
|
---|
35 |
|
---|
36 | RayCaster(const Preprocessor &preprocessor);
|
---|
37 |
|
---|
38 | virtual ~RayCaster();
|
---|
39 |
|
---|
40 | virtual int Type() const = 0;
|
---|
41 |
|
---|
42 | /** Wrapper for casting single ray.
|
---|
43 | @returns ray or NULL if invalid
|
---|
44 | */
|
---|
45 | VssRay *CastRay(
|
---|
46 | const SimpleRay &simpleRay,
|
---|
47 | const AxisAlignedBox3 &box,
|
---|
48 | const bool castDoubleRay
|
---|
49 | );
|
---|
50 |
|
---|
51 | virtual int CastRay(
|
---|
52 | const SimpleRay &simpleRay,
|
---|
53 | VssRayContainer &vssRays,
|
---|
54 | const AxisAlignedBox3 &box,
|
---|
55 | const bool castDoubleRay,
|
---|
56 | const bool pruneInvalidRays = true
|
---|
57 | ) = 0;
|
---|
58 |
|
---|
59 | virtual void CastRays16(
|
---|
60 | const int i,
|
---|
61 | SimpleRayContainer &rays,
|
---|
62 | VssRayContainer &vssRays,
|
---|
63 | const AxisAlignedBox3 &sbox,
|
---|
64 | const bool castDoubleRay,
|
---|
65 | const bool pruneInvalidRays = true
|
---|
66 | ) = 0;
|
---|
67 |
|
---|
68 |
|
---|
69 | protected:
|
---|
70 | struct Intersection
|
---|
71 | {
|
---|
72 | Intersection(): mObject(NULL), mFaceId(0)
|
---|
73 | {}
|
---|
74 |
|
---|
75 | Intersection(const Vector3 &p, const Vector3 &n, Intersectable *o, const int f):
|
---|
76 | mPoint(p), mNormal(n), mObject(o), mFaceId(f)
|
---|
77 | {}
|
---|
78 |
|
---|
79 | Intersection(const Vector3 &p): mPoint(p), mObject(NULL), mFaceId(0)
|
---|
80 | {}
|
---|
81 | Vector3 mPoint;
|
---|
82 | Vector3 mNormal;
|
---|
83 | Intersectable *mObject;
|
---|
84 | int mFaceId;
|
---|
85 | };
|
---|
86 |
|
---|
87 |
|
---|
88 | int ProcessRay(
|
---|
89 | const SimpleRay &ray,
|
---|
90 | Intersection &hitA,
|
---|
91 | Intersection &hitB,
|
---|
92 | VssRayContainer &vssRays,
|
---|
93 | const AxisAlignedBox3 &box,
|
---|
94 | const bool castDoubleRay,
|
---|
95 | const bool pruneInvalidRays = true
|
---|
96 | );
|
---|
97 |
|
---|
98 | /** Checks if ray is valid.
|
---|
99 | I.e., the ray is in valid view space.
|
---|
100 | @note: clamps the ray to valid view space.
|
---|
101 | */
|
---|
102 | bool ValidateRay(const Vector3 &origin,
|
---|
103 | const Vector3 &direction,
|
---|
104 | const AxisAlignedBox3 &box,
|
---|
105 | Intersection &hit);
|
---|
106 |
|
---|
107 | const Preprocessor &mPreprocessor;
|
---|
108 | };
|
---|
109 |
|
---|
110 |
|
---|
111 | }
|
---|
112 |
|
---|
113 | #endif
|
---|