summaryrefslogtreecommitdiffstats
path: root/src/render/backend
diff options
context:
space:
mode:
authorSean Harmer <sean.harmer@kdab.com>2018-01-25 14:43:15 +0000
committerSean Harmer <sean.harmer@kdab.com>2018-01-25 14:44:35 +0000
commit0851956b9b5bf17a8be097cdd0161eb708629070 (patch)
tree0a307aab7936afa97724d745781a8765875e7c49 /src/render/backend
parent09c344d28017e06af6b34bc3c7b781902d052059 (diff)
parente680fe041700296be5e6e4a132e2cfc6f54d4e77 (diff)
Merge branch '5.9' into 5.10
Conflicts: src/render/backend/cameralens.cpp src/render/backend/cameralens_p.h src/render/jobs/pickboundingvolumejob.cpp src/render/jobs/updatelevelofdetailjob.cpp Change-Id: I5433dde8ace462d11f037742d45f555c87235ffe
Diffstat (limited to 'src/render/backend')
-rw-r--r--src/render/backend/cameralens.cpp14
-rw-r--r--src/render/backend/cameralens_p.h2
-rw-r--r--src/render/backend/renderview.cpp11
3 files changed, 16 insertions, 11 deletions
diff --git a/src/render/backend/cameralens.cpp b/src/render/backend/cameralens.cpp
index cf1f17d32..e127b5885 100644
--- a/src/render/backend/cameralens.cpp
+++ b/src/render/backend/cameralens.cpp
@@ -105,6 +105,18 @@ void CameraLens::setRenderAspect(QRenderAspect *renderAspect)
m_renderAspect = renderAspect;
}
+QMatrix4x4 CameraLens::viewMatrix(const QMatrix4x4 &worldTransform)
+{
+ const QVector4D position = worldTransform * QVector4D(0.0f, 0.0f, 0.0f, 1.0f);
+ // OpenGL convention is looking down -Z
+ const QVector4D viewDirection = worldTransform * QVector4D(0.0f, 0.0f, -1.0f, 0.0f);
+ const QVector4D upVector = worldTransform * QVector4D(0.0f, 1.0f, 0.0f, 0.0f);
+
+ QMatrix4x4 m;
+ m.lookAt(position.toVector3D(), (position + viewDirection).toVector3D(), upVector.toVector3D());
+ return m;
+}
+
void CameraLens::initializeFromPeer(const Qt3DCore::QNodeCreatedChangeBasePtr &change)
{
const auto typedChange = qSharedPointerCast<Qt3DCore::QNodeCreatedChange<QCameraLensData>>(change);
@@ -209,7 +221,7 @@ bool CameraLens::viewMatrixForCamera(EntityManager* manager, Qt3DCore::QNodeId c
if (!lens || !lens->isEnabled())
return false;
- viewMatrix = *camNode->worldTransform();
+ viewMatrix = lens->viewMatrix(*camNode->worldTransform());
projectionMatrix = lens->projection();
return true;
}
diff --git a/src/render/backend/cameralens_p.h b/src/render/backend/cameralens_p.h
index d071619d8..1afeeda24 100644
--- a/src/render/backend/cameralens_p.h
+++ b/src/render/backend/cameralens_p.h
@@ -89,6 +89,8 @@ public:
void setRenderAspect(QRenderAspect* renderAspect);
+ QMatrix4x4 viewMatrix(const QMatrix4x4 &worldTransform);
+
void setProjection(const QMatrix4x4 &projection);
inline QMatrix4x4 projection() const { return m_projection; }
diff --git a/src/render/backend/renderview.cpp b/src/render/backend/renderview.cpp
index f488b7e44..dd5968420 100644
--- a/src/render/backend/renderview.cpp
+++ b/src/render/backend/renderview.cpp
@@ -733,16 +733,7 @@ void RenderView::updateMatrices()
{
if (m_data.m_renderCameraNode && m_data.m_renderCameraLens && m_data.m_renderCameraLens->isEnabled()) {
const QMatrix4x4 cameraWorld = *(m_data.m_renderCameraNode->worldTransform());
-
- const QVector4D position = cameraWorld * QVector4D(0.0f, 0.0f, 0.0f, 1.0f);
- // OpenGL convention is looking down -Z
- const QVector4D viewDirection = cameraWorld * QVector4D(0.0f, 0.0f, -1.0f, 0.0f);
- const QVector4D upVector = cameraWorld * QVector4D(0.0f, 1.0f, 0.0f, 0.0f);
-
- QMatrix4x4 m;
- m.lookAt(position.toVector3D(), (position + viewDirection).toVector3D(), upVector.toVector3D());
-
- setViewMatrix(m);
+ setViewMatrix(m_data.m_renderCameraLens->viewMatrix(cameraWorld));
setViewProjectionMatrix(m_data.m_renderCameraLens->projection() * viewMatrix());
//To get the eyePosition of the camera, we need to use the inverse of the