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