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