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