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