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 | #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 | //-----------------------------------------------------------------------
|
---|
31 | VisibilityManager::~VisibilityManager()
|
---|
32 | {
|
---|
33 | delete mCullingManager;
|
---|
34 | delete mPreprocessingManager;
|
---|
35 | }
|
---|
36 | //-----------------------------------------------------------------------
|
---|
37 | void 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 | //-----------------------------------------------------------------------
|
---|
77 | void VisibilityManager::SetVisibilityCullingThreshold(unsigned int visibilityThreshold)
|
---|
78 | {
|
---|
79 | mVisibilityThreshold = visibilityThreshold;
|
---|
80 | mCullingManager->SetVisibilityThreshold(mVisibilityThreshold);
|
---|
81 | }
|
---|
82 | //-----------------------------------------------------------------------
|
---|
83 | CullingManager *VisibilityManager::GetCullingManager()
|
---|
84 | {
|
---|
85 | return mCullingManager;
|
---|
86 | }
|
---|
87 | //-----------------------------------------------------------------------
|
---|
88 | void VisibilityManager::ApplyVisibilityCulling()
|
---|
89 | {
|
---|
90 | mCullingManager->RenderScene();
|
---|
91 | }
|
---|
92 | //-----------------------------------------------------------------------
|
---|
93 | VisibilityEnvironment::CullingManagerType VisibilityManager::GetCullingManagerType()
|
---|
94 | {
|
---|
95 | return mCullingManagerType;
|
---|
96 | }
|
---|
97 | //-----------------------------------------------------------------------
|
---|
98 | void VisibilityManager::SetQueryManager(QueryManager *queryManager)
|
---|
99 | {
|
---|
100 | mQueryManager = queryManager;
|
---|
101 | }
|
---|
102 | //-----------------------------------------------------------------------
|
---|
103 | QueryManager *VisibilityManager::GetQueryManager()
|
---|
104 | {
|
---|
105 | return mQueryManager;
|
---|
106 | }
|
---|
107 | //-----------------------------------------------------------------------
|
---|
108 | void 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 | //-----------------------------------------------------------------------
|
---|
122 | VisibilityEnvironment *VisibilityManager::GetVisibilityEnvironment()
|
---|
123 | {
|
---|
124 | return mVisibilityEnvironment;
|
---|
125 | }
|
---|
126 |
|
---|
127 | } // namespace GtpVisibility
|
---|