summaryrefslogtreecommitdiffstats
path: root/src/render/jobs/renderviewjob.cpp
diff options
context:
space:
mode:
authorPaul Lemire <paul.lemire@kdab.com>2015-11-17 12:48:56 +0100
committerAndy Nichols <andy.nichols@theqtcompany.com>2015-11-24 16:53:40 +0000
commit2283cf838010d1c5264ab27553d30ce000fb01e6 (patch)
tree6257c543cc781570c023bde1d483baf4ab5e616f /src/render/jobs/renderviewjob.cpp
parent92311456e21ff0ff0e9e290e728dcca7cbd86c24 (diff)
RenderView: frustum culling
Change-Id: Iacfcfce5d4a339acd29bcaacffb38ce339220ad2 Reviewed-by: Andy Nichols <andy.nichols@theqtcompany.com>
Diffstat (limited to 'src/render/jobs/renderviewjob.cpp')
-rw-r--r--src/render/jobs/renderviewjob.cpp16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/render/jobs/renderviewjob.cpp b/src/render/jobs/renderviewjob.cpp
index 890612110..81439e99c 100644
--- a/src/render/jobs/renderviewjob.cpp
+++ b/src/render/jobs/renderviewjob.cpp
@@ -66,8 +66,20 @@ void RenderViewJob::run()
// Build RenderCommand should perform the culling as we have no way to determine
// if a child has a mesh in the view frustum while its parent isn't contained in it.
- if (!renderView->noDraw())
- renderView->buildRenderCommands(m_renderer->sceneRoot());
+ if (!renderView->noDraw()) {
+ const QMatrix4x4 viewProjectionMatrix = renderView->viewProjectionMatrix();
+
+ const Plane planes[6] = {
+ Plane(viewProjectionMatrix.row(3) + viewProjectionMatrix.row(0)), // Left
+ Plane(viewProjectionMatrix.row(3) - viewProjectionMatrix.row(0)), // Right
+ Plane(viewProjectionMatrix.row(3) + viewProjectionMatrix.row(1)), // Top
+ Plane(viewProjectionMatrix.row(3) - viewProjectionMatrix.row(1)), // Bottom
+ Plane(viewProjectionMatrix.row(3) + viewProjectionMatrix.row(2)), // Front
+ Plane(viewProjectionMatrix.row(3) - viewProjectionMatrix.row(2)), // Back
+ };
+
+ renderView->buildRenderCommands(m_renderer->sceneRoot(), planes);
+ }
// Sorts RenderCommand
renderView->sort();