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