source: trunk/VUT/GtpVisibility/src/VisibilityManager.cpp @ 155

Revision 155, 3.6 KB checked in by mattausch, 19 years ago (diff)

added node traversal interface

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"
[59]7
8namespace GtpVisibility {
[95]9
[74]10//-----------------------------------------------------------------------
11VisibilityManager::VisibilityManager(VisibilityEnvironment *visEnvironment):
[100]12mVisibilityThreshold(0), mCullingManager(NULL),
[153]13mQueryManager(NULL),
[100]14mPreprocessingManager(new DummyPreprocessingManager(NULL)),
[147]15mVisibilityEnvironment(visEnvironment),
[155]16mAssumedVisibilityForChc(0)
[59]17{
[107]18        SetCullingManager(VisibilityEnvironment::COHERENT_HIERARCHICAL_CULLING);
[103]19        //SetCullingManager(VisibilityEnvironment::STOP_AND_WAIT_CULLING);
[107]20        //SetCullingManager(VisibilityEnvironment::FRUSTUM_CULLING);
[59]21}
[74]22//-----------------------------------------------------------------------
[59]23VisibilityManager::~VisibilityManager()
24{
25        delete mCullingManager;
[153]26        delete mPreprocessingManager;
[59]27}
[74]28//-----------------------------------------------------------------------
[155]29void VisibilityManager::SetCullingManager(VisibilityEnvironment::
30                                                                                  CullingManagerType ocmType)
[59]31{
[94]32        // change only if necessary
33        if (!mCullingManager || (mCullingManagerType != ocmType))
[59]34        {
[92]35                // delete old culling manager
[100]36                if (mCullingManager)
[103]37                {
[94]38                        delete mCullingManager;
[103]39                }
[155]40
[92]41                mCullingManagerType = ocmType;
42               
[59]43                switch (ocmType)
44                {
[74]45                case VisibilityEnvironment::STOP_AND_WAIT_CULLING:
46                        mCullingManager = new StopAndWaitCullingManager();
[59]47                        break;
48
49                case VisibilityEnvironment::COHERENT_HIERARCHICAL_CULLING:
[155]50                        mCullingManager = new CoherentHierarchicalCullingManager(mAssumedVisibilityForChc);
[59]51                        break;
52
53                case VisibilityEnvironment::FRUSTUM_CULLING:
[74]54                        mCullingManager = new FrustumCullingManager();
[59]55                        break;
[114]56
[59]57                default:
[74]58                        mCullingManager = new StopAndWaitCullingManager();
[59]59                        break;
[114]60
[59]61                }
[114]62
63                // -- set threshold
64                mCullingManager->SetVisibilityThreshold(mVisibilityThreshold);         
[59]65        }
66}
[74]67//-----------------------------------------------------------------------
68void VisibilityManager::SetVisibilityCullingThreshold(unsigned int visibilityThreshold)
69{
70        mVisibilityThreshold = visibilityThreshold;
71        mCullingManager->SetVisibilityThreshold(mVisibilityThreshold);
72}
73//-----------------------------------------------------------------------
[59]74CullingManager *VisibilityManager::GetCullingManager()
75{
76        return mCullingManager;
77}
[74]78//-----------------------------------------------------------------------
[59]79void VisibilityManager::ApplyVisibilityCulling()
80{
81        mCullingManager->RenderScene();
82}
[100]83//-----------------------------------------------------------------------
[92]84VisibilityEnvironment::CullingManagerType VisibilityManager::GetCullingManagerType()
85{
86        return mCullingManagerType;
87}
[130]88//-----------------------------------------------------------------------
89void VisibilityManager::SetQueryManager(QueryManager *queryManager)
90{
91        mQueryManager = queryManager;
92}
93//-----------------------------------------------------------------------
94QueryManager *VisibilityManager::GetQueryManager()
95{
96        return mQueryManager;
97}
[153]98//-----------------------------------------------------------------------
[155]99void VisibilityManager::SetAssumedVisibilityForChc(unsigned int assumedVisibility)
100                                                                         
[146]101{
[155]102        mAssumedVisibilityForChc = assumedVisibility;
[146]103
[155]104        // in case we currently use chc
[146]105        if (VisibilityManager::GetCullingManagerType() ==
106                VisibilityEnvironment::COHERENT_HIERARCHICAL_CULLING)
107        {
108                dynamic_cast<CoherentHierarchicalCullingManager *>(mCullingManager)->
[155]109                                SetAssumedVisibility(assumedVisibility);
[146]110        }
111}
[155]112
113
[59]114} // namespace GtpVisibility
Note: See TracBrowser for help on using the repository browser.