1 | #ifndef __MUTUAL_VISIBILITY_H
|
---|
2 | #define __MUTUAL_VISIBILITY_H
|
---|
3 |
|
---|
4 | #include "Vector3.h"
|
---|
5 | #include "Ray.h"
|
---|
6 | #include "Triangle3.h"
|
---|
7 |
|
---|
8 | class Intersectable;
|
---|
9 | class AxisAlignedBox3;
|
---|
10 |
|
---|
11 |
|
---|
12 |
|
---|
13 |
|
---|
14 | struct SimpleRay {
|
---|
15 | Vector3 mOrigin;
|
---|
16 | Vector3 mDirection;
|
---|
17 | };
|
---|
18 |
|
---|
19 |
|
---|
20 | struct TriangleSample {
|
---|
21 | public:
|
---|
22 | /// evaluted sampling error
|
---|
23 | float mError;
|
---|
24 | /// depth in recursion
|
---|
25 | int mDepth;
|
---|
26 | /// The source triangle
|
---|
27 | Triangle3 mSource;
|
---|
28 | /// The target triangle
|
---|
29 | Triangle3 mTarget;
|
---|
30 |
|
---|
31 | /// intersections with the scene
|
---|
32 | vector<Ray::Intersection> mIntersections[9];
|
---|
33 |
|
---|
34 | void ComputeError();
|
---|
35 |
|
---|
36 | TriangleSample () {}
|
---|
37 |
|
---|
38 | TriangleSample (
|
---|
39 | const Triangle3 &source,
|
---|
40 | const Triangle3 &target)
|
---|
41 | {
|
---|
42 | Init(source, target);
|
---|
43 | }
|
---|
44 |
|
---|
45 | // initial triangle sample
|
---|
46 | void Init(
|
---|
47 | const Triangle3 &source,
|
---|
48 | const Triangle3 &target);
|
---|
49 |
|
---|
50 | Vector3
|
---|
51 | GetIntersectionPoint(const int rayIndex,
|
---|
52 | const int depth) const;
|
---|
53 |
|
---|
54 | void GetRay(const int rayIndex,
|
---|
55 | Vector3 &origin,
|
---|
56 | Vector3 &direction) const;
|
---|
57 |
|
---|
58 | };
|
---|
59 |
|
---|
60 | enum { VISIBLE, INVISIBLE };
|
---|
61 |
|
---|
62 |
|
---|
63 | class MutualVisibilitySampler {
|
---|
64 | public:
|
---|
65 | KdTree *mKdTree;
|
---|
66 | AxisAlignedBox3 mSource;
|
---|
67 | AxisAlignedBox3 mTarget;
|
---|
68 | float mSolidAngleThreshold;
|
---|
69 |
|
---|
70 |
|
---|
71 | MutualVisibilitySampler(KdTree *kdTree,
|
---|
72 | AxisAlignedBox3 &source,
|
---|
73 | AxisAlignedBox3 &target,
|
---|
74 | const float solidAngleThreshold);
|
---|
75 | int
|
---|
76 | ComputeVisibility();
|
---|
77 |
|
---|
78 | void
|
---|
79 | ConstructInitialSamples(
|
---|
80 | const AxisAlignedBox3 &source,
|
---|
81 | const AxisAlignedBox3 &target,
|
---|
82 | vector<TriangleSample *> &samples
|
---|
83 | );
|
---|
84 |
|
---|
85 | void
|
---|
86 | AddInitialSamples(
|
---|
87 | const Rectangle3 &sourceRect,
|
---|
88 | const Rectangle3 &targetRect,
|
---|
89 | vector<TriangleSample *> &samples
|
---|
90 | );
|
---|
91 |
|
---|
92 | // the split sample method contains a methodology to create new samples
|
---|
93 | // or terminate the sampling
|
---|
94 | bool
|
---|
95 | SplitSample(
|
---|
96 | const TriangleSample &source,
|
---|
97 | TriangleSample &sample1,
|
---|
98 | TriangleSample &sample2
|
---|
99 | );
|
---|
100 | void
|
---|
101 | PerformSplit(
|
---|
102 | const TriangleSample &sample,
|
---|
103 | const bool splitSource,
|
---|
104 | const int edge,
|
---|
105 | const Vector3 &splitPoint,
|
---|
106 | const Ray &ray,
|
---|
107 | TriangleSample &sample1,
|
---|
108 | TriangleSample &sample2
|
---|
109 | );
|
---|
110 |
|
---|
111 |
|
---|
112 | bool
|
---|
113 | SampleTerminationCriteriaMet(
|
---|
114 | const TriangleSample &sample);
|
---|
115 |
|
---|
116 | float
|
---|
117 | GetSpatialAngle(const TriangleSample &sample,
|
---|
118 | const Vector3 &point
|
---|
119 | );
|
---|
120 |
|
---|
121 | void
|
---|
122 | ComputeError(TriangleSample &sample);
|
---|
123 |
|
---|
124 |
|
---|
125 | };
|
---|
126 |
|
---|
127 | int
|
---|
128 | ComputeBoxVisibility(KdTree *kdTree,
|
---|
129 | AxisAlignedBox3 &source,
|
---|
130 | AxisAlignedBox3 &target,
|
---|
131 | float solidAngleThreshold);
|
---|
132 |
|
---|
133 |
|
---|
134 |
|
---|
135 |
|
---|
136 |
|
---|
137 |
|
---|
138 | #endif
|
---|