[406] | 1 | #ifndef _RenderSimulator_h__
|
---|
| 2 | #define _RenderSimulator_h__
|
---|
| 3 |
|
---|
| 4 | #include "common.h"
|
---|
[414] | 5 | #include "Statistics.h"
|
---|
[406] | 6 |
|
---|
| 7 | class BspTree;
|
---|
| 8 | class KdTree;
|
---|
| 9 | class ViewCell;
|
---|
[407] | 10 | class KdLeaf;
|
---|
[449] | 11 | class VspKdTree;
|
---|
[448] | 12 | class VspBspTree;
|
---|
[406] | 13 |
|
---|
[414] | 14 | class SimulationStatistics: public StatisticsBase |
---|
| 15 | { |
---|
| 16 | public: |
---|
| 17 | /// view cell with the biggest "cost" |
---|
| 18 | float maxCost; |
---|
| 19 | /// view cell with the minimal "cost" |
---|
| 20 | float minCost; |
---|
| 21 | /// average render time |
---|
| 22 | float avgRenderTime; |
---|
| 23 | /// average render time with the overhead when crossing view cells |
---|
| 24 | float avgRtWithoutOverhead; |
---|
| 25 | |
---|
| 26 | void Reset() |
---|
| 27 | { |
---|
| 28 | maxCost = 0; |
---|
| 29 | minCost = 999999; |
---|
| 30 | avgRenderTime = 0; |
---|
| 31 | avgRtWithoutOverhead = 0; |
---|
| 32 | } |
---|
| 33 | |
---|
| 34 | void Print(ostream &app) const; |
---|
| 35 | |
---|
| 36 | friend ostream &operator<<(ostream &s, const SimulationStatistics &stat) |
---|
| 37 | { |
---|
| 38 | stat.Print(s); |
---|
| 39 | return s; |
---|
| 40 | } |
---|
[441] | 41 | |
---|
| 42 | SimulationStatistics() |
---|
| 43 | { |
---|
| 44 | Reset(); |
---|
| 45 | } |
---|
[414] | 46 | };
|
---|
| 47 |
|
---|
[406] | 48 | /** Simulated rendering using a simple render heuristics. Used to evaluate the |
---|
| 49 | quality of the view cell partition. |
---|
| 50 | */ |
---|
| 51 | class RenderSimulator |
---|
| 52 | { |
---|
[414] | 53 | |
---|
[406] | 54 | public: |
---|
| 55 | RenderSimulator(); |
---|
[439] | 56 | /** Constructor taking the estimated render cost, |
---|
| 57 | the view cell overhead, |
---|
| 58 | and the average move speed of the player into account. |
---|
| 59 | */ |
---|
[409] | 60 | RenderSimulator(float objRendercost, float vcOverhead, float moveSpeed); |
---|
[406] | 61 | |
---|
[439] | 62 | /** Simulates rendering of the view cells. |
---|
| 63 | @returns the statistics of the simulation. |
---|
| 64 | */ |
---|
| 65 | virtual SimulationStatistics SimulateRendering() = 0; |
---|
| 66 | |
---|
| 67 | /** Sets estimated render time for a single object in the PVS. |
---|
| 68 | */ |
---|
| 69 | void SetObjectRenderCost(const float objRenderCost); |
---|
| 70 | |
---|
| 71 | /** Contant overhead for crossing a view cell border. |
---|
| 72 | */ |
---|
| 73 | void SetVcOverhead(const float vcOverhead); |
---|
| 74 | |
---|
| 75 | /** Average move speed of the player during rendering. |
---|
| 76 | */ |
---|
| 77 | void SetMoveSpeed(const float moveSpeed); |
---|
| 78 | |
---|
| 79 | |
---|
| 80 | protected: |
---|
| 81 | |
---|
[409] | 82 | /// render time for single object of the PVS |
---|
[406] | 83 | float mObjRenderCost; |
---|
[409] | 84 | /// const overhead for crossing a view cell border |
---|
[406] | 85 | float mVcOverhead; |
---|
[409] | 86 | /// move speed of player |
---|
| 87 | float mMoveSpeed; |
---|
[406] | 88 | }; |
---|
| 89 | |
---|
[439] | 90 | class BspRenderSimulator: public RenderSimulator |
---|
[406] | 91 | { |
---|
| 92 | public: |
---|
[440] | 93 | BspRenderSimulator(BspTree *bspTree); |
---|
| 94 | |
---|
[439] | 95 | BspRenderSimulator(float objRenderCost, |
---|
[411] | 96 | float vcOverhead, |
---|
| 97 | float moveSpeed, |
---|
| 98 | BspTree *bspTree); |
---|
[406] | 99 | |
---|
[439] | 100 | SimulationStatistics SimulateRendering(); |
---|
[406] | 101 | |
---|
| 102 | protected: |
---|
| 103 | /** Simulates rendering of the pvs of one view cell, with given rendering time for an object. |
---|
| 104 | @param viewCell the view cell holding the Pvs |
---|
| 105 | @param objRenderTime estimated render time for one object of the Pvs |
---|
| 106 | */ |
---|
| 107 | Real RenderPvs(ViewCell &viewCell, const float objRenderTime) const; |
---|
| 108 | |
---|
[448] | 109 | private: |
---|
[406] | 110 | BspTree *mBspTree; |
---|
| 111 | }; |
---|
| 112 | |
---|
[448] | 113 | class VspBspRenderSimulator: public RenderSimulator |
---|
| 114 | { |
---|
| 115 | public: |
---|
| 116 | VspBspRenderSimulator(VspBspTree *vspBspTree); |
---|
| 117 | |
---|
| 118 | VspBspRenderSimulator(float objRenderCost, |
---|
| 119 | float vcOverhead, |
---|
| 120 | float moveSpeed, |
---|
| 121 | VspBspTree *vspBspTree); |
---|
| 122 | |
---|
| 123 | SimulationStatistics SimulateRendering(); |
---|
| 124 | |
---|
| 125 | protected: |
---|
| 126 | /** Simulates rendering of the pvs of one view cell, with given rendering time for an object. |
---|
| 127 | @param viewCell the view cell holding the Pvs |
---|
| 128 | @param objRenderTime estimated render time for one object of the Pvs |
---|
| 129 | */ |
---|
| 130 | Real RenderPvs(ViewCell &viewCell, const float objRenderTime) const; |
---|
| 131 | |
---|
| 132 | private: |
---|
| 133 | VspBspTree *mVspBspTree; |
---|
| 134 | }; |
---|
| 135 | |
---|
[439] | 136 | class KdRenderSimulator: public RenderSimulator |
---|
[406] | 137 | { |
---|
| 138 | public: |
---|
[440] | 139 | KdRenderSimulator(KdTree *kdTree); |
---|
| 140 | |
---|
[439] | 141 | KdRenderSimulator(float objRenderCost, |
---|
[411] | 142 | float vcOverhead, |
---|
| 143 | float moveSpeed, |
---|
| 144 | KdTree *kdTree); |
---|
[439] | 145 | SimulationStatistics SimulateRendering();
|
---|
[406] | 146 | |
---|
[407] | 147 | protected: |
---|
[406] | 148 | |
---|
[407] | 149 | Real RenderPvs(KdLeaf *leaf, float objRenderTime) const; |
---|
| 150 | |
---|
[406] | 151 | KdTree *mKdTree; |
---|
| 152 | };
|
---|
| 153 |
|
---|
[449] | 154 | class VspKdRenderSimulator: public RenderSimulator |
---|
| 155 | { |
---|
| 156 | public: |
---|
| 157 | VspKdRenderSimulator(VspKdTree *vspKdTree); |
---|
| 158 | |
---|
| 159 | VspKdRenderSimulator(float objRenderCost, |
---|
| 160 | float vcOverhead, |
---|
| 161 | float moveSpeed, |
---|
| 162 | VspKdTree *vspKdTree); |
---|
| 163 | |
---|
| 164 | SimulationStatistics SimulateRendering(); |
---|
| 165 | |
---|
| 166 | protected: |
---|
| 167 | /** Simulates rendering of the pvs of one view cell, with given rendering time for an object. |
---|
| 168 | @param viewCell the view cell holding the Pvs |
---|
| 169 | @param objRenderTime estimated render time for one object of the Pvs |
---|
| 170 | */ |
---|
| 171 | Real RenderPvs(ViewCell &viewCell, const float objRenderTime) const; |
---|
| 172 | |
---|
| 173 | private: |
---|
| 174 | VspKdTree *mVspKdTree; |
---|
| 175 | };
|
---|
| 176 |
|
---|
[406] | 177 | #endif // RenderSimulator
|
---|