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

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