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->TraverseNode(node); |
---|
34 | } |
---|
35 | else |
---|
36 | { |
---|
37 | ++ mNumQueriesIssued; |
---|
38 | |
---|
39 | unsigned int visiblePixels = 0; |
---|
40 | |
---|
41 | mHierarchyInterface->IssueNodeOcclusionQuery(node)->GetQueryResult(visiblePixels, true); |
---|
42 | |
---|
43 | // node visible |
---|
44 | if (0 || visiblePixels > mVisibilityThreshold) |
---|
45 | { |
---|
46 | mHierarchyInterface->TraverseNode(node); |
---|
47 | } |
---|
48 | else |
---|
49 | { |
---|
50 | ++ mNumQueryCulledNodes; |
---|
51 | |
---|
52 | if (mVisualizeCulledNodes) |
---|
53 | { |
---|
54 | mHierarchyInterface->VisualizeCulledNode(node, QUERY_CULLED); |
---|
55 | } |
---|
56 | } |
---|
57 | } |
---|
58 | } |
---|
59 | } |
---|
60 | } // namespace GtpVisibility |
---|