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