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 |
|
---|
10 | namespace GtpVisibility {
|
---|
11 |
|
---|
12 | //-----------------------------------------------------------------------
|
---|
13 | VisibilityManager::VisibilityManager(VisibilityEnvironment *visEnvironment):
|
---|
14 | mVisibilityThreshold(0),
|
---|
15 | mCullingManager(NULL),
|
---|
16 | mQueryManager(NULL),
|
---|
17 | mPreprocessingManager(new DummyPreprocessingManager(NULL)),
|
---|
18 | mVisibilityEnvironment(visEnvironment),
|
---|
19 | mAssumedVisibilityForChc(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 | //-----------------------------------------------------------------------
|
---|
32 | VisibilityManager::~VisibilityManager()
|
---|
33 | {
|
---|
34 | delete mCullingManager;
|
---|
35 | delete mPreprocessingManager;
|
---|
36 | CullingLogManager::DelSingleton();
|
---|
37 | }
|
---|
38 | //-----------------------------------------------------------------------
|
---|
39 | void 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 | mCullingManager = new RandomUpdateCullingManager();
|
---|
62 | break;
|
---|
63 |
|
---|
64 | case VisibilityEnvironment::STOP_AND_WAIT_CULLING:
|
---|
65 | mCullingManager = new StopAndWaitCullingManager();
|
---|
66 | //mCullingManager = new RandomUpdateCullingManager();
|
---|
67 | break;
|
---|
68 |
|
---|
69 | default:
|
---|
70 | mCullingManager = new CoherentHierarchicalCullingManager(mAssumedVisibilityForChc);
|
---|
71 | break;
|
---|
72 |
|
---|
73 | }
|
---|
74 |
|
---|
75 | /////////
|
---|
76 | //-- set threshold
|
---|
77 | mCullingManager->SetVisibilityThreshold(mVisibilityThreshold);
|
---|
78 | }
|
---|
79 | }
|
---|
80 | //-----------------------------------------------------------------------
|
---|
81 | void VisibilityManager::SetVisibilityCullingThreshold(unsigned int visibilityThreshold)
|
---|
82 | {
|
---|
83 | mVisibilityThreshold = visibilityThreshold;
|
---|
84 | mCullingManager->SetVisibilityThreshold(mVisibilityThreshold);
|
---|
85 | }
|
---|
86 | //-----------------------------------------------------------------------
|
---|
87 | CullingManager *VisibilityManager::GetCullingManager()
|
---|
88 | {
|
---|
89 | return mCullingManager;
|
---|
90 | }
|
---|
91 | //-----------------------------------------------------------------------
|
---|
92 | void VisibilityManager::ApplyVisibilityCulling()
|
---|
93 | {
|
---|
94 | mCullingManager->RenderScene();
|
---|
95 | }
|
---|
96 | //-----------------------------------------------------------------------
|
---|
97 | VisibilityEnvironment::CullingManagerType VisibilityManager::GetCullingManagerType()
|
---|
98 | {
|
---|
99 | return mCullingManagerType;
|
---|
100 | }
|
---|
101 | //-----------------------------------------------------------------------
|
---|
102 | void VisibilityManager::SetQueryManager(QueryManager *queryManager)
|
---|
103 | {
|
---|
104 | mQueryManager = queryManager;
|
---|
105 | }
|
---|
106 | //-----------------------------------------------------------------------
|
---|
107 | QueryManager *VisibilityManager::GetQueryManager()
|
---|
108 | {
|
---|
109 | return mQueryManager;
|
---|
110 | }
|
---|
111 | //-----------------------------------------------------------------------
|
---|
112 | void VisibilityManager::SetAssumedVisibilityForChc(unsigned int assumedVisibility)
|
---|
113 |
|
---|
114 | {
|
---|
115 | mAssumedVisibilityForChc = assumedVisibility;
|
---|
116 |
|
---|
117 | // in case we currently use chc
|
---|
118 | if (VisibilityManager::GetCullingManagerType() ==
|
---|
119 | VisibilityEnvironment::COHERENT_HIERARCHICAL_CULLING)
|
---|
120 | {
|
---|
121 | static_cast<CoherentHierarchicalCullingManager *>(mCullingManager)->
|
---|
122 | SetAssumedVisibility(assumedVisibility);
|
---|
123 | }
|
---|
124 | }
|
---|
125 | //-----------------------------------------------------------------------
|
---|
126 | VisibilityEnvironment *VisibilityManager::GetVisibilityEnvironment()
|
---|
127 | {
|
---|
128 | return mVisibilityEnvironment;
|
---|
129 | }
|
---|
130 |
|
---|
131 | } // namespace GtpVisibility
|
---|