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