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(new DummyQueryManager(NULL)),
|
---|
14 | mPreprocessingManager(new DummyPreprocessingManager(NULL)),
|
---|
15 | mVisibilityEnvironment(visEnvironment)
|
---|
16 | {
|
---|
17 | SetCullingManager(VisibilityEnvironment::COHERENT_HIERARCHICAL_CULLING);
|
---|
18 | //SetCullingManager(VisibilityEnvironment::STOP_AND_WAIT_CULLING);
|
---|
19 | //SetCullingManager(VisibilityEnvironment::FRUSTUM_CULLING);
|
---|
20 | }
|
---|
21 | //-----------------------------------------------------------------------
|
---|
22 | VisibilityManager::~VisibilityManager()
|
---|
23 | {
|
---|
24 | delete mCullingManager;
|
---|
25 | }
|
---|
26 | //-----------------------------------------------------------------------
|
---|
27 | void VisibilityManager::SetCullingManager(
|
---|
28 | VisibilityEnvironment::CullingManagerType ocmType)
|
---|
29 | {
|
---|
30 | // change only if necessary
|
---|
31 | if (!mCullingManager || (mCullingManagerType != ocmType))
|
---|
32 | {
|
---|
33 | // delete old culling manager
|
---|
34 | if (mCullingManager)
|
---|
35 | {
|
---|
36 | delete mCullingManager;
|
---|
37 | }
|
---|
38 | mCullingManagerType = ocmType;
|
---|
39 |
|
---|
40 | switch (ocmType)
|
---|
41 | {
|
---|
42 | case VisibilityEnvironment::STOP_AND_WAIT_CULLING:
|
---|
43 | mCullingManager = new StopAndWaitCullingManager();
|
---|
44 | break;
|
---|
45 |
|
---|
46 | case VisibilityEnvironment::COHERENT_HIERARCHICAL_CULLING:
|
---|
47 | mCullingManager = new CoherentHierarchicalCullingManager();
|
---|
48 | break;
|
---|
49 |
|
---|
50 | case VisibilityEnvironment::FRUSTUM_CULLING:
|
---|
51 | mCullingManager = new FrustumCullingManager();
|
---|
52 | break;
|
---|
53 |
|
---|
54 | default:
|
---|
55 | mCullingManager = new StopAndWaitCullingManager();
|
---|
56 | break;
|
---|
57 |
|
---|
58 | }
|
---|
59 |
|
---|
60 | // -- set threshold
|
---|
61 | mCullingManager->SetVisibilityThreshold(mVisibilityThreshold);
|
---|
62 | }
|
---|
63 | }
|
---|
64 | //-----------------------------------------------------------------------
|
---|
65 | void VisibilityManager::SetVisibilityCullingThreshold(unsigned int visibilityThreshold)
|
---|
66 | {
|
---|
67 | mVisibilityThreshold = visibilityThreshold;
|
---|
68 | mCullingManager->SetVisibilityThreshold(mVisibilityThreshold);
|
---|
69 | }
|
---|
70 | //-----------------------------------------------------------------------
|
---|
71 | CullingManager *VisibilityManager::GetCullingManager()
|
---|
72 | {
|
---|
73 | return mCullingManager;
|
---|
74 | }
|
---|
75 | //-----------------------------------------------------------------------
|
---|
76 | void VisibilityManager::ApplyVisibilityCulling()
|
---|
77 | {
|
---|
78 | mCullingManager->RenderScene();
|
---|
79 | }
|
---|
80 | //-----------------------------------------------------------------------
|
---|
81 | VisibilityEnvironment::CullingManagerType VisibilityManager::GetCullingManagerType()
|
---|
82 | {
|
---|
83 | return mCullingManagerType;
|
---|
84 | }
|
---|
85 |
|
---|
86 | } // namespace GtpVisibility
|
---|