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 | struct Triangle3;
|
---|
11 |
|
---|
12 | class BspInterior;
|
---|
13 | class BspPvs;
|
---|
14 | class BspLeaf;
|
---|
15 | class VspKdTree;
|
---|
16 | class VspKdLeaf;
|
---|
17 | class KdLeaf;
|
---|
18 |
|
---|
19 | /**
|
---|
20 | View cell with an optional mesh representation
|
---|
21 | */
|
---|
22 | class ViewCell: public MeshInstance
|
---|
23 | {
|
---|
24 | public:
|
---|
25 | ViewCell();
|
---|
26 |
|
---|
27 | /** Constructor taking a mesh representing the shape of the viewcell.
|
---|
28 | */
|
---|
29 | ViewCell(Mesh *mesh);
|
---|
30 |
|
---|
31 | /** Default destructor.
|
---|
32 | */
|
---|
33 | virtual ~ViewCell() {}
|
---|
34 | /** Returns Pvs.
|
---|
35 | */
|
---|
36 | const ObjectPvs &GetPvs() const;
|
---|
37 | ObjectPvs &GetPvs();
|
---|
38 |
|
---|
39 | int Type() const;
|
---|
40 |
|
---|
41 | /** Adds a passing ray to the passing ray container.
|
---|
42 | */
|
---|
43 | void AddPassingRay(const Ray &ray, const int contributions);
|
---|
44 |
|
---|
45 | /** Returns volume of the view cell.
|
---|
46 | */
|
---|
47 | virtual float GetVolume() const;
|
---|
48 |
|
---|
49 | /** Sets volume of the view cell.
|
---|
50 | */
|
---|
51 | void SetVolume(float size);
|
---|
52 |
|
---|
53 | /// Ray set description of the rays passing through this node.
|
---|
54 | PassingRaySet mPassingRays;
|
---|
55 |
|
---|
56 | /// Rays piercing this view cell.
|
---|
57 | RayContainer mPiercingRays;
|
---|
58 |
|
---|
59 | protected:
|
---|
60 |
|
---|
61 | /// the potentially visible objects
|
---|
62 | ObjectPvs mPvs;
|
---|
63 |
|
---|
64 | float mVolume;
|
---|
65 | };
|
---|
66 |
|
---|
67 | /**
|
---|
68 | View cell belonging to a hierarchy.
|
---|
69 | */
|
---|
70 | template<typename T>
|
---|
71 | class HierarchyViewCell: public ViewCell
|
---|
72 | {
|
---|
73 | public:
|
---|
74 | HierarchyViewCell<T>(): mLeaves(0) {}
|
---|
75 | HierarchyViewCell<T>(Mesh *mesh):
|
---|
76 | ViewCell(mesh), mLeaves(0) {}
|
---|
77 |
|
---|
78 | /// Leaves of the hierarchy which are part of this view cell.
|
---|
79 | std::vector<T> mLeaves;
|
---|
80 | };
|
---|
81 |
|
---|
82 | typedef HierarchyViewCell<BspLeaf *> BspViewCell;
|
---|
83 | typedef HierarchyViewCell<KdLeaf *> KdViewCell;
|
---|
84 | typedef HierarchyViewCell<VspKdLeaf *> VspKdViewCell;
|
---|
85 |
|
---|
86 | /*class BspViewCell: public ViewCell
|
---|
87 | {
|
---|
88 | public:
|
---|
89 | BspViewCell(): mBspLeaves(0) {}
|
---|
90 | BspViewCell(Mesh *mesh):
|
---|
91 | ViewCell(mesh), mBspLeaves(0) {}
|
---|
92 |
|
---|
93 | /// Leaves of the hierarchy which are part of this view cell.
|
---|
94 | std::vector<BspLeaf *> mBspLeaves;
|
---|
95 | };
|
---|
96 | */
|
---|
97 | /*class VspKdViewCell: public ViewCell
|
---|
98 | {
|
---|
99 | public:
|
---|
100 | VspKdViewCell(): mLeaves(0) {}
|
---|
101 | VspKdViewCell(Mesh *mesh):
|
---|
102 | ViewCell(mesh), mLeaves(0) {}
|
---|
103 |
|
---|
104 | /// Leaves of the hierarchy which are part of this view cell.
|
---|
105 | std::vector<VspKdLeaf *> mLeaves;
|
---|
106 | };
|
---|
107 | */
|
---|
108 | class ViewCellsStatistics: public StatisticsBase
|
---|
109 | {
|
---|
110 | public:
|
---|
111 |
|
---|
112 | /// number of view cells
|
---|
113 | int viewCells;
|
---|
114 |
|
---|
115 | /// size of the PVS
|
---|
116 | int pvs;
|
---|
117 |
|
---|
118 | /// largest PVS of all view cells
|
---|
119 | int maxPvs;
|
---|
120 |
|
---|
121 | /// smallest PVS of all view cells
|
---|
122 | int minPvs;
|
---|
123 |
|
---|
124 | /// view cells with empty PVS
|
---|
125 | int emptyPvs;
|
---|
126 |
|
---|
127 | /// number of leaves covering the view space
|
---|
128 | int leaves;
|
---|
129 |
|
---|
130 | /// largest number of leaves covered by one view cell
|
---|
131 | int maxLeaves;
|
---|
132 |
|
---|
133 | // Constructor
|
---|
134 | ViewCellsStatistics()
|
---|
135 | {
|
---|
136 | Reset();
|
---|
137 | }
|
---|
138 |
|
---|
139 | double AvgLeaves() const {return (double)leaves / (double)viewCells;};
|
---|
140 | double AvgPvs() const {return (double)pvs / (double)viewCells;};
|
---|
141 |
|
---|
142 | void Reset()
|
---|
143 | {
|
---|
144 | viewCells = 0;
|
---|
145 | pvs = 0;
|
---|
146 | maxPvs = 0;
|
---|
147 |
|
---|
148 | minPvs = 999999;
|
---|
149 | emptyPvs = 0;
|
---|
150 | leaves = 0;
|
---|
151 | maxLeaves = 0;
|
---|
152 | }
|
---|
153 |
|
---|
154 | void Print(ostream &app) const;
|
---|
155 |
|
---|
156 | friend ostream &operator<<(ostream &s, const ViewCellsStatistics &stat)
|
---|
157 | {
|
---|
158 | stat.Print(s);
|
---|
159 | return s;
|
---|
160 | }
|
---|
161 | };
|
---|
162 |
|
---|
163 | #endif
|
---|