source: GTP/trunk/Lib/Vis/OnlineCullingCHC/src/VisibilityManager.cpp @ 726

Revision 726, 3.7 KB checked in by mattausch, 19 years ago (diff)

improved performance of TerrainSceneManager?
revisit octreescenemanager

RevLine 
[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
9namespace GtpVisibility {
[95]10
[74]11//-----------------------------------------------------------------------
12VisibilityManager::VisibilityManager(VisibilityEnvironment *visEnvironment):
[722]13mVisibilityThreshold(0),
14mCullingManager(NULL),
[153]15mQueryManager(NULL),
[100]16mPreprocessingManager(new DummyPreprocessingManager(NULL)),
[147]17mVisibilityEnvironment(visEnvironment),
[155]18mAssumedVisibilityForChc(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]31VisibilityManager::~VisibilityManager()
32{
33        delete mCullingManager;
[153]34        delete mPreprocessingManager;
[59]35}
[74]36//-----------------------------------------------------------------------
[155]37void 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//-----------------------------------------------------------------------
77void VisibilityManager::SetVisibilityCullingThreshold(unsigned int visibilityThreshold)
78{
79        mVisibilityThreshold = visibilityThreshold;
80        mCullingManager->SetVisibilityThreshold(mVisibilityThreshold);
81}
82//-----------------------------------------------------------------------
[59]83CullingManager *VisibilityManager::GetCullingManager()
84{
85        return mCullingManager;
86}
[74]87//-----------------------------------------------------------------------
[59]88void VisibilityManager::ApplyVisibilityCulling()
89{
90        mCullingManager->RenderScene();
91}
[100]92//-----------------------------------------------------------------------
[92]93VisibilityEnvironment::CullingManagerType VisibilityManager::GetCullingManagerType()
94{
95        return mCullingManagerType;
96}
[130]97//-----------------------------------------------------------------------
98void VisibilityManager::SetQueryManager(QueryManager *queryManager)
99{
100        mQueryManager = queryManager;
101}
102//-----------------------------------------------------------------------
103QueryManager *VisibilityManager::GetQueryManager()
104{
105        return mQueryManager;
106}
[153]107//-----------------------------------------------------------------------
[155]108void 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
Note: See TracBrowser for help on using the repository browser.