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