1 | #include "RenderSimulator.h"
|
---|
2 | #include "KdTree.h"
|
---|
3 | #include "ViewCellBsp.h"
|
---|
4 | #include "ViewCell.h"
|
---|
5 | #include "VspBspTree.h"
|
---|
6 | #include "VspKdTree.h"
|
---|
7 | #include "ViewCellsManager.h"
|
---|
8 |
|
---|
9 | void SimulationStatistics::Print(ostream &app) const
|
---|
10 | {
|
---|
11 | app << "===== Simulation statistics ===============\n";
|
---|
12 |
|
---|
13 | app << setprecision(4);
|
---|
14 |
|
---|
15 | app << "#N_CTIME ( Simulation time [s] )\n" << Time() << " \n";
|
---|
16 |
|
---|
17 | app << "#MAX_COST ( maximal cost of a view cell )\n" << maxCost << "\n";
|
---|
18 |
|
---|
19 | app << "#MIN_COST ( minimal cost of a view cell )\n" << minCost << "\n";
|
---|
20 |
|
---|
21 | app << "#AVG_RENDER_TIME ( average render time )\n" << avgRenderTime << "\n";
|
---|
22 |
|
---|
23 | app << "#AVG_RENDER_TIME_NO_OVERHEAD ( average render time without overhead )\n" << avgRtWithoutOverhead << "\n";
|
---|
24 |
|
---|
25 | app << "===== END OF Simulation statistics ==========\n";
|
---|
26 | }
|
---|
27 |
|
---|
28 | RenderSimulator::RenderSimulator()
|
---|
29 | {}
|
---|
30 |
|
---|
31 | RenderSimulator::RenderSimulator(float objRenderCost,
|
---|
32 | float vcOverhead,
|
---|
33 | float moveSpeed):
|
---|
34 | mObjRenderCost(objRenderCost),
|
---|
35 | mVcOverhead(vcOverhead),
|
---|
36 | mMoveSpeed(moveSpeed)
|
---|
37 | {
|
---|
38 | }
|
---|
39 |
|
---|
40 | void RenderSimulator::SetObjectRenderCost(const float objRenderCost)
|
---|
41 | {
|
---|
42 | mObjRenderCost = objRenderCost;
|
---|
43 | }
|
---|
44 |
|
---|
45 | void RenderSimulator::SetVcOverhead(const float vcOverhead)
|
---|
46 | {
|
---|
47 | mVcOverhead = vcOverhead;
|
---|
48 | }
|
---|
49 |
|
---|
50 | void RenderSimulator::SetMoveSpeed(const float moveSpeed)
|
---|
51 | {
|
---|
52 | mMoveSpeed = moveSpeed;
|
---|
53 | }
|
---|
54 |
|
---|
55 | bool RenderSimulator::RenderScene()
|
---|
56 | {
|
---|
57 | mSimulationStatistics.Reset();
|
---|
58 | mSimulationStatistics.Start();
|
---|
59 |
|
---|
60 | Real renderTime = 0;
|
---|
61 |
|
---|
62 | // overhead for loading the PVS of the view cells
|
---|
63 | float loadPvsOverhead = 0;
|
---|
64 |
|
---|
65 | ViewCellContainer::const_iterator it,
|
---|
66 | it_end = mViewCellsManager->GetViewCells().end();
|
---|
67 |
|
---|
68 | for (it = mViewCellsManager->GetViewCells().begin(); it != it_end; ++ it)
|
---|
69 | {
|
---|
70 | ViewCell *vc = *it;
|
---|
71 |
|
---|
72 | // probability of view cell
|
---|
73 | const float pInVc = mViewCellsManager->GetProbability(vc);
|
---|
74 |
|
---|
75 | // compute render time of PVS times probability that view point is in view cell
|
---|
76 | const float vcCost = pInVc * mViewCellsManager->GetRendercost(vc, mObjRenderCost);
|
---|
77 |
|
---|
78 | // crossing the border of a view cell is depending on the move speed
|
---|
79 | // and the probability that a view cell border is crossed
|
---|
80 | loadPvsOverhead += GetCrossVcProbability() * mVcOverhead;
|
---|
81 |
|
---|
82 | //-- update statistics
|
---|
83 | renderTime += vcCost;
|
---|
84 |
|
---|
85 | if (vcCost > mSimulationStatistics.maxCost)
|
---|
86 | mSimulationStatistics.maxCost = vcCost;
|
---|
87 | else if (vcCost < mSimulationStatistics.minCost)
|
---|
88 | mSimulationStatistics.minCost = vcCost;
|
---|
89 | }
|
---|
90 |
|
---|
91 | mSimulationStatistics.avgRtWithoutOverhead = renderTime;
|
---|
92 | mSimulationStatistics.avgRenderTime = renderTime + loadPvsOverhead;
|
---|
93 |
|
---|
94 | mSimulationStatistics.Stop();
|
---|
95 |
|
---|
96 | return true;
|
---|
97 | }
|
---|
98 |
|
---|
99 | float RenderSimulator::GetCrossVcProbability()
|
---|
100 | {
|
---|
101 | return 0;
|
---|
102 | }
|
---|
103 |
|
---|
104 | void RenderSimulator::GetStatistics(SimulationStatistics &simStats) const
|
---|
105 | {
|
---|
106 | simStats = mSimulationStatistics;
|
---|
107 | } |
---|