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 | unsigned int visiblePixels = 0; |
---|
48 | const bool waitForResult = true; |
---|
49 | mHierarchyInterface->IssueNodeOcclusionQuery(node)->GetQueryResult(visiblePixels, waitForResult); |
---|
50 | |
---|
51 | // node visible |
---|
52 | if (visiblePixels > mVisibilityThreshold) |
---|
53 | { |
---|
54 | mHierarchyInterface->TraverseNode(node); |
---|
55 | } |
---|
56 | else |
---|
57 | { |
---|
58 | ++ mNumQueryCulledNodes; |
---|
59 | |
---|
60 | if (mVisualizeCulledNodes) |
---|
61 | { |
---|
62 | mHierarchyInterface->VisualizeCulledNode(node, QUERY_CULLED); |
---|
63 | } |
---|
64 | } |
---|
65 | } |
---|
66 | } |
---|
67 | } |
---|
68 | } // namespace GtpVisibility |
---|