[59] | 1 | #include "StopAndWaitCullingManager.h" |
---|
[94] | 2 | #include <OgreLogManager.h> |
---|
[59] | 3 | |
---|
| 4 | namespace GtpVisibility { |
---|
| 5 | |
---|
| 6 | //----------------------------------------------------------------------- |
---|
| 7 | void StopAndWaitCullingManager::RenderScene() |
---|
| 8 | { |
---|
[175] | 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; |
---|
| 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 | { |
---|
| 38 | |
---|
[139] | 39 | ++ mNumQueriesIssued; |
---|
[87] | 40 | |
---|
[86] | 41 | unsigned int visiblePixels = 0; |
---|
| 42 | |
---|
[175] | 43 | mHierarchyInterface->IssueNodeOcclusionQuery(node)->GetQueryResult(visiblePixels, true); |
---|
[92] | 44 | |
---|
[74] | 45 | // node visible |
---|
[86] | 46 | if (visiblePixels > mVisibilityThreshold) |
---|
[74] | 47 | { |
---|
[158] | 48 | mHierarchyInterface->TraverseNode(node); |
---|
[74] | 49 | } |
---|
| 50 | else |
---|
[139] | 51 | { |
---|
| 52 | ++ mNumQueryCulledNodes; |
---|
| 53 | |
---|
[114] | 54 | if (mVisualizeCulledNodes) |
---|
[113] | 55 | { |
---|
| 56 | mHierarchyInterface->VisualizeCulledNode(node, QUERY_CULLED); |
---|
| 57 | } |
---|
[74] | 58 | } |
---|
[59] | 59 | } |
---|
| 60 | } |
---|
| 61 | } |
---|
| 62 | } // namespace GtpVisibility |
---|