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