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