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