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

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