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

Revision 722, 3.8 KB checked in by mattausch, 19 years ago (diff)
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
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]32VisibilityManager::~VisibilityManager()
33{
34        delete mCullingManager;
[153]35        delete mPreprocessingManager;
[59]36}
[74]37//-----------------------------------------------------------------------
[155]38void 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//-----------------------------------------------------------------------
78void VisibilityManager::SetVisibilityCullingThreshold(unsigned int visibilityThreshold)
79{
80        mVisibilityThreshold = visibilityThreshold;
81        mCullingManager->SetVisibilityThreshold(mVisibilityThreshold);
82}
83//-----------------------------------------------------------------------
[59]84CullingManager *VisibilityManager::GetCullingManager()
85{
86        return mCullingManager;
87}
[74]88//-----------------------------------------------------------------------
[59]89void VisibilityManager::ApplyVisibilityCulling()
90{
91        mCullingManager->RenderScene();
92}
[100]93//-----------------------------------------------------------------------
[92]94VisibilityEnvironment::CullingManagerType VisibilityManager::GetCullingManagerType()
95{
96        return mCullingManagerType;
97}
[130]98//-----------------------------------------------------------------------
99void VisibilityManager::SetQueryManager(QueryManager *queryManager)
100{
101        mQueryManager = queryManager;
102}
103//-----------------------------------------------------------------------
104QueryManager *VisibilityManager::GetQueryManager()
105{
106        return mQueryManager;
107}
[153]108//-----------------------------------------------------------------------
[155]109void 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
Note: See TracBrowser for help on using the repository browser.