[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; |
---|
[86] | 47 | unsigned int visiblePixels = 0; |
---|
[2455] | 48 | const bool waitForResult = true; |
---|
| 49 | mHierarchyInterface->IssueNodeOcclusionQuery(node)->GetQueryResult(visiblePixels, waitForResult); |
---|
[925] | 50 | |
---|
[74] | 51 | // node visible |
---|
[2171] | 52 | if (visiblePixels > mVisibilityThreshold) |
---|
[74] | 53 | { |
---|
[158] | 54 | mHierarchyInterface->TraverseNode(node); |
---|
[74] | 55 | } |
---|
| 56 | else |
---|
[139] | 57 | { |
---|
| 58 | ++ mNumQueryCulledNodes; |
---|
| 59 | |
---|
[114] | 60 | if (mVisualizeCulledNodes) |
---|
[113] | 61 | { |
---|
| 62 | mHierarchyInterface->VisualizeCulledNode(node, QUERY_CULLED); |
---|
| 63 | } |
---|
[74] | 64 | } |
---|
[59] | 65 | } |
---|
| 66 | } |
---|
| 67 | } |
---|
| 68 | } // namespace GtpVisibility |
---|