source: GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreVisibilityOptionsManager.cpp @ 2171

Revision 2171, 2.8 KB checked in by mattausch, 18 years ago (diff)

implemented function for exact visibility queries

Line 
1#include "OgreVisibilityOptionsManager.h"
2
3namespace Ogre {
4//-----------------------------------------------------------------------
5VisibilityOptionsManager::VisibilityOptionsManager(
6                                                        GtpVisibility::VisibilityManager *visManager,
7                                                        PlatformHierarchyInterface *hierarchyInterface):
8mVisibilityManager(visManager),
9mHierarchyInterface(hierarchyInterface)
10{
11}
12//-----------------------------------------------------------------------
13bool VisibilityOptionsManager::setOption(const String & key, const void * val)
14{
15        if (key == "Algorithm")
16        {
17                // delete old queries (not needed for e.g., view frustum culling)
18                // note cannot be deleted because of new ogre occlusion query
19                // implementation there we cannot just delete the queries, so
20                // they would stay!
21                // mHierarchyInterface->ResetQueries();
22                mVisibilityManager->SetCullingManager(*static_cast<const
23                        GtpVisibility::VisibilityEnvironment::CullingManagerType *>(val));
24                return true;
25        }
26        if (key == "Threshold")
27        {
28                mVisibilityManager->SetVisibilityCullingThreshold(*static_cast<const int *>(val));
29                return true;
30        }
31        if (key == "AssumedVisibility")
32        {
33                mVisibilityManager->SetAssumedVisibilityForChc(*static_cast<const int *>(val));
34                return true;
35        }
36        if (key == "TestGeometryForVisibleLeaves")
37        {
38                mHierarchyInterface->TestGeometryForVisibleLeaves(*static_cast<const bool *>(val));
39                return true;
40        }
41       
42        return false;
43}
44//-----------------------------------------------------------------------
45bool VisibilityOptionsManager::getOption( const String & key, void *val )
46{
47        if (key == "NumTraversedNodes")
48        {
49                * static_cast <unsigned int *>(val) =
50                        mHierarchyInterface->GetNumTraversedNodes();
51                return true;
52        }
53        if (key == "NumRenderedNodes")
54        {
55                * static_cast <unsigned int *>(val) =
56                        mHierarchyInterface->GetNumRenderedNodes();
57                return true;
58        }
59        if (key == "NumQueryCulledNodes")
60        {
61                * static_cast <unsigned int *>(val) =
62                        mVisibilityManager->GetCullingManager()->GetNumQueryCulledNodes();
63                return true;
64        }
65        if (key == "NumFrustumCulledNodes")
66        {
67                * static_cast<unsigned int *>(val) =
68                        mVisibilityManager->GetCullingManager()->GetNumFrustumCulledNodes();
69                return true;
70        }
71        if (key == "NumQueriesIssued")
72        {
73                * static_cast<unsigned int *>(val) =
74                        mVisibilityManager->GetCullingManager()->GetNumQueriesIssued();
75                return true;
76        }
77       
78        return false;
79}
80//-----------------------------------------------------------------------
81bool VisibilityOptionsManager::getOptionKeys(StringVector & refKeys)
82{
83        refKeys.push_back("NumRenderedNodes");
84        refKeys.push_back("NumTraversedNodes");
85        refKeys.push_back("NumQueryCulledNodes");
86        refKeys.push_back("NumFrustumCulledNodes");
87        refKeys.push_back("NumQueriesIssued");
88       
89        return true;
90}
91} // namespace Ogre
Note: See TracBrowser for help on using the repository browser.