source: GTP/trunk/Lib/Vis/OnlineCullingCHC/src/VisibilityManager.cpp @ 2289

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