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

Revision 114, 2.7 KB checked in by mattausch, 19 years ago (diff)
Line 
1#include "VisibilityManager.h"
2#include "StopAndWaitCullingManager.h"
3#include "CoherentHierarchicalCullingManager.h"
4#include "FrustumCullingManager.h"
5#include "DummyPreprocessingManager.h"
6#include "DummyQueryManager.h"
7
8namespace GtpVisibility {
9
10//-----------------------------------------------------------------------
11VisibilityManager::VisibilityManager(VisibilityEnvironment *visEnvironment):
12mVisibilityThreshold(0), mCullingManager(NULL),
13mQueryManager(new DummyQueryManager(NULL)),
14mPreprocessingManager(new DummyPreprocessingManager(NULL)),
15mVisibilityEnvironment(visEnvironment)
16{
17        SetCullingManager(VisibilityEnvironment::COHERENT_HIERARCHICAL_CULLING);
18        //SetCullingManager(VisibilityEnvironment::STOP_AND_WAIT_CULLING);
19        //SetCullingManager(VisibilityEnvironment::FRUSTUM_CULLING);
20}
21//-----------------------------------------------------------------------
22VisibilityManager::~VisibilityManager()
23{
24        delete mCullingManager;
25}
26//-----------------------------------------------------------------------
27void VisibilityManager::SetCullingManager(
28        VisibilityEnvironment::CullingManagerType ocmType)
29{
30        // change only if necessary
31        if (!mCullingManager || (mCullingManagerType != ocmType))
32        {
33                // delete old culling manager
34                if (mCullingManager)
35                {
36                        delete mCullingManager;
37                }
38                mCullingManagerType = ocmType;
39               
40                switch (ocmType)
41                {
42                case VisibilityEnvironment::STOP_AND_WAIT_CULLING:
43                        mCullingManager = new StopAndWaitCullingManager();
44                        break;
45
46                case VisibilityEnvironment::COHERENT_HIERARCHICAL_CULLING:
47                        mCullingManager = new CoherentHierarchicalCullingManager();
48                        break;
49
50                case VisibilityEnvironment::FRUSTUM_CULLING:
51                        mCullingManager = new FrustumCullingManager();
52                        break;
53
54                default:
55                        mCullingManager = new StopAndWaitCullingManager();
56                        break;
57
58                }
59
60                // -- set threshold
61                mCullingManager->SetVisibilityThreshold(mVisibilityThreshold);         
62        }
63}
64//-----------------------------------------------------------------------
65void VisibilityManager::SetVisibilityCullingThreshold(unsigned int visibilityThreshold)
66{
67        mVisibilityThreshold = visibilityThreshold;
68        mCullingManager->SetVisibilityThreshold(mVisibilityThreshold);
69}
70//-----------------------------------------------------------------------
71CullingManager *VisibilityManager::GetCullingManager()
72{
73        return mCullingManager;
74}
75//-----------------------------------------------------------------------
76void VisibilityManager::ApplyVisibilityCulling()
77{
78        mCullingManager->RenderScene();
79}
80//-----------------------------------------------------------------------
81VisibilityEnvironment::CullingManagerType VisibilityManager::GetCullingManagerType()
82{
83        return mCullingManagerType;
84}
85
86} // namespace GtpVisibility
Note: See TracBrowser for help on using the repository browser.