source: trunk/VUT/GtpVisibility/src/VisibilityManager.cpp @ 371

Revision 371, 3.7 KB checked in by mattausch, 19 years ago (diff)

added render heuristics evaluation

Line 
1#include "VisibilityManager.h"
2#include "StopAndWaitCullingManager.h"
3#include "CoherentHierarchicalCullingManager.h"
4#include "FrustumCullingManager.h"
5#include "DummyPreprocessingManager.h"
6#include "DummyQueryManager.h"
7//#include "BatchedQueriesCullingManager.h"
8
9namespace GtpVisibility {
10
11//-----------------------------------------------------------------------
12VisibilityManager::VisibilityManager(VisibilityEnvironment *visEnvironment):
13mVisibilityThreshold(0), mCullingManager(NULL),
14mQueryManager(NULL),
15mPreprocessingManager(new DummyPreprocessingManager(NULL)),
16mVisibilityEnvironment(visEnvironment),
17mAssumedVisibilityForChc(0)
18{
19        SetCullingManager(VisibilityEnvironment::COHERENT_HIERARCHICAL_CULLING);
20        //SetCullingManager(VisibilityEnvironment::STOP_AND_WAIT_CULLING);
21        //SetCullingManager(VisibilityEnvironment::FRUSTUM_CULLING);
22}
23//-----------------------------------------------------------------------
24VisibilityManager::~VisibilityManager()
25{
26        delete mCullingManager;
27        delete mPreprocessingManager;
28}
29//-----------------------------------------------------------------------
30void VisibilityManager::SetCullingManager(VisibilityEnvironment::
31                                                                                  CullingManagerType ocmType)
32{
33        // change only if necessary
34        if (!mCullingManager || (mCullingManagerType != ocmType))
35        {
36                // delete old culling manager
37                if (mCullingManager)
38                {
39                        delete mCullingManager;
40                }
41
42                mCullingManagerType = ocmType;
43               
44                switch (ocmType)
45                {
46                case VisibilityEnvironment::STOP_AND_WAIT_CULLING:
47                        mCullingManager = new StopAndWaitCullingManager();
48                                //new BatchedQueriesCullingManager();
49                        break;
50
51                case VisibilityEnvironment::COHERENT_HIERARCHICAL_CULLING:
52                        mCullingManager = new CoherentHierarchicalCullingManager(mAssumedVisibilityForChc);
53                        break;
54
55                case VisibilityEnvironment::FRUSTUM_CULLING:
56                        mCullingManager = new FrustumCullingManager();
57                        break;
58
59                default:
60                        mCullingManager = new StopAndWaitCullingManager();
61                        break;
62
63                }
64
65                //-- set threshold
66                mCullingManager->SetVisibilityThreshold(mVisibilityThreshold);         
67        }
68}
69//-----------------------------------------------------------------------
70void VisibilityManager::SetVisibilityCullingThreshold(unsigned int visibilityThreshold)
71{
72        mVisibilityThreshold = visibilityThreshold;
73        mCullingManager->SetVisibilityThreshold(mVisibilityThreshold);
74}
75//-----------------------------------------------------------------------
76CullingManager *VisibilityManager::GetCullingManager()
77{
78        return mCullingManager;
79}
80//-----------------------------------------------------------------------
81void VisibilityManager::ApplyVisibilityCulling()
82{
83        mCullingManager->RenderScene();
84}
85//-----------------------------------------------------------------------
86VisibilityEnvironment::CullingManagerType VisibilityManager::GetCullingManagerType()
87{
88        return mCullingManagerType;
89}
90//-----------------------------------------------------------------------
91void VisibilityManager::SetQueryManager(QueryManager *queryManager)
92{
93        mQueryManager = queryManager;
94}
95//-----------------------------------------------------------------------
96QueryManager *VisibilityManager::GetQueryManager()
97{
98        return mQueryManager;
99}
100//-----------------------------------------------------------------------
101void VisibilityManager::SetAssumedVisibilityForChc(unsigned int assumedVisibility)
102                                                                         
103{
104        mAssumedVisibilityForChc = assumedVisibility;
105
106        // in case we currently use chc
107        if (VisibilityManager::GetCullingManagerType() ==
108                VisibilityEnvironment::COHERENT_HIERARCHICAL_CULLING)
109        {
110                dynamic_cast<CoherentHierarchicalCullingManager *>(mCullingManager)->
111                                SetAssumedVisibility(assumedVisibility);
112        }
113}
114
115
116} // namespace GtpVisibility
Note: See TracBrowser for help on using the repository browser.