[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:
|
---|
[2278] | 60 | //mCullingManager = new FrustumCullingManager();
|
---|
[2287] | 61 | mCullingManager = new RandomUpdateCullingManager();
|
---|
[59] | 62 | break;
|
---|
[114] | 63 |
|
---|
[2287] | 64 | case VisibilityEnvironment::STOP_AND_WAIT_CULLING:
|
---|
| 65 | mCullingManager = new StopAndWaitCullingManager();
|
---|
| 66 | //mCullingManager = new RandomUpdateCullingManager();
|
---|
| 67 | break;
|
---|
| 68 |
|
---|
[59] | 69 | default:
|
---|
[2280] | 70 | mCullingManager = new CoherentHierarchicalCullingManager(mAssumedVisibilityForChc);
|
---|
[59] | 71 | break;
|
---|
[114] | 72 |
|
---|
[59] | 73 | }
|
---|
[114] | 74 |
|
---|
[2280] | 75 | /////////
|
---|
[254] | 76 | //-- set threshold
|
---|
[2280] | 77 | mCullingManager->SetVisibilityThreshold(mVisibilityThreshold);
|
---|
[59] | 78 | }
|
---|
| 79 | }
|
---|
[74] | 80 | //-----------------------------------------------------------------------
|
---|
| 81 | void VisibilityManager::SetVisibilityCullingThreshold(unsigned int visibilityThreshold)
|
---|
| 82 | {
|
---|
| 83 | mVisibilityThreshold = visibilityThreshold;
|
---|
| 84 | mCullingManager->SetVisibilityThreshold(mVisibilityThreshold);
|
---|
| 85 | }
|
---|
| 86 | //-----------------------------------------------------------------------
|
---|
[59] | 87 | CullingManager *VisibilityManager::GetCullingManager()
|
---|
| 88 | {
|
---|
| 89 | return mCullingManager;
|
---|
| 90 | }
|
---|
[74] | 91 | //-----------------------------------------------------------------------
|
---|
[59] | 92 | void VisibilityManager::ApplyVisibilityCulling()
|
---|
| 93 | {
|
---|
| 94 | mCullingManager->RenderScene();
|
---|
| 95 | }
|
---|
[100] | 96 | //-----------------------------------------------------------------------
|
---|
[92] | 97 | VisibilityEnvironment::CullingManagerType VisibilityManager::GetCullingManagerType()
|
---|
| 98 | {
|
---|
| 99 | return mCullingManagerType;
|
---|
| 100 | }
|
---|
[130] | 101 | //-----------------------------------------------------------------------
|
---|
| 102 | void VisibilityManager::SetQueryManager(QueryManager *queryManager)
|
---|
| 103 | {
|
---|
| 104 | mQueryManager = queryManager;
|
---|
| 105 | }
|
---|
| 106 | //-----------------------------------------------------------------------
|
---|
| 107 | QueryManager *VisibilityManager::GetQueryManager()
|
---|
| 108 | {
|
---|
| 109 | return mQueryManager;
|
---|
| 110 | }
|
---|
[153] | 111 | //-----------------------------------------------------------------------
|
---|
[155] | 112 | void VisibilityManager::SetAssumedVisibilityForChc(unsigned int assumedVisibility)
|
---|
| 113 |
|
---|
[146] | 114 | {
|
---|
[155] | 115 | mAssumedVisibilityForChc = assumedVisibility;
|
---|
[146] | 116 |
|
---|
[155] | 117 | // in case we currently use chc
|
---|
[146] | 118 | if (VisibilityManager::GetCullingManagerType() ==
|
---|
| 119 | VisibilityEnvironment::COHERENT_HIERARCHICAL_CULLING)
|
---|
| 120 | {
|
---|
[2066] | 121 | static_cast<CoherentHierarchicalCullingManager *>(mCullingManager)->
|
---|
[155] | 122 | SetAssumedVisibility(assumedVisibility);
|
---|
[146] | 123 | }
|
---|
| 124 | }
|
---|
[925] | 125 | //-----------------------------------------------------------------------
|
---|
| 126 | VisibilityEnvironment *VisibilityManager::GetVisibilityEnvironment()
|
---|
| 127 | {
|
---|
| 128 | return mVisibilityEnvironment;
|
---|
| 129 | }
|
---|
[155] | 130 |
|
---|
[59] | 131 | } // namespace GtpVisibility
|
---|