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 |
|
---|
9 | namespace GtpVisibility {
|
---|
10 |
|
---|
11 | //-----------------------------------------------------------------------
|
---|
12 | VisibilityManager::VisibilityManager(VisibilityEnvironment *visEnvironment):
|
---|
13 | mVisibilityThreshold(0),
|
---|
14 | mCullingManager(NULL),
|
---|
15 | mQueryManager(NULL),
|
---|
16 | mPreprocessingManager(new DummyPreprocessingManager(NULL)),
|
---|
17 | mVisibilityEnvironment(visEnvironment),
|
---|
18 | mAssumedVisibilityForChc(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 | //-----------------------------------------------------------------------
|
---|
32 | VisibilityManager::~VisibilityManager()
|
---|
33 | {
|
---|
34 | delete mCullingManager;
|
---|
35 | delete mPreprocessingManager;
|
---|
36 | }
|
---|
37 | //-----------------------------------------------------------------------
|
---|
38 | void 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 | //-----------------------------------------------------------------------
|
---|
78 | void VisibilityManager::SetVisibilityCullingThreshold(unsigned int visibilityThreshold)
|
---|
79 | {
|
---|
80 | mVisibilityThreshold = visibilityThreshold;
|
---|
81 | mCullingManager->SetVisibilityThreshold(mVisibilityThreshold);
|
---|
82 | }
|
---|
83 | //-----------------------------------------------------------------------
|
---|
84 | CullingManager *VisibilityManager::GetCullingManager()
|
---|
85 | {
|
---|
86 | return mCullingManager;
|
---|
87 | }
|
---|
88 | //-----------------------------------------------------------------------
|
---|
89 | void VisibilityManager::ApplyVisibilityCulling()
|
---|
90 | {
|
---|
91 | mCullingManager->RenderScene();
|
---|
92 | }
|
---|
93 | //-----------------------------------------------------------------------
|
---|
94 | VisibilityEnvironment::CullingManagerType VisibilityManager::GetCullingManagerType()
|
---|
95 | {
|
---|
96 | return mCullingManagerType;
|
---|
97 | }
|
---|
98 | //-----------------------------------------------------------------------
|
---|
99 | void VisibilityManager::SetQueryManager(QueryManager *queryManager)
|
---|
100 | {
|
---|
101 | mQueryManager = queryManager;
|
---|
102 | }
|
---|
103 | //-----------------------------------------------------------------------
|
---|
104 | QueryManager *VisibilityManager::GetQueryManager()
|
---|
105 | {
|
---|
106 | return mQueryManager;
|
---|
107 | }
|
---|
108 | //-----------------------------------------------------------------------
|
---|
109 | void 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
|
---|