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

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

added render heuristics evaluation

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