1 | #include "StopAndWaitCullingManager.h" |
---|
2 | #include <OgreLogManager.h> |
---|
3 | |
---|
4 | namespace GtpVisibility { |
---|
5 | |
---|
6 | //----------------------------------------------------------------------- |
---|
7 | void StopAndWaitCullingManager::RenderScene() |
---|
8 | { |
---|
9 | //Ogre::LogManager::getSingleton().logMessage("Stop and Wait Culling"); |
---|
10 | while (!mHierarchyInterface->GetQueue()->empty()) |
---|
11 | { |
---|
12 | HierarchyNode *node = mHierarchyInterface->GetQueue()->top(); |
---|
13 | mHierarchyInterface->GetQueue()->pop(); |
---|
14 | |
---|
15 | // interesting for visualization purpose |
---|
16 | mHierarchyInterface->SetNodeVisible(node, false); |
---|
17 | mHierarchyInterface->SetLastVisited(node, mHierarchyInterface->GetFrameId()); |
---|
18 | |
---|
19 | bool intersects = false; |
---|
20 | |
---|
21 | if (!mHierarchyInterface->CheckFrustumVisible(node, intersects)) |
---|
22 | { |
---|
23 | ++ mNumFrustumCulledNodes; |
---|
24 | |
---|
25 | if (mVisualizeCulledNodes) |
---|
26 | { |
---|
27 | mHierarchyInterface->VisualizeCulledNode(node, FRUSTUM_CULLED); |
---|
28 | } |
---|
29 | } |
---|
30 | // if intersects near plane => skip occlusion query because wrong results possible |
---|
31 | else if (intersects) |
---|
32 | { |
---|
33 | mHierarchyInterface->SetNodeVisible(node, true); |
---|
34 | mHierarchyInterface->TraverseNode(node); |
---|
35 | } |
---|
36 | else |
---|
37 | { |
---|
38 | ++ mNumQueriesIssued; |
---|
39 | |
---|
40 | unsigned int visiblePixels = 0; |
---|
41 | |
---|
42 | mHierarchyInterface->IssueNodeOcclusionQuery(node)->GetQueryResult(visiblePixels, true); |
---|
43 | |
---|
44 | // node visible |
---|
45 | if (visiblePixels > mVisibilityThreshold) |
---|
46 | { |
---|
47 | mHierarchyInterface->TraverseNode(node); |
---|
48 | } |
---|
49 | else |
---|
50 | { |
---|
51 | ++ mNumQueryCulledNodes; |
---|
52 | |
---|
53 | if (mVisualizeCulledNodes) |
---|
54 | { |
---|
55 | mHierarchyInterface->VisualizeCulledNode(node, QUERY_CULLED); |
---|
56 | } |
---|
57 | } |
---|
58 | } |
---|
59 | } |
---|
60 | } |
---|
61 | } // namespace GtpVisibility |
---|