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

Revision 146, 3.5 KB checked in by mattausch, 19 years ago (diff)

added assumed visibility

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                        dynamic_cast<CoherentHierarchicalCullingManager *>(mCullingManager)->
49                                SetAssumedVisibility(mAssumedVisibility);
50                        break;
51
52                case VisibilityEnvironment::FRUSTUM_CULLING:
53                        mCullingManager = new FrustumCullingManager();
54                        break;
55
56                default:
57                        mCullingManager = new StopAndWaitCullingManager();
58                        break;
59
60                }
61
62                // -- set threshold
63                mCullingManager->SetVisibilityThreshold(mVisibilityThreshold);         
64        }
65}
66//-----------------------------------------------------------------------
67void VisibilityManager::SetVisibilityCullingThreshold(unsigned int visibilityThreshold)
68{
69        mVisibilityThreshold = visibilityThreshold;
70        mCullingManager->SetVisibilityThreshold(mVisibilityThreshold);
71}
72//-----------------------------------------------------------------------
73CullingManager *VisibilityManager::GetCullingManager()
74{
75        return mCullingManager;
76}
77//-----------------------------------------------------------------------
78void VisibilityManager::ApplyVisibilityCulling()
79{
80        mCullingManager->RenderScene();
81}
82//-----------------------------------------------------------------------
83VisibilityEnvironment::CullingManagerType VisibilityManager::GetCullingManagerType()
84{
85        return mCullingManagerType;
86}
87//-----------------------------------------------------------------------
88void VisibilityManager::SetQueryManager(QueryManager *queryManager)
89{
90        mQueryManager = queryManager;
91}
92//-----------------------------------------------------------------------
93QueryManager *VisibilityManager::GetQueryManager()
94{
95        return mQueryManager;
96}
97void VisibilityManager::SetAssumedVisibility(unsigned int assumedVisibility)
98{
99        mAssumedVisibility = assumedVisibility;
100
101        if (VisibilityManager::GetCullingManagerType() ==
102                VisibilityEnvironment::COHERENT_HIERARCHICAL_CULLING)
103        {
104                dynamic_cast<CoherentHierarchicalCullingManager *>(mCullingManager)->
105                                SetAssumedVisibility(mAssumedVisibility);
106        }
107}
108} // namespace GtpVisibility
Note: See TracBrowser for help on using the repository browser.