1 | #ifndef __BEAM_H
|
---|
2 | #define __BEAM_H
|
---|
3 |
|
---|
4 | #include <vector>
|
---|
5 | #include "AxisAlignedBox3.h"
|
---|
6 | #include "Statistics.h"
|
---|
7 |
|
---|
8 | using namespace std;
|
---|
9 |
|
---|
10 | class KdNode;
|
---|
11 | class Intersectable;
|
---|
12 |
|
---|
13 | // the values need for rss tree update computed already inside the glrendererbuffer
|
---|
14 | // not all of them need to be computed
|
---|
15 | class BeamSampleStatistics: public StatisticsBase
|
---|
16 | {
|
---|
17 | public:
|
---|
18 | enum {COMPUTE_PVS_SIZE, COMPUTE_RAY_CONTRIBUTIONS, COMPUTE_PVS_ENTROPY};
|
---|
19 | int flags;
|
---|
20 |
|
---|
21 | BeamSampleStatistics(): flags(COMPUTE_RAY_CONTRIBUTIONS)
|
---|
22 | {
|
---|
23 | Reset();
|
---|
24 | }
|
---|
25 |
|
---|
26 | float pvsSize;
|
---|
27 | float rays;
|
---|
28 | float rayContributions;
|
---|
29 | float pvsEntropy;
|
---|
30 | float rayLengthEntropy;
|
---|
31 | float importance;
|
---|
32 |
|
---|
33 | float weightedRayContribution;
|
---|
34 |
|
---|
35 | void Reset()
|
---|
36 | {
|
---|
37 | pvsSize = 0;
|
---|
38 | rays = 0;
|
---|
39 | rayContributions = 0;
|
---|
40 | pvsEntropy = 0;
|
---|
41 | rayLengthEntropy = 0;
|
---|
42 | importance = 0;
|
---|
43 | }
|
---|
44 |
|
---|
45 | void Print(ostream &app) const;
|
---|
46 |
|
---|
47 | friend ostream &operator<<(ostream &s, const BeamSampleStatistics &stat)
|
---|
48 | {
|
---|
49 | stat.Print(s);
|
---|
50 | return s;
|
---|
51 | }
|
---|
52 | };
|
---|
53 |
|
---|
54 |
|
---|
55 | class Beam {
|
---|
56 |
|
---|
57 | public:
|
---|
58 | enum {STORE_KD_NODES=1, STORE_OBJECTS=2, VALID=4};
|
---|
59 | int mFlags;
|
---|
60 |
|
---|
61 | // list of nodes intersected by the frustum
|
---|
62 | vector<KdNode *> mKdNodes;
|
---|
63 | // list of objects intersected by the frustum
|
---|
64 | ObjectContainer mObjects;
|
---|
65 | // view cells intersected by frustum
|
---|
66 | ViewCellContainer mViewCells;
|
---|
67 |
|
---|
68 | // spatial box
|
---|
69 | AxisAlignedBox3 mBox;
|
---|
70 | // directional box (it is actually a 2D box - only x and y ranges are valid)
|
---|
71 | // directional parametrization according to VssRay::GetDirParametrization
|
---|
72 | AxisAlignedBox3 mDirBox;
|
---|
73 |
|
---|
74 | vector<Plane3> mPlanes;
|
---|
75 |
|
---|
76 |
|
---|
77 | void Construct(const AxisAlignedBox3 &box,
|
---|
78 | const AxisAlignedBox3 &dBox);
|
---|
79 |
|
---|
80 | void ComputeFrustum(float &left, float &right,
|
---|
81 | float &bottom, float &top,
|
---|
82 | float &near, float &far,
|
---|
83 | const AxisAlignedBox3 &sceneBBox) const;
|
---|
84 |
|
---|
85 | int ComputeIntersection(const AxisAlignedBox3 &box);
|
---|
86 |
|
---|
87 | Vector3 GetMainDirection() const;
|
---|
88 |
|
---|
89 | bool IsValid() { return mFlags & VALID; }
|
---|
90 | bool SetValid() { return mFlags |= VALID; }
|
---|
91 |
|
---|
92 | Beam():mFlags(STORE_KD_NODES+STORE_OBJECTS), mKdNodes(0), mObjects(0)
|
---|
93 | {
|
---|
94 | }
|
---|
95 | };
|
---|
96 |
|
---|
97 |
|
---|
98 | #endif
|
---|