1 | #ifndef _ViewCell_H__
|
---|
2 | #define _ViewCell_H__
|
---|
3 |
|
---|
4 | #include "Mesh.h"
|
---|
5 | #include "Containers.h"
|
---|
6 | #include "Ray.h"
|
---|
7 | #include "Statistics.h"
|
---|
8 | //namespace GtpVisibilityPreprocessor {
|
---|
9 |
|
---|
10 | class BspInterior;
|
---|
11 | class BspPvs;
|
---|
12 | struct Triangle3;
|
---|
13 | class BspLeaf;
|
---|
14 | class VspKdTree;
|
---|
15 | class VspKdLeaf;
|
---|
16 |
|
---|
17 |
|
---|
18 | /**
|
---|
19 | View cell with an optional mesh representation
|
---|
20 | */
|
---|
21 | class ViewCell: public MeshInstance
|
---|
22 | {
|
---|
23 | public:
|
---|
24 | ViewCell();
|
---|
25 |
|
---|
26 | /** Constructor taking a mesh representing the shape of the viewcell.
|
---|
27 | */
|
---|
28 | ViewCell(Mesh *mesh);
|
---|
29 |
|
---|
30 |
|
---|
31 | virtual ~ViewCell() {}
|
---|
32 | /** Returns Pvs.
|
---|
33 | */
|
---|
34 | const ViewCellPvs &GetPvs() const;
|
---|
35 | ViewCellPvs &GetPvs();
|
---|
36 |
|
---|
37 | int Type() const;
|
---|
38 |
|
---|
39 | /** Adds a passing ray to the passing ray container.
|
---|
40 | */
|
---|
41 | void AddPassingRay(const Ray &ray, const int contributions);
|
---|
42 |
|
---|
43 |
|
---|
44 | /// Ray set description of the rays passing through this node.
|
---|
45 | PassingRaySet mPassingRays;
|
---|
46 |
|
---|
47 | /// Rays piercing this view cell.
|
---|
48 | RayContainer mPiercingRays;
|
---|
49 |
|
---|
50 | protected:
|
---|
51 |
|
---|
52 | /// the potentially visible objects
|
---|
53 | ViewCellPvs mPvs;
|
---|
54 | };
|
---|
55 |
|
---|
56 | class BspViewCell: public ViewCell
|
---|
57 | {
|
---|
58 | public:
|
---|
59 | BspViewCell(): mBspLeaves(0) {}
|
---|
60 | BspViewCell(Mesh *mesh):
|
---|
61 | ViewCell(mesh), mBspLeaves(0) {}
|
---|
62 |
|
---|
63 | /// Leaves which hold this view cell.
|
---|
64 | vector<BspLeaf *> mBspLeaves;
|
---|
65 | };
|
---|
66 |
|
---|
67 | class VspKdViewCell: public ViewCell
|
---|
68 | {
|
---|
69 | public:
|
---|
70 | VspKdViewCell(): mVspKdLeaves(0) {}
|
---|
71 | VspKdViewCell(Mesh *mesh):
|
---|
72 | ViewCell(mesh), mVspKdLeaves(0) {}
|
---|
73 |
|
---|
74 | float GetSize() {return mSize;}
|
---|
75 | void SetSize(float size) {mSize = size;}
|
---|
76 |
|
---|
77 | /// Leaves which hold this view cell.
|
---|
78 | vector<VspKdLeaf *> mVspKdLeaves;
|
---|
79 |
|
---|
80 | protected:
|
---|
81 | float mSize;
|
---|
82 | };
|
---|
83 |
|
---|
84 | class ViewCellsStatistics: public StatisticsBase |
---|
85 | { |
---|
86 | public: |
---|
87 | |
---|
88 | /// number of view cells |
---|
89 | int viewCells; |
---|
90 | |
---|
91 | /// size of the PVS |
---|
92 | int pvs; |
---|
93 | |
---|
94 | /// largest PVS of all view cells |
---|
95 | int maxPvs; |
---|
96 | |
---|
97 | /// smallest PVS of all view cells |
---|
98 | int minPvs; |
---|
99 | |
---|
100 | /// view cells with empty PVS |
---|
101 | int emptyPvs; |
---|
102 | |
---|
103 | /// number of leaves covering the view space |
---|
104 | int leaves; |
---|
105 | |
---|
106 | /// largest number of leaves covered by one view cell |
---|
107 | int maxLeaves; |
---|
108 | |
---|
109 | // Constructor |
---|
110 | ViewCellsStatistics() |
---|
111 | { |
---|
112 | Reset(); |
---|
113 | } |
---|
114 | |
---|
115 | double AvgLeaves() const {return (double)leaves / (double)viewCells;}; |
---|
116 | double AvgPvs() const {return (double)pvs / (double)viewCells;}; |
---|
117 | |
---|
118 | void Reset() |
---|
119 | { |
---|
120 | viewCells = 0; |
---|
121 | pvs = 0; |
---|
122 | maxPvs = 0; |
---|
123 | |
---|
124 | minPvs = 999999; |
---|
125 | emptyPvs = 0; |
---|
126 | leaves = 0; |
---|
127 | maxLeaves = 0; |
---|
128 | } |
---|
129 | |
---|
130 | void Print(ostream &app) const; |
---|
131 | |
---|
132 | friend ostream &operator<<(ostream &s, const ViewCellsStatistics &stat) |
---|
133 | { |
---|
134 | stat.Print(s); |
---|
135 | return s; |
---|
136 | } |
---|
137 | }; |
---|
138 |
|
---|
139 | #endif
|
---|