1 | #include "StopAndWaitCullingManager.h" |
---|
2 | #include <OgreLogManager.h> |
---|
3 | |
---|
4 | namespace GtpVisibility { |
---|
5 | |
---|
6 | //----------------------------------------------------------------------- |
---|
7 | void StopAndWaitCullingManager::RenderScene() |
---|
8 | { |
---|
9 | while (!mHierarchyInterface->GetQueue()->empty()) |
---|
10 | { |
---|
11 | HierarchyNode *node = mHierarchyInterface->GetQueue()->top(); |
---|
12 | mHierarchyInterface->GetQueue()->pop(); |
---|
13 | |
---|
14 | // interesting for visualization purpose |
---|
15 | mHierarchyInterface->SetNodeVisible(node, false); |
---|
16 | mHierarchyInterface->SetLastVisited(node, mHierarchyInterface->GetFrameId()); |
---|
17 | |
---|
18 | bool intersects = false; |
---|
19 | |
---|
20 | if (!mHierarchyInterface->CheckFrustumVisible(node, intersects)) |
---|
21 | { |
---|
22 | ++ mNumFrustumCulledNodes; |
---|
23 | |
---|
24 | if (mVisualizeCulledNodes) |
---|
25 | { |
---|
26 | mHierarchyInterface->VisualizeCulledNode(node, FRUSTUM_CULLED); |
---|
27 | } |
---|
28 | } |
---|
29 | // if intersects near plane => skip occlusion query because wrong results possible |
---|
30 | else if (intersects) |
---|
31 | { |
---|
32 | mHierarchyInterface->SetNodeVisible(node, true); |
---|
33 | mHierarchyInterface->TraverseAndRenderNode(node); |
---|
34 | } |
---|
35 | else |
---|
36 | { |
---|
37 | |
---|
38 | ++ mNumQueriesIssued; |
---|
39 | |
---|
40 | unsigned int visiblePixels = 0; |
---|
41 | |
---|
42 | mHierarchyInterface->IssueOcclusionQuery(node)->GetQueryResult(visiblePixels, true); |
---|
43 | |
---|
44 | // node visible |
---|
45 | if (visiblePixels > mVisibilityThreshold) |
---|
46 | { |
---|
47 | mHierarchyInterface->TraverseAndRenderNode(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 |
---|