source: trunk/VUT/GtpVisibilityPreprocessor/src/RenderSimulator.cpp @ 473

Revision 473, 2.9 KB checked in by mattausch, 19 years ago (diff)

worked on new features,
removed Random Bug (took only 32000 values),
removed bug when choosing new candidates (totally wrong)
introduced new candidate plane method
implemented priority queue for vsp bsp

Line 
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
9void 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
28RenderSimulator::RenderSimulator(ViewCellsManager *viewCellsManager):
29Renderer(viewCellsManager)
30{}
31
32RenderSimulator::RenderSimulator(ViewCellsManager *viewCellsManager,
33                                                                 float objRenderCost,
34                                                                 float vcOverhead,
35                                                                 float moveSpeed):
36Renderer(viewCellsManager),
37mObjRenderCost(objRenderCost),
38mVcOverhead(vcOverhead),
39mMoveSpeed(moveSpeed)
40{
41}
42
43void RenderSimulator::SetObjectRenderCost(const float objRenderCost)
44{
45        mObjRenderCost = objRenderCost;
46}
47
48void RenderSimulator::SetVcOverhead(const float vcOverhead)
49{
50        mVcOverhead = vcOverhead;
51}
52
53void RenderSimulator::SetMoveSpeed(const float moveSpeed)
54{
55        mMoveSpeed = moveSpeed;
56}
57
58bool RenderSimulator::RenderScene()
59{
60        mSimulationStatistics.Reset();
61        mSimulationStatistics.Start();
62
63        Real renderTime = 0;
64       
65        // overhead for loading the PVS of the view cells
66        float loadPvsOverhead = 0;
67       
68        ViewCellContainer::const_iterator it,
69                it_end = mViewCellsManager->GetViewCells().end();
70
71        for (it = mViewCellsManager->GetViewCells().begin(); it != it_end; ++ it)
72        {
73                ViewCell *vc = *it;
74
75                // probability of view cell
76                const float pInVc = mViewCellsManager->GetProbability(vc);
77                               
78                // compute render time of PVS times probability that view point is in view cell
79                const float vcCost = pInVc * mViewCellsManager->GetRendercost(vc, mObjRenderCost);
80       
81                // crossing the border of a view cell is depending on the move speed
82                // and the probability that a view cell border is crossed
83                loadPvsOverhead += GetCrossVcProbability() * mVcOverhead;
84
85                //-- update statistics
86                renderTime += vcCost;
87       
88                if (vcCost > mSimulationStatistics.maxCost)
89                        mSimulationStatistics.maxCost = vcCost;
90                else if (vcCost < mSimulationStatistics.minCost)
91                        mSimulationStatistics.minCost = vcCost;
92        }
93       
94        mSimulationStatistics.avgRtWithoutOverhead = renderTime;
95        mSimulationStatistics.avgRenderTime = renderTime + loadPvsOverhead;
96       
97        mSimulationStatistics.Stop();
98
99        return true;
100}
101
102float RenderSimulator::GetCrossVcProbability()
103{
104        return 0;
105}
106
107void RenderSimulator::GetStatistics(SimulationStatistics &simStats) const
108{
109        simStats = mSimulationStatistics;
110}
Note: See TracBrowser for help on using the repository browser.