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