[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;
|
---|
[406] | 11 |
|
---|
[414] | 12 | class SimulationStatistics: public StatisticsBase |
---|
| 13 | { |
---|
| 14 | public: |
---|
| 15 | /// view cell with the biggest "cost" |
---|
| 16 | float maxCost; |
---|
| 17 | /// view cell with the minimal "cost" |
---|
| 18 | float minCost; |
---|
| 19 | /// average render time |
---|
| 20 | float avgRenderTime; |
---|
| 21 | /// average render time with the overhead when crossing view cells |
---|
| 22 | float avgRtWithoutOverhead; |
---|
| 23 | |
---|
| 24 | void Reset() |
---|
| 25 | { |
---|
| 26 | maxCost = 0; |
---|
| 27 | minCost = 999999; |
---|
| 28 | avgRenderTime = 0; |
---|
| 29 | avgRtWithoutOverhead = 0; |
---|
| 30 | } |
---|
| 31 | |
---|
| 32 | void Print(ostream &app) const; |
---|
| 33 | |
---|
| 34 | friend ostream &operator<<(ostream &s, const SimulationStatistics &stat) |
---|
| 35 | { |
---|
| 36 | stat.Print(s); |
---|
| 37 | return s; |
---|
| 38 | } |
---|
| 39 | };
|
---|
| 40 |
|
---|
[406] | 41 | /** Simulated rendering using a simple render heuristics. Used to evaluate the |
---|
| 42 | quality of the view cell partition. |
---|
| 43 | */ |
---|
| 44 | class RenderSimulator |
---|
| 45 | { |
---|
[414] | 46 | |
---|
[406] | 47 | public: |
---|
| 48 | RenderSimulator(); |
---|
[439] | 49 | /** Constructor taking the estimated render cost, |
---|
| 50 | the view cell overhead, |
---|
| 51 | and the average move speed of the player into account. |
---|
| 52 | */ |
---|
[409] | 53 | RenderSimulator(float objRendercost, float vcOverhead, float moveSpeed); |
---|
[406] | 54 | |
---|
[439] | 55 | /** Simulates rendering of the view cells. |
---|
| 56 | @returns the statistics of the simulation. |
---|
| 57 | */ |
---|
| 58 | virtual SimulationStatistics SimulateRendering() = 0; |
---|
| 59 | |
---|
| 60 | /** Sets estimated render time for a single object in the PVS. |
---|
| 61 | */ |
---|
| 62 | void SetObjectRenderCost(const float objRenderCost); |
---|
| 63 | |
---|
| 64 | /** Contant overhead for crossing a view cell border. |
---|
| 65 | */ |
---|
| 66 | void SetVcOverhead(const float vcOverhead); |
---|
| 67 | |
---|
| 68 | /** Average move speed of the player during rendering. |
---|
| 69 | */ |
---|
| 70 | void SetMoveSpeed(const float moveSpeed); |
---|
| 71 | |
---|
| 72 | |
---|
| 73 | protected: |
---|
| 74 | |
---|
[409] | 75 | /// render time for single object of the PVS |
---|
[406] | 76 | float mObjRenderCost; |
---|
[409] | 77 | /// const overhead for crossing a view cell border |
---|
[406] | 78 | float mVcOverhead; |
---|
[409] | 79 | /// move speed of player |
---|
| 80 | float mMoveSpeed; |
---|
[406] | 81 | }; |
---|
| 82 | |
---|
[439] | 83 | class BspRenderSimulator: public RenderSimulator |
---|
[406] | 84 | { |
---|
| 85 | public: |
---|
[440] | 86 | BspRenderSimulator(BspTree *bspTree); |
---|
| 87 | |
---|
[439] | 88 | BspRenderSimulator(float objRenderCost, |
---|
[411] | 89 | float vcOverhead, |
---|
| 90 | float moveSpeed, |
---|
| 91 | BspTree *bspTree); |
---|
[406] | 92 | |
---|
[439] | 93 | SimulationStatistics SimulateRendering(); |
---|
[406] | 94 | |
---|
| 95 | protected: |
---|
| 96 | /** Simulates rendering of the pvs of one view cell, with given rendering time for an object. |
---|
| 97 | @param viewCell the view cell holding the Pvs |
---|
| 98 | @param objRenderTime estimated render time for one object of the Pvs |
---|
| 99 | */ |
---|
| 100 | Real RenderPvs(ViewCell &viewCell, const float objRenderTime) const; |
---|
| 101 | |
---|
| 102 | BspTree *mBspTree; |
---|
| 103 | }; |
---|
| 104 | |
---|
[439] | 105 | class KdRenderSimulator: public RenderSimulator |
---|
[406] | 106 | { |
---|
| 107 | public: |
---|
[440] | 108 | KdRenderSimulator(KdTree *kdTree); |
---|
| 109 | |
---|
[439] | 110 | KdRenderSimulator(float objRenderCost, |
---|
[411] | 111 | float vcOverhead, |
---|
| 112 | float moveSpeed, |
---|
| 113 | KdTree *kdTree); |
---|
[439] | 114 | SimulationStatistics SimulateRendering();
|
---|
[406] | 115 | |
---|
[407] | 116 | protected: |
---|
[406] | 117 | |
---|
[407] | 118 | Real RenderPvs(KdLeaf *leaf, float objRenderTime) const; |
---|
| 119 | |
---|
[406] | 120 | KdTree *mKdTree; |
---|
| 121 | };
|
---|
| 122 |
|
---|
| 123 | #endif // RenderSimulator
|
---|