summaryrefslogtreecommitdiffstats
path: root/src/runtimerender/rendererimpl/Qt3DSRendererImplLayerRenderPreparationData.cpp
diff options
context:
space:
mode:
authorAndy Nichols <andy.nichols@qt.io>2019-08-26 13:39:45 +0200
committerAndy Nichols <andy.nichols@qt.io>2019-08-29 07:51:48 +0200
commit9ea345e6372433217915a45b73acb81a81627bde (patch)
tree74e67716130df22dd9ecd7dad5722c272cdaf146 /src/runtimerender/rendererimpl/Qt3DSRendererImplLayerRenderPreparationData.cpp
parent0cce5a54b0f9971021fc0bd0c11198fbe7845ee8 (diff)
Add property to Camera to enable frustum culling when needed
By default frustum culling is disabled because for most scenes all items are always visible. There is a not insignificant cost to doing frustum culling, so it shouldn't be the default behavior. Change-Id: Ibc0c0a4bd1cf65a215256de9ec22ca1d97eb6de5 Reviewed-by: Antti Määttä <antti.maatta@qt.io> Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
Diffstat (limited to 'src/runtimerender/rendererimpl/Qt3DSRendererImplLayerRenderPreparationData.cpp')
-rw-r--r--src/runtimerender/rendererimpl/Qt3DSRendererImplLayerRenderPreparationData.cpp26
1 files changed, 15 insertions, 11 deletions
diff --git a/src/runtimerender/rendererimpl/Qt3DSRendererImplLayerRenderPreparationData.cpp b/src/runtimerender/rendererimpl/Qt3DSRendererImplLayerRenderPreparationData.cpp
index a53a40a..bfd52d6 100644
--- a/src/runtimerender/rendererimpl/Qt3DSRendererImplLayerRenderPreparationData.cpp
+++ b/src/runtimerender/rendererimpl/Qt3DSRendererImplLayerRenderPreparationData.cpp
@@ -1409,17 +1409,21 @@ namespace render {
theTextScaleFactor = m_Camera->GetTextScaleFactor(
thePrepResult.GetLayerToPresentationViewport(),
thePrepResult.GetPresentationDesignDimensions());
- SClipPlane nearPlane;
- QT3DSMat33 theUpper33(m_Camera->m_GlobalTransform.getUpper3x3InverseTranspose());
-
- QT3DSVec3 dir(theUpper33.transform(QT3DSVec3(0, 0, -1)));
- dir.normalize();
- nearPlane.normal = dir;
- QT3DSVec3 theGlobalPos = m_Camera->GetGlobalPos() + m_Camera->m_ClipNear * dir;
- nearPlane.d = -(dir.dot(theGlobalPos));
- // the near plane's bbox edges are calculated in the clipping frustum's
- // constructor.
- m_ClippingFrustum = SClippingFrustum(m_ViewProjection, nearPlane);
+ if (m_Camera->m_EnableFrustumCulling) {
+ SClipPlane nearPlane;
+ QT3DSMat33 theUpper33(m_Camera->m_GlobalTransform.getUpper3x3InverseTranspose());
+
+ QT3DSVec3 dir(theUpper33.transform(QT3DSVec3(0, 0, -1)));
+ dir.normalize();
+ nearPlane.normal = dir;
+ QT3DSVec3 theGlobalPos = m_Camera->GetGlobalPos() + m_Camera->m_ClipNear * dir;
+ nearPlane.d = -(dir.dot(theGlobalPos));
+ // the near plane's bbox edges are calculated in the clipping frustum's
+ // constructor.
+ m_ClippingFrustum = SClippingFrustum(m_ViewProjection, nearPlane);
+ } else if (m_ClippingFrustum.hasValue()) {
+ m_ClippingFrustum.setEmpty();
+ }
} else {
m_ViewProjection = QT3DSMat44::createIdentity();
}