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

Revision 925, 3.9 KB checked in by mattausch, 19 years ago (diff)

update for ogre 1.2
OcclusionCullingSceneManager? is the only scenemanager in the solution now

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