1 | #include "StopAndWaitCullingManager.h" |
---|
2 | |
---|
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 | if (mVisualizeCulledNodes) |
---|
16 | { |
---|
17 | mHierarchyInterface->SetNodeVisible(node, false); |
---|
18 | mHierarchyInterface->SetLastVisited(node, mHierarchyInterface->GetFrameId()); |
---|
19 | } |
---|
20 | |
---|
21 | bool intersects = false; |
---|
22 | |
---|
23 | if (!mHierarchyInterface->CheckFrustumVisible(node, intersects)) |
---|
24 | { |
---|
25 | ++ mNumFrustumCulledNodes; |
---|
26 | |
---|
27 | if (mVisualizeCulledNodes) |
---|
28 | { |
---|
29 | mHierarchyInterface->VisualizeCulledNode(node, FRUSTUM_CULLED); |
---|
30 | } |
---|
31 | } |
---|
32 | // if intersects near plane => skip occlusion query because wrong results possible |
---|
33 | else if (intersects) |
---|
34 | { |
---|
35 | if (mVisualizeCulledNodes) |
---|
36 | { |
---|
37 | mHierarchyInterface->SetNodeVisible(node, true); |
---|
38 | } |
---|
39 | |
---|
40 | mHierarchyInterface->TraverseNode(node); |
---|
41 | } |
---|
42 | else |
---|
43 | { |
---|
44 | ++ mNumQueriesIssued; |
---|
45 | |
---|
46 | unsigned int visiblePixels = 0; |
---|
47 | |
---|
48 | mHierarchyInterface->IssueNodeOcclusionQuery(node)->GetQueryResult(visiblePixels, true); |
---|
49 | |
---|
50 | // node visible |
---|
51 | if (visiblePixels > mVisibilityThreshold) |
---|
52 | { |
---|
53 | mHierarchyInterface->TraverseNode(node); |
---|
54 | } |
---|
55 | else |
---|
56 | { |
---|
57 | ++ mNumQueryCulledNodes; |
---|
58 | |
---|
59 | if (mVisualizeCulledNodes) |
---|
60 | { |
---|
61 | mHierarchyInterface->VisualizeCulledNode(node, QUERY_CULLED); |
---|
62 | } |
---|
63 | } |
---|
64 | } |
---|
65 | } |
---|
66 | } |
---|
67 | } // namespace GtpVisibility |
---|