[59] | 1 | #include "StopAndWaitCullingManager.h" |
---|
[94] | 2 | #include <OgreLogManager.h> |
---|
[59] | 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(); |
---|
[87] | 13 | |
---|
[59] | 14 | // interesting for visualization purpose |
---|
| 15 | mHierarchyInterface->SetNodeVisible(node, false); |
---|
| 16 | mHierarchyInterface->SetLastVisited(node, mHierarchyInterface->GetFrameId()); |
---|
| 17 | |
---|
| 18 | bool intersects = false; |
---|
[345] | 19 | |
---|
[74] | 20 | if (!mHierarchyInterface->CheckFrustumVisible(node, intersects)) |
---|
[139] | 21 | { |
---|
| 22 | ++ mNumFrustumCulledNodes; |
---|
| 23 | |
---|
[114] | 24 | if (mVisualizeCulledNodes) |
---|
[113] | 25 | { |
---|
| 26 | mHierarchyInterface->VisualizeCulledNode(node, FRUSTUM_CULLED); |
---|
| 27 | } |
---|
[59] | 28 | } |
---|
[155] | 29 | // if intersects near plane => skip occlusion query because wrong results possible |
---|
| 30 | else if (intersects) |
---|
| 31 | { |
---|
| 32 | mHierarchyInterface->SetNodeVisible(node, true); |
---|
[158] | 33 | mHierarchyInterface->TraverseNode(node); |
---|
[155] | 34 | } |
---|
[74] | 35 | else |
---|
[925] | 36 | { |
---|
[139] | 37 | ++ mNumQueriesIssued; |
---|
[87] | 38 | |
---|
[86] | 39 | unsigned int visiblePixels = 0; |
---|
| 40 | |
---|
[175] | 41 | mHierarchyInterface->IssueNodeOcclusionQuery(node)->GetQueryResult(visiblePixels, true); |
---|
[925] | 42 | |
---|
[74] | 43 | // node visible |
---|
[925] | 44 | if (0 || visiblePixels > mVisibilityThreshold) |
---|
[74] | 45 | { |
---|
[158] | 46 | mHierarchyInterface->TraverseNode(node); |
---|
[74] | 47 | } |
---|
| 48 | else |
---|
[139] | 49 | { |
---|
| 50 | ++ mNumQueryCulledNodes; |
---|
| 51 | |
---|
[114] | 52 | if (mVisualizeCulledNodes) |
---|
[113] | 53 | { |
---|
| 54 | mHierarchyInterface->VisualizeCulledNode(node, QUERY_CULLED); |
---|
| 55 | } |
---|
[74] | 56 | } |
---|
[59] | 57 | } |
---|
| 58 | } |
---|
| 59 | } |
---|
| 60 | } // namespace GtpVisibility |
---|