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

Revision 468, 2.8 KB checked in by mattausch, 19 years ago (diff)

updated rendersimulator

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()
29{}
30
31RenderSimulator::RenderSimulator(float objRenderCost,
32                                                                 float vcOverhead,
33                                                                 float moveSpeed):
34mObjRenderCost(objRenderCost),
35mVcOverhead(vcOverhead),
36mMoveSpeed(moveSpeed)
37{
38}
39
40void RenderSimulator::SetObjectRenderCost(const float objRenderCost)
41{
42        mObjRenderCost = objRenderCost;
43}
44
45void RenderSimulator::SetVcOverhead(const float vcOverhead)
46{
47        mVcOverhead = vcOverhead;
48}
49
50void RenderSimulator::SetMoveSpeed(const float moveSpeed)
51{
52        mMoveSpeed = moveSpeed;
53}
54
55bool 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
99float RenderSimulator::GetCrossVcProbability()
100{
101        return 0;
102}
103
104void RenderSimulator::GetStatistics(SimulationStatistics &simStats) const
105{
106        simStats = mSimulationStatistics;
107}
Note: See TracBrowser for help on using the repository browser.