diff options
author | Paul Lemire <paul.lemire@kdab.com> | 2016-06-03 11:57:20 +0200 |
---|---|---|
committer | Paul Lemire <paul.lemire@kdab.com> | 2016-07-04 06:09:25 +0000 |
commit | 70dfe10ef9c4745bbf7253c0917a7b5b4120f240 (patch) | |
tree | c52c55163e5e0ccfd753574510bfbd1d4bf7464b /src/render/backend/renderview.cpp | |
parent | 496797fea24e86388eb8ceb9ad257c94c79c72ae (diff) |
Further job improvements
The RenderViewInitialization job used to have to wait for the world transform
job to be completed because it was used to set the viewProjectionMatrix.
This patch adjust dependencies and adds a new job that sets the
viewProjectionMatrix once the transform update job is complete.
This allows to start most of the processing earlier and better use the
available cpu cores.
Change-Id: I77d751e0b20639934cc00be0cd9888f41f684f89
Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
Diffstat (limited to 'src/render/backend/renderview.cpp')
-rw-r--r-- | src/render/backend/renderview.cpp | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/src/render/backend/renderview.cpp b/src/render/backend/renderview.cpp index f6c1ed5e2..3e4fb88c1 100644 --- a/src/render/backend/renderview.cpp +++ b/src/render/backend/renderview.cpp @@ -143,7 +143,7 @@ QUniformValue RenderView::viewMatrix(const QMatrix4x4 &) const QUniformValue RenderView::projectionMatrix(const QMatrix4x4 &) const { - return QUniformValue(QVariant::fromValue(m_data.m_renderCamera->projection())); + return QUniformValue(QVariant::fromValue(m_data.m_renderCameraLens->projection())); } QUniformValue RenderView::modelViewMatrix(const QMatrix4x4 &model) const @@ -169,8 +169,8 @@ QUniformValue RenderView::inverseViewMatrix(const QMatrix4x4 &) const QUniformValue RenderView::inverseProjectionMatrix(const QMatrix4x4 &) const { QMatrix4x4 projection; - if (m_data.m_renderCamera) - projection = m_data.m_renderCamera->projection(); + if (m_data.m_renderCameraLens) + projection = m_data.m_renderCameraLens->projection(); return QUniformValue(QVariant::fromValue(projection.inverted())); } @@ -474,6 +474,19 @@ QVector<RenderCommand *> RenderView::buildComputeRenderCommands(const QVector<En return commands; } +void RenderView::updateMatrices() +{ + if (m_data.m_renderCameraNode && m_data.m_renderCameraLens && m_data.m_renderCameraLens->isEnabled()) { + setViewMatrix(*m_data.m_renderCameraNode->worldTransform()); + setViewProjectionMatrix(m_data.m_renderCameraLens->projection() * viewMatrix()); + //To get the eyePosition of the camera, we need to use the inverse of the + //camera's worldTransform matrix. + const QMatrix4x4 inverseWorldTransform = viewMatrix().inverted(); + const QVector3D eyePosition(inverseWorldTransform.column(3)); + setEyePosition(eyePosition); + } +} + void RenderView::setUniformValue(ShaderParameterPack &uniformPack, int nameId, const QVariant &value) const { Texture *tex = nullptr; |