From 4d4c7b617276446e87d05e97a1bcedb9e461d26d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antti=20M=C3=A4=C3=A4tt=C3=A4?= Date: Fri, 2 Sep 2016 12:33:50 +0300 Subject: Update QRenderSurfaceSelector docs Change-Id: I8022413e6d6b7bcda469a7a5ec569f7af0cefd1f Reviewed-by: Miikka Heikkinen Reviewed-by: Paul Lemire --- src/render/framegraph/qrendersurfaceselector.cpp | 92 +++++++++++++++--------- 1 file changed, 59 insertions(+), 33 deletions(-) diff --git a/src/render/framegraph/qrendersurfaceselector.cpp b/src/render/framegraph/qrendersurfaceselector.cpp index e76963e72..27d06e264 100644 --- a/src/render/framegraph/qrendersurfaceselector.cpp +++ b/src/render/framegraph/qrendersurfaceselector.cpp @@ -52,43 +52,70 @@ QT_BEGIN_NAMESPACE namespace Qt3DRender { /*! - * \class Qt3DRender::QRenderSurfaceSelector - * \inmodule Qt3DRender - * \brief Provides a way of specifying the render surface - * \since 5.7 - * - * \inherits Qt3DRender::QFrameGraphNode - * + \class Qt3DRender::QRenderSurfaceSelector + \inmodule Qt3DRender + \brief Provides a way of specifying the render surface + \since 5.7 + + The Qt3DRender::QRenderSurfaceSelector can be used to select the surface, where + Qt3D renders the content. The surface can either be window surface or offscreen + surface. The externalRenderTargetSize is used to specify the actual size of the + surface when offscreen surface is used. + + When DPI scaling is used by the system, the logical surface size, which is used + by mouse events, and the actual 'physical' size of the surface can differ. + The surfacePixelRatio is the factor to convert the logical size to the physical + size. + + \sa QWindow, QOffscreenSurface, QSurface */ /*! - * \qmltype RenderSurfaceSelector - * \inqmlmodule Qt3D.Render - * \since 5.7 - * \ingroup - * \instantiates Qt3DRender::QRenderSurfaceSelector - * \brief Provides a way of specifying the render surface - * + \qmltype RenderSurfaceSelector + \inqmlmodule Qt3D.Render + \since 5.7 + \instantiates Qt3DRender::QRenderSurfaceSelector + \inherits FrameGraphNode + \brief Provides a way of specifying the render surface + + The RenderSurfaceSelector can be used to select the surface, where + Qt3D renders the content. The surface can either be window surface or offscreen + surface. The externalRenderTargetSize is used to specify the actual size of the + render target when offscreen surface is used. + + When DPI scaling is used by the system, the logical surface size, which is used + by mouse events, and the actual 'physical' size of the surface can differ. + The surfacePixelRatio is the factor to convert the logical size to the physical + size. */ /*! \qmlproperty QSurface Qt3D.Render::RenderSurfaceSelector::surface - * - * Holds the surface. + Holds the surface. */ -/*! - * \property QRenderSurfaceSelector::surface - * Holds the surface +/*! \qmlproperty size Qt3D.Render::RenderSurfaceSelector::externalRenderTargetSize + + Holds the size of the external render target. + */ + +/*! \qmlproperty real Qt3D.Render::RenderSurfaceSelector::surfacePixelRatio + + Holds the surfacePixelRatio of the surface. */ -/*! \qmlproperty QSize Qt3D.Render::RenderSurfaceSelector::externalRenderTargetSize - * - * Holds the size of the external render target. +/*! + \property QRenderSurfaceSelector::surface + Holds the surface */ /*! - * \property QRenderSurfaceSelector::externalRenderTargetSize - * Holds the size of the external render target. + \property QRenderSurfaceSelector::externalRenderTargetSize + Holds the size of the external render target. + */ + +/*! \property QRenderSurfaceSelector::surfacePixelRatio + + Holds the surfacePixelRatio of the surface. */ QRenderSurfaceSelectorPrivate::QRenderSurfaceSelectorPrivate() @@ -136,7 +163,7 @@ void QRenderSurfaceSelectorPrivate::setExternalRenderTargetSize(const QSize &siz } /*! - * Constructs QRenderSurfaceSelector with given \a parent. + Constructs QRenderSurfaceSelector with given \a parent. */ QRenderSurfaceSelector::QRenderSurfaceSelector(Qt3DCore::QNode *parent) : Qt3DRender::QFrameGraphNode(*new QRenderSurfaceSelectorPrivate, parent) @@ -144,14 +171,14 @@ QRenderSurfaceSelector::QRenderSurfaceSelector(Qt3DCore::QNode *parent) } /*! - * \internal + \internal */ QRenderSurfaceSelector::~QRenderSurfaceSelector() { } /*! - * \internal + \internal */ QRenderSurfaceSelector::QRenderSurfaceSelector(QRenderSurfaceSelectorPrivate &dd, Qt3DCore::QNode *parent) : Qt3DRender::QFrameGraphNode(dd, parent) @@ -178,9 +205,8 @@ QObject *QRenderSurfaceSelector::surface() const return surfaceObj; } -/*! \property QRenderSurfaceSelector::surface - * - * Sets \a surface. +/*! + Sets \a surfaceObject. */ void QRenderSurfaceSelector::setSurface(QObject *surfaceObject) { @@ -197,7 +223,7 @@ void QRenderSurfaceSelector::setSurface(QObject *surfaceObject) surface = static_cast(offscreen); } - Q_ASSERT_X(surface, Q_FUNC_INFO, "surfaceObject is not a valid QSurface * object"); + Q_ASSERT_X(surface, Q_FUNC_INFO, "surfaceObject is not a valid QSurface object"); } if (d->m_surface == surface) @@ -286,8 +312,8 @@ float QRenderSurfaceSelector::surfacePixelRatio() const return d->m_surfacePixelRatio; } /*! - * Sets render target \a size if different than underlying surface size. - * Tells picking the correct size. + Sets render target \a size if different than underlying surface size. + Tells picking the correct size. */ void QRenderSurfaceSelector::setExternalRenderTargetSize(const QSize &size) { -- cgit v1.2.3 From 69f8f117912af25f5ac513de8627738d9c9dc1b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antti=20M=C3=A4=C3=A4tt=C3=A4?= Date: Fri, 2 Sep 2016 13:29:16 +0300 Subject: Update QLayerFilter docs Change-Id: I4715d22a583f16444ea9f35c6f9352d53e63f114 Reviewed-by: Paul Lemire Reviewed-by: Miikka Heikkinen --- src/render/framegraph/qlayerfilter.cpp | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/src/render/framegraph/qlayerfilter.cpp b/src/render/framegraph/qlayerfilter.cpp index 92c1e1266..f7f4dd12c 100644 --- a/src/render/framegraph/qlayerfilter.cpp +++ b/src/render/framegraph/qlayerfilter.cpp @@ -59,7 +59,10 @@ QLayerFilterPrivate::QLayerFilterPrivate() \since 5.5 \brief Controls layers Drawn in a frame graph branch. - A QLayerFiler can be used to instruct the renderer as to which layer(s) to draw in that branch of the frame graph. + A Qt3DRender::QLayerFilter can be used to instruct the renderer as to which layer(s) + to draw in that branch of the frame graph. The Qt3DRender::QLayerFilter selects which + entities to draw based on the Qt3DRender::QLayer instances added to the QLayerFilter + and as components to the \l Qt3DCore::QEntity. */ /*! @@ -70,12 +73,20 @@ QLayerFilterPrivate::QLayerFilterPrivate() \since 5.5 \brief Controls layers Drawn in a frame graph branch. - A QLayerFiler can be used to instruct the renderer as to which layer(s) to draw in that branch of the frame graph. + A LayerFilter can be used to instruct the renderer as to which layer(s) + to draw in that branch of the frame graph. The LayerFilter selects which + entities to draw based on the \l Layer instances added to the LayerFilter + and as components to the \l Entity. */ +/*! + \qmlproperty list Qt3D.Render::LayerFilter::layers + Holds a list of layers specifying the layers to select for drawing. + \readonly + */ /*! - The constructor creates an instance with the specified \a parent. + The constructor creates an instance with the specified \a parent. */ QLayerFilter::QLayerFilter(QNode *parent) : QFrameGraphNode(*new QLayerFilterPrivate, parent) @@ -94,16 +105,7 @@ QLayerFilter::~QLayerFilter() } /*! - \property Qt3DRender::QLayerFilter::layers - - */ - -/*! - \qmlproperty stringlist Qt3D.Render::LayerFilter::layers - -*/ -/*! - Add \a layer to the current list of layers + Add \a layer to the current list of layers */ void QLayerFilter::addLayer(QLayer *layer) { @@ -131,7 +133,7 @@ void QLayerFilter::addLayer(QLayer *layer) } /*! - Remove \a layer from the current list of layers + Remove \a layer from the current list of layers */ void QLayerFilter::removeLayer(QLayer *layer) { @@ -148,7 +150,7 @@ void QLayerFilter::removeLayer(QLayer *layer) } /*! - \return the current list of layers + \return the current list of layers */ QVector QLayerFilter::layers() const { -- cgit v1.2.3 From 929d45716e3347c06c0e84c6a49e3801d0b65550 Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Mon, 5 Sep 2016 10:40:10 +0300 Subject: Remove excess slashes from include statements Change-Id: I64f815587947ad2f63462bb38027c533c7aa4bdc Reviewed-by: Paul Lemire --- examples/qt3d/simple-cpp/main.cpp | 4 ++-- tests/manual/bigscene-cpp/main.cpp | 2 +- tests/manual/deferred-renderer-cpp/main.cpp | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/examples/qt3d/simple-cpp/main.cpp b/examples/qt3d/simple-cpp/main.cpp index d3a6728ca..32f19c194 100644 --- a/examples/qt3d/simple-cpp/main.cpp +++ b/examples/qt3d/simple-cpp/main.cpp @@ -59,8 +59,8 @@ #include #include -#include -#include +#include +#include #include #include #include diff --git a/tests/manual/bigscene-cpp/main.cpp b/tests/manual/bigscene-cpp/main.cpp index ebbd499f3..791aeb19d 100644 --- a/tests/manual/bigscene-cpp/main.cpp +++ b/tests/manual/bigscene-cpp/main.cpp @@ -61,7 +61,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/tests/manual/deferred-renderer-cpp/main.cpp b/tests/manual/deferred-renderer-cpp/main.cpp index baafb4796..47425e7ee 100644 --- a/tests/manual/deferred-renderer-cpp/main.cpp +++ b/tests/manual/deferred-renderer-cpp/main.cpp @@ -51,8 +51,8 @@ #include #include -#include -#include +#include +#include #include #include #include -- cgit v1.2.3 From d323d7e733100dc2417ae90bdebd4d4704606ead Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Fri, 2 Sep 2016 13:00:35 +0300 Subject: Fix camera controllers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixed a few bugs and inconsistencies between qml and c++ implementations of the camera controllers. Also documented them. Task-number: QTBUG-55697 Change-Id: Ie490b0ca46f60a2a34c04f91572505e908ce65ba Reviewed-by: Antti Määttä Reviewed-by: Paul Lemire --- src/doc/src/qmlextracontrollers.qdoc | 170 +++++++++++++++++++++ .../defaults/qfirstpersoncameracontroller.cpp | 54 ++++++- src/extras/defaults/qorbitcameracontroller.cpp | 68 ++++++++- src/extras/defaults/qorbitcameracontroller.h | 1 - .../extras/defaults/qml/OrbitCameraController.qml | 18 +-- 5 files changed, 295 insertions(+), 16 deletions(-) create mode 100644 src/doc/src/qmlextracontrollers.qdoc diff --git a/src/doc/src/qmlextracontrollers.qdoc b/src/doc/src/qmlextracontrollers.qdoc new file mode 100644 index 000000000..737d0f823 --- /dev/null +++ b/src/doc/src/qmlextracontrollers.qdoc @@ -0,0 +1,170 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt3D module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \qmltype FirstPersonCameraController + \inqmlmodule Qt3D.Extras + \brief The FirstPersonCameraController allows controlling the scene camera + from the first person perspective. + \since 5.7 + \inherits Qt3D.Core::Entity + + The FirstPersonCameraController allows controlling the scene camera from the first person + perspective. + + The controls are: + \table + \header + \li Input + \li Action + \row + \li Left mouse button + \li While the left mouse button is pressed, mouse movement along x-axis pans the camera and + movement along y-axis tilts it. + \row + \li Shift key + \li Turns the fine motion control active while pressed. Makes mouse pan and tilt less + sensitive. + \row + \li Arrow keys + \li Move the camera horizontally relative to camera viewport. + \row + \li Page up and page down keys + \li Move the camera vertically relative to camera viewport. + \endtable +*/ +/*! + \qmlproperty Camera FirstPersonCameraController::camera + + Holds the currently controlled camera. +*/ +/*! + \qmlproperty real FirstPersonCameraController::linearSpeed + + Holds the current linear speed of the camera controller. Linear speed determines the + movement speed of the camera. +*/ +/*! + \qmlproperty real FirstPersonCameraController::lookSpeed + + Holds the current look speed of the camera controller. The look speed determines the turn rate + of the camera pan and tilt. +*/ +/*! + \qmlproperty real FirstPersonCameraController::acceleration + + Holds the current acceleration. + Specifies the rate at which the camera linear speed increases when a key is held. + If the acceleration is negative, the linear speed stays constant. + Defaults to -1.0. +*/ +/*! + \qmlproperty real FirstPersonCameraController::deceleration + + Specifies the rate at which the camera linear speed decreases when a key is released. + If the deceleration is negative, the linear speed stays constant. + Defaults to -1.0. +*/ + +/*! + \qmltype OrbitCameraController + \inqmlmodule Qt3D.Extras + \brief The OrbitCameraController class allows controlling the scene camera along orbital path. + \since 5.7 + \inherits Qt3D.Core::Entity + + The OrbitCameraController class allows controlling the scene camera along orbital path. + + The controls are: + \table + \header + \li Input + \li Action + \row + \li Left mouse button + \li While the left mouse button is pressed, mouse movement along x-axis moves the camera + left and right and movement along y-axis moves it up and down. + \row + \li Right mouse button + \li While the right mouse button is pressed, mouse movement along x-axis pans the camera + around the camera view center and movement along y-axis tilts it around the camera + view center. + \row + \li Both left and right mouse button + \li While both the left and the right mouse button are pressed, mouse movement along y-axis + zooms the camera in and out without changing the view center. + \row + \li Arrow keys + \li Move the camera vertically and horizontally relative to camera viewport. + \row + \li Page up and page down keys + \li Move the camera forwards and backwards. + \row + \li Shift key + \li Changes the behavior of the up and down arrow keys to zoom the camera in and out + without changing the view center. The other movement keys are disabled. + \row + \li Alt key + \li Changes the behovior of the arrow keys to pan and tilt the camera around the view + center. Disables the page up and page down keys. + \endtable +*/ +/*! + \qmlproperty Camera OrbitCameraController::camera + + Holds the currently controlled camera. +*/ +/*! + \qmlproperty real OrbitCameraController::linearSpeed + + Holds the current linear speed of the camera controller. Linear speed determines the + movement speed of the camera. +*/ +/*! + \qmlproperty real OrbitCameraController::lookSpeed + + Holds the current look speed of the camera controller. The look speed determines the turn rate + of the camera pan and tilt. +*/ +/*! + \qmlproperty real OrbitCameraController::zoomLimit + + Holds the current zoom-in limit. The zoom-in limit determines how close to the view center + the camera can be zoomed. +*/ diff --git a/src/extras/defaults/qfirstpersoncameracontroller.cpp b/src/extras/defaults/qfirstpersoncameracontroller.cpp index 0e1af51b3..973566a3c 100644 --- a/src/extras/defaults/qfirstpersoncameracontroller.cpp +++ b/src/extras/defaults/qfirstpersoncameracontroller.cpp @@ -184,12 +184,45 @@ void QFirstPersonCameraControllerPrivate::_q_onTriggered(float dt) m_tyAxis->value() * m_linearSpeed, m_tzAxis->value() * m_linearSpeed) * dt); if (m_leftMouseButtonAction->isActive()) { - m_camera->pan(m_rxAxis->value() * m_lookSpeed * dt, m_firstPersonUp); - m_camera->tilt(m_ryAxis->value() * m_lookSpeed * dt); + float lookSpeed = m_lookSpeed; + if (m_fineMotionAction->isActive()) + lookSpeed *= 0.2f; + m_camera->pan(m_rxAxis->value() * lookSpeed * dt, m_firstPersonUp); + m_camera->tilt(m_ryAxis->value() * lookSpeed * dt); } } } +/*! + \class Qt3DExtras::QFirstPersonCameraController + \brief The QFirstPersonCameraController class allows controlling the scene camera + from the first person perspective. + \inmodule Qt3DExtras + \since 5.7 + \inherits Qt3DCore::QEntity + + The controls are: + \table + \header + \li Input + \li Action + \row + \li Left mouse button + \li While the left mouse button is pressed, mouse movement along x-axis pans the camera and + movement along y-axis tilts it. + \row + \li Shift key + \li Turns the fine motion control active while pressed. Makes mouse pan and tilt less + sensitive. + \row + \li Arrow keys + \li Move the camera horizontally relative to camera viewport. + \row + \li Page up and page down keys + \li Move the camera vertically relative to camera viewport. + \endtable +*/ + QFirstPersonCameraController::QFirstPersonCameraController(Qt3DCore::QNode *parent) : Qt3DCore::QEntity(*new QFirstPersonCameraControllerPrivate, parent) { @@ -201,18 +234,35 @@ QFirstPersonCameraController::~QFirstPersonCameraController() { } +/*! + \property QFirstPersonCameraController::camera + + Holds the currently controlled camera. +*/ Qt3DRender::QCamera *QFirstPersonCameraController::camera() const { Q_D(const QFirstPersonCameraController); return d->m_camera; } +/*! + \property QFirstPersonCameraController::linearSpeed + + Holds the current linear speed of the camera controller. Linear speed determines the + movement speed of the camera. +*/ float QFirstPersonCameraController::linearSpeed() const { Q_D(const QFirstPersonCameraController); return d->m_linearSpeed; } +/*! + \property QFirstPersonCameraController::lookSpeed + + Holds the current look speed of the camera controller. The look speed determines the turn rate + of the camera pan and tilt. +*/ float QFirstPersonCameraController::lookSpeed() const { Q_D(const QFirstPersonCameraController); diff --git a/src/extras/defaults/qorbitcameracontroller.cpp b/src/extras/defaults/qorbitcameracontroller.cpp index deeec7f0d..d8f468ed0 100644 --- a/src/extras/defaults/qorbitcameracontroller.cpp +++ b/src/extras/defaults/qorbitcameracontroller.cpp @@ -54,9 +54,46 @@ QT_BEGIN_NAMESPACE namespace Qt3DExtras { /*! - * \class QOrbitCameraController::QOrbitCameraController - * \internal - */ + \class Qt3DExtras::QOrbitCameraController + \brief The QOrbitCameraController class allows controlling the scene camera along orbital path. + \inmodule Qt3DExtras + \since 5.7 + \inherits Qt3DCore::QEntity + + The controls are: + \table + \header + \li Input + \li Action + \row + \li Left mouse button + \li While the left mouse button is pressed, mouse movement along x-axis moves the camera + left and right and movement along y-axis moves it up and down. + \row + \li Right mouse button + \li While the right mouse button is pressed, mouse movement along x-axis pans the camera + around the camera view center and movement along y-axis tilts it around the camera + view center. + \row + \li Both left and right mouse button + \li While both the left and the right mouse button are pressed, mouse movement along y-axis + zooms the camera in and out without changing the view center. + \row + \li Arrow keys + \li Move the camera vertically and horizontally relative to camera viewport. + \row + \li Page up and page down keys + \li Move the camera forwards and backwards. + \row + \li Shift key + \li Changes the behavior of the up and down arrow keys to zoom the camera in and out + without changing the view center. The other movement keys are disabled. + \row + \li Alt key + \li Changes the behovior of the arrow keys to pan and tilt the camera around the view + center. Disables the page up and page down keys. + \endtable +*/ QOrbitCameraControllerPrivate::QOrbitCameraControllerPrivate() : Qt3DCore::QEntityPrivate() @@ -214,8 +251,8 @@ void QOrbitCameraControllerPrivate::_q_onTriggered(float dt) m_camera->translate(QVector3D(clampInputs(m_rxAxis->value(), m_txAxis->value()) * m_linearSpeed, clampInputs(m_ryAxis->value(), m_tyAxis->value()) * m_linearSpeed, 0) * dt); - return; } + return; } else if (m_rightMouseButtonAction->isActive()) { // Orbit @@ -254,24 +291,47 @@ QOrbitCameraController::~QOrbitCameraController() { } +/*! + \property QOrbitCameraController::camera + + Holds the currently controlled camera. +*/ Qt3DRender::QCamera *QOrbitCameraController::camera() const { Q_D(const QOrbitCameraController); return d->m_camera; } +/*! + \property QOrbitCameraController::linearSpeed + + Holds the current linear speed of the camera controller. Linear speed determines the + movement speed of the camera. +*/ float QOrbitCameraController::linearSpeed() const { Q_D(const QOrbitCameraController); return d->m_linearSpeed; } +/*! + \property QOrbitCameraController::lookSpeed + + Holds the current look speed of the camera controller. The look speed determines the turn rate + of the camera pan and tilt. +*/ float QOrbitCameraController::lookSpeed() const { Q_D(const QOrbitCameraController); return d->m_lookSpeed; } +/*! + \property QOrbitCameraController::zoomInLimit + + Holds the current zoom-in limit. The zoom-in limit determines how close to the view center + the camera can be zoomed. +*/ float QOrbitCameraController::zoomInLimit() const { Q_D(const QOrbitCameraController); diff --git a/src/extras/defaults/qorbitcameracontroller.h b/src/extras/defaults/qorbitcameracontroller.h index fb4d0aa7a..e48e39142 100644 --- a/src/extras/defaults/qorbitcameracontroller.h +++ b/src/extras/defaults/qorbitcameracontroller.h @@ -62,7 +62,6 @@ public: explicit QOrbitCameraController(Qt3DCore::QNode *parent = nullptr); ~QOrbitCameraController(); - float clampInputs(float input1, float input2); Qt3DRender::QCamera *camera() const; float linearSpeed() const; float lookSpeed() const; diff --git a/src/quick3d/imports/extras/defaults/qml/OrbitCameraController.qml b/src/quick3d/imports/extras/defaults/qml/OrbitCameraController.qml index 328b7b98e..1f5fa5a7a 100644 --- a/src/quick3d/imports/extras/defaults/qml/OrbitCameraController.qml +++ b/src/quick3d/imports/extras/defaults/qml/OrbitCameraController.qml @@ -162,13 +162,13 @@ Entity { id: keyboardZAxis ButtonAxisInput { sourceDevice: keyboardSourceDevice - buttons: [Qt.Key_Up] - scale: d.shiftPressed ? 1.0 : 0.0 + buttons: [Qt.Key_PageUp] + scale: 1.0 } ButtonAxisInput { sourceDevice: keyboardSourceDevice - buttons: [Qt.Key_Down] - scale: d.shiftPressed ? -1.0 : 0.0 + buttons: [Qt.Key_PageDown] + scale: -1.0 } }, Axis { @@ -176,12 +176,12 @@ Entity { ButtonAxisInput { sourceDevice: keyboardSourceDevice buttons: [Qt.Key_Up] - scale: d.shiftPressed ? 0.0 : 1.0 + scale: 1.0 } ButtonAxisInput { sourceDevice: keyboardSourceDevice buttons: [Qt.Key_Down] - scale: d.shiftPressed ? 0.0 : -1.0 + scale: -1.0 } } ] // axes @@ -205,8 +205,8 @@ Entity { } else { // Translate root.camera.translate(Qt.vector3d(d.translationX, d.translationY, 0).times(dt)); - return } + return } else if (d.rightMouseButtonPressed) { // Orbit root.camera.panAboutViewCenter(d.orbitX * dt, d.firstPersonUp); @@ -220,14 +220,14 @@ Entity { } else if (d.shiftPressed) { if (zoomDistance(root.camera.position, root.camera.viewCenter) > root.zoomLimit * root.zoomLimit) { // Dolly up to limit - root.camera.translate(Qt.vector3d(0, 0, d.translationZ).times(dt), Camera.DontTranslateViewCenter); + root.camera.translate(Qt.vector3d(0, 0, d.translationY).times(dt), Camera.DontTranslateViewCenter); } else { // Too close, Dolly backwards root.camera.translate(Qt.vector3d(0, 0, -1).times(dt), Camera.DontTranslateViewCenter); } } else { // Translate - root.camera.translate(Qt.vector3d(d.translationX, d.translationY, 0).times(dt)); + root.camera.translate(Qt.vector3d(d.translationX, d.translationY, d.translationZ).times(dt)); } } } -- cgit v1.2.3 From 0febc2e9be299475e72c4cd348e830cb267ece95 Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Mon, 5 Sep 2016 11:26:26 +0300 Subject: Fix QForwardRenderer docs Change-Id: Ic9fcfa41caa8773a1fa12fa42c6345292ae6160e Reviewed-by: Paul Lemire --- src/extras/defaults/qforwardrenderer.cpp | 99 ++++++++++++++++++++++---------- 1 file changed, 70 insertions(+), 29 deletions(-) diff --git a/src/extras/defaults/qforwardrenderer.cpp b/src/extras/defaults/qforwardrenderer.cpp index 8e6dc9425..32c4a2968 100644 --- a/src/extras/defaults/qforwardrenderer.cpp +++ b/src/extras/defaults/qforwardrenderer.cpp @@ -84,26 +84,46 @@ void QForwardRendererPrivate::init() } /*! - \class Qt3DRender::QForwardRenderer - \brief The Qt3DRender::QForwardRenderer provides a default \l {QFrameGraph}{FrameGraph} implementation of a forward renderer. - \inmodule Qt3DRender - \since 5.5 - - Forward rendering is how OpenGL is traditionally. It renders directly to the backbuffer + \class Qt3DExtras::QForwardRenderer + \brief The QForwardRenderer provides a default \l{Qt 3D Render Framegraph}{FrameGraph} + implementation of a forward renderer. + \inmodule Qt3DExtras + \since 5.7 + \inherits Qt3DRender::QTechniqueFilter + + Forward rendering is what OpenGL traditionally uses. It renders directly to the backbuffer one object at a time shading each one as it goes. - Internally the Qt3DRender::QForwardRenderer is a subclass of Qt3DRender::QTechniqueFilter. - This a is a single leaf Framegraph tree which contains a Qt3DRender::QViewport, a Qt3DRender::QCameraSelector - and a Qt3DRender::QClearBuffers. - The Qt3DRender::QForwardRenderer has a default requirement annotation whose name is "renderingStyle" and value "forward". - If you need to filter out your techniques, you should do so based on that annotation. + QForwardRenderer is a single leaf \l{Qt 3D Render Framegraph}{FrameGraph} tree which contains + a Qt3DRender::QViewport, a Qt3DRender::QCameraSelector, and a Qt3DRender::QClearBuffers. + The QForwardRenderer has a default requirement filter key whose name is "renderingStyle" and + value "forward". + If you need to filter out your techniques, you should do so based on that filter key. - By default the viewport occupies the whole screen and the clear color is white. Frustum culling is also enabled. + By default the viewport occupies the whole screen and the clear color is white. + Frustum culling is also enabled. */ - /*! - Constructs a new Qt3DRender::QForwardRenderer instance with parent object \a parent. + \qmltype ForwardRenderer + \brief The ForwardRenderer provides a default \l{Qt 3D Render Framegraph}{FrameGraph} + implementation of a forward renderer. + \since 5.7 + \inqmlmodule Qt3D.Extras + \instantiates Qt3DExtras::QForwardRenderer + + Forward rendering is what OpenGL traditionally uses. It renders directly to the backbuffer + one object at a time shading each one as it goes. + + ForwardRenderer is a single leaf \l{Qt 3D Render Framegraph}{FrameGraph} tree which contains + a Viewport, a CameraSelector, and a ClearBuffers. + The ForwardRenderer has a default requirement filter key whose name is "renderingStyle" and + value "forward". + If you need to filter out your techniques, you should do so based on that filter key. + + By default the viewport occupies the whole screen and the clear color is white. + Frustum culling is also enabled. */ + QForwardRenderer::QForwardRenderer(QNode *parent) : QTechniqueFilter(*new QForwardRendererPrivate, parent) { @@ -115,9 +135,6 @@ QForwardRenderer::QForwardRenderer(QNode *parent) d->init(); } -/*! - Destroys the QForwardRenderer instance. -*/ QForwardRenderer::~QForwardRenderer() { } @@ -134,11 +151,6 @@ void QForwardRenderer::setClearColor(const QColor &clearColor) d->m_clearBuffer->setClearColor(clearColor); } -/*! - Sets the camera which should be used to render the scene to \a camera. - - \note A camera is a QEntity having a QCameraLens as one of its components. -*/ void QForwardRenderer::setCamera(Qt3DCore::QEntity *camera) { Q_D(QForwardRenderer); @@ -152,10 +164,15 @@ void QForwardRenderer::setSurface(QObject *surface) } /*! - \property Qt3DRender::QForwardRenderer::viewportRect + \qmlproperty rect ForwardRenderer::viewportRect - Holds the current viewport normalizedRect. - */ + Holds the current normalized viewport rectangle. +*/ +/*! + \property QForwardRenderer::viewportRect + + Holds the current normalized viewport rectangle. +*/ QRectF QForwardRenderer::viewportRect() const { Q_D(const QForwardRenderer); @@ -163,9 +180,16 @@ QRectF QForwardRenderer::viewportRect() const } /*! - \property Qt3DRender::QForwardRenderer::clearColor + \qmlproperty color ForwardRenderer::clearColor + + Holds the current clear color of the scene. The frame buffer is initialized to the clear color + before rendering. +*/ +/*! + \property QForwardRenderer::clearColor - Holds the current clearColor. + Holds the current clear color of the scene. The frame buffer is initialized to the clear color + before rendering. */ QColor QForwardRenderer::clearColor() const { @@ -174,9 +198,16 @@ QColor QForwardRenderer::clearColor() const } /*! - \property Qt3DRender::QForwardRenderer::camera + \qmlproperty Entity ForwardRenderer::camera + + Holds the current camera entity used to render the scene. + + \note A camera is an Entity that has a CameraLens as one of its components. +*/ +/*! + \property QForwardRenderer::camera - Holds the current QEntity camera used to render the scene. + Holds the current camera entity used to render the scene. \note A camera is a QEntity that has a QCameraLens as one of its components. */ @@ -186,6 +217,16 @@ Qt3DCore::QEntity *QForwardRenderer::camera() const return d->m_cameraSelector->camera(); } +/*! + \qmlproperty Object ForwardRenderer::surface + + Holds the current render surface. +*/ +/*! + \property QForwardRenderer::surface + + Holds the current render surface. +*/ QObject *QForwardRenderer::surface() const { Q_D(const QForwardRenderer); -- cgit v1.2.3 From 6eecb253c0a9a5d0c1eaaa031e38d24e3bb5f447 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antti=20M=C3=A4=C3=A4tt=C3=A4?= Date: Thu, 1 Sep 2016 12:48:22 +0300 Subject: Update QViewport docs Change-Id: I9a81ddc741af8fb0f1126b431763ccf7a1f07e3a Reviewed-by: Miikka Heikkinen Reviewed-by: Paul Lemire --- src/render/framegraph/qviewport.cpp | 54 ++++++++++++++++++++++--------------- 1 file changed, 32 insertions(+), 22 deletions(-) diff --git a/src/render/framegraph/qviewport.cpp b/src/render/framegraph/qviewport.cpp index c68ff141f..cf7667289 100644 --- a/src/render/framegraph/qviewport.cpp +++ b/src/render/framegraph/qviewport.cpp @@ -53,27 +53,39 @@ QViewportPrivate::QViewportPrivate() } /*! - * \class Qt3DRender::QViewport - * \inmodule Qt3DRender - * \brief A viewport on the Qt3D Scene - * \since 5.7 - * - * \inherits Qt3DRender::QFrameGraphNode - * + \class Qt3DRender::QViewport + \inmodule Qt3DRender + \brief A viewport on the Qt3D Scene + \since 5.7 + + \inherits Qt3DRender::QFrameGraphNode + + Qt3DRender::QViewport of the scene specifies at which portion of the render surface Qt3D + is rendering to. Area outside the viewport is left untouched. */ /*! - * \qmltype Viewport - * \inqmlmodule Qt3D.Render - * \since 5.7 - * \ingroup - * \instantiates Qt3DRender::QViewport - * \brief A viewport on the Qt3D Scene - * + \qmltype Viewport + \inqmlmodule Qt3D.Render + \since 5.7 + \ingroup + \instantiates Qt3DRender::QViewport + \brief A viewport on the Qt3D Scene + + Viewport of the scene specifies at which portion of the render surface Qt3D is + rendering to. Area outside the viewport is left untouched. */ /*! - * Constructs QViewport with given \a parent. + \qmlproperty rect Viewport::normalizedRect + + Specifies the normalised rectangle for the viewport, i.e. the viewport rectangle + is specified relative to the render surface size. Whole surface sized viewport + is specified as [0.0, 0.0, 1.0, 1.0], which is the default. + */ + +/*! + Constructs QViewport with given \a parent. */ QViewport::QViewport(QNode *parent) : QFrameGraphNode(*new QViewportPrivate, parent) @@ -99,14 +111,12 @@ QRectF QViewport::normalizedRect() const } /*! - \property Qt3DRender::QViewport::normalizedRect - Specifies the normalise rect for the viewport -*/ - -/*! - \qmlproperty QRectF Qt3D.Render::QViewport::normalizedRect + \property QViewport::normalizedRect -*/ + Specifies the normalised rectangle for the viewport, i.e. the viewport rectangle + is specified relative to the render surface size. Whole surface sized viewport + is specified as [0.0, 0.0, 1.0, 1.0], which is the default. + */ void QViewport::setNormalizedRect(const QRectF &normalizedRect) { Q_D(QViewport); -- cgit v1.2.3 From 4cf4e0a1be90e6c7861d7f70c109082555b45455 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antti=20M=C3=A4=C3=A4tt=C3=A4?= Date: Thu, 1 Sep 2016 13:15:24 +0300 Subject: Update QSceneLoader docs Change-Id: Idb4210e9d455c9b8c87a6540d486992531778c0e Reviewed-by: Miikka Heikkinen Reviewed-by: Paul Lemire --- src/render/io/qsceneloader.cpp | 130 ++++++++++++++++++++++++----------------- 1 file changed, 76 insertions(+), 54 deletions(-) diff --git a/src/render/io/qsceneloader.cpp b/src/render/io/qsceneloader.cpp index 69bd8528b..9cb067161 100644 --- a/src/render/io/qsceneloader.cpp +++ b/src/render/io/qsceneloader.cpp @@ -51,44 +51,36 @@ using namespace Qt3DCore; namespace Qt3DRender { -QSceneLoaderPrivate::QSceneLoaderPrivate() - : QComponentPrivate() - , m_status(QSceneLoader::None) - , m_subTreeRoot(nullptr) -{ - m_shareable = false; -} - /*! - \class Qt3DRender::QSceneLoader - \inmodule Qt3DRender - \since 5.7 - \ingroup io + \class Qt3DRender::QSceneLoader + \inmodule Qt3DRender + \since 5.7 + \ingroup io - \brief Provides the facility to load an existing Scene + \brief Provides the facility to load an existing Scene - Given a 3D source file, the Qt3DRender::QSceneLoader will try to parse it and - build a tree of Qt3DCore::QEntity with proper Qt3DRender::QGeometryRenderer - Qt3DCore::QTransform and QtRender::QMaterial components. + Given a 3D source file, the Qt3DRender::QSceneLoader will try to parse it and + build a tree of Qt3DCore::QEntity objects with proper Qt3DRender::QGeometryRenderer, + Qt3DCore::QTransform and Qt3DRender::QMaterial components. - The loader will try to determine the best material to be used based on the properties - of the model file. If you wish to use a custom material, you will have to traverse - the tree and replace the default associated materials with yours. + The loader will try to determine the best material to be used based on the properties + of the model file. If you wish to use a custom material, you will have to traverse + the tree and replace the default associated materials with yours. - As the name implies, Qt3DRender::QSceneLoader loads a complete scene subtree. - If you wish to load a single piece of geometry, you should rather be using - the Qt3DRender::QMesh instead. + As the name implies, Qt3DRender::QSceneLoader loads a complete scene subtree. + If you wish to load a single piece of geometry, you should rather use + the Qt3DRender::QMesh instead. - Qt3DRender::QSceneLoader internally relies on the use of plugins to support a - wide variety of 3D file formats. \l - {http://www.assimp.org/main_features_formats.html}{Here} is a list of formats - that are supported by Qt3D. + Qt3DRender::QSceneLoader internally relies on the use of plugins to support a + wide variety of 3D file formats. \l + {http://www.assimp.org/main_features_formats.html}{Here} is a list of formats + that are supported by Qt3D. - \note this component shouldn't be shared among several Qt3DCore::QEntity instances. - Undefined behavior will result. + \note this component shouldn't be shared among several Qt3DCore::QEntity instances. + Undefined behavior will result. - \sa Qt3DRender::QMesh - \sa Qt3DRender::QGeometryRenderer + \sa Qt3DRender::QMesh + \sa Qt3DRender::QGeometryRenderer */ /*! @@ -97,10 +89,10 @@ QSceneLoaderPrivate::QSceneLoaderPrivate() \instantiates Qt3DRender::QSceneLoader \inherits Component \since 5.7 - \qmlabstract Provides the facility to load an existing Scene + \brief Provides the facility to load an existing Scene Given a 3D source file, the SceneLoader will try to parse it and build a - tree of Entity with proper GeometryRenderer, Transform and Material + tree of Entity objects with proper GeometryRenderer, Transform and Material components. The loader will try to determine the best material to be used based on the @@ -109,7 +101,7 @@ QSceneLoaderPrivate::QSceneLoaderPrivate() with yours. As the name implies, SceneLoader loads a complete scene subtree. If you - wish to load a single piece of geometry, you should rather be using the + wish to load a single piece of geometry, you should rather use the Mesh instead. SceneLoader internally relies on the use of plugins to support a wide @@ -122,7 +114,7 @@ QSceneLoaderPrivate::QSceneLoaderPrivate() \sa Mesh \sa GeometryRenderer -*/ + */ /*! \enum QSceneLoader::Status @@ -132,10 +124,58 @@ QSceneLoaderPrivate::QSceneLoaderPrivate() \value Loading The Qt3DRender::QSceneLoader is currently loading the scene file. \value Ready The Qt3DRender::QSceneLoader successfully loaded the scene file. \value Error The Qt3DRender::QSceneLoader encountered an error while loading the scene file. -*/ + */ + +/*! + \qmlproperty url SceneLoader::source + + Holds the url to the source to be loaded. + */ /*! - The constructor creates an instance with the specified \a parent. + \qmlproperty enumeration SceneLoader::status + + Holds the status of scene loading. + \list + \li SceneLoader.None + \li SceneLoader.Loading + \li SceneLoader.Ready + \li SceneLoader.Error + \endlist + \sa Qt3DRender::QSceneLoader::Status + \readonly + */ + +/*! + \property QSceneLoader::source + + Holds the url to the source to be loaded. + */ + +/*! + \property QSceneLoader::status + + Holds the status of scene loading. + \list + \li SceneLoader.None + \li SceneLoader.Loading + \li SceneLoader.Ready + \li SceneLoader.Error + \endlist + \sa Qt3DRender::QSceneLoader::Status + */ + +/*! \internal */ +QSceneLoaderPrivate::QSceneLoaderPrivate() + : QComponentPrivate() + , m_status(QSceneLoader::None) + , m_subTreeRoot(nullptr) +{ + m_shareable = false; +} + +/*! + The constructor creates an instance with the specified \a parent. */ QSceneLoader::QSceneLoader(QNode *parent) : Qt3DCore::QComponent(*new QSceneLoaderPrivate, parent) @@ -190,15 +230,6 @@ QUrl QSceneLoader::source() const return d->m_source; } -/*! - \property Qt3DRender::QSceneLoader::source - Specifies the url for the source to be loaded. -*/ - -/*! - \qmlproperty QUrl Qt3D.Render::SceneLoader::source - -*/ void QSceneLoader::setSource(const QUrl &arg) { Q_D(QSceneLoader); @@ -208,15 +239,6 @@ void QSceneLoader::setSource(const QUrl &arg) } } -/*! - \property Qt3DRender::QSceneLoader::status - Indicates the status of scene loading. -*/ - -/*! - \qmlproperty Status Qt3D.Render::SceneLoader::status - -*/ QSceneLoader::Status QSceneLoader::status() const { Q_D(const QSceneLoader); -- cgit v1.2.3 From 54817963613f5ac81767a6feebc8caf34a901196 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antti=20M=C3=A4=C3=A4tt=C3=A4?= Date: Thu, 1 Sep 2016 14:25:39 +0300 Subject: Update QCameraLens docs Change-Id: I3e2cd85d5c85b066fdcf7793adbc969092fc7736 Reviewed-by: Miikka Heikkinen Reviewed-by: Paul Lemire --- src/render/frontend/qcameralens.cpp | 287 ++++++++++++++++++++---------------- 1 file changed, 162 insertions(+), 125 deletions(-) diff --git a/src/render/frontend/qcameralens.cpp b/src/render/frontend/qcameralens.cpp index 8c730c763..3073fbc3f 100644 --- a/src/render/frontend/qcameralens.cpp +++ b/src/render/frontend/qcameralens.cpp @@ -45,8 +45,164 @@ QT_BEGIN_NAMESPACE namespace Qt3DRender { /*! - \internal -*/ + * \class Qt3DRender::QCameraLens + * \inmodule Qt3DCore + * + * \brief Qt3DRender::QCameraLens specifies the projection matrix that will be used to + * define a Camera for a 3D scene. + * + * \since 5.5 + */ + +/*! + * \qmltype CameraLens + * \instantiates Qt3DRender::QCameraLens + * \inqmlmodule Qt3D.Core + * \inherits Component3D + * \since 5.5 + * \brief Provides the projection matrix that is used to define a Camera for 3D scene. + */ + +/*! + * \enum Qt3DRender::QCameraLens::ProjectionType + * + * Specifies which parameters of Qt3DRender::QCameraLens are used to compute the projection matrix. + * + * \value OrthographicProjection Orthogonal projection + * \value PerspectiveProjection Perspective projection + * \value FrustumProjection Frustum projection + * \value CustomProjection Custom user-defined projection + */ + +/*! + * \qmlproperty enumeration CameraLens::projectionType + * + * Holds the type of the camera projection. + * + * \list + * \li CameraLens.OrthographicProjection + * \li CameraLens.PerspectiveProjection + * \li CameraLens.FrustumProjection + * \li CameraLens.CustomProjection + * \endlist + * \sa Qt3DRender::QCameraLens::ProjectionType + */ + +/*! + * \qmlproperty real CameraLens::nearPlane + * Holds the current near plane of the camera lens. + */ + +/*! + * \qmlproperty real CameraLens::farPlane + * Holds the current near plane of the camera lens. + */ + +/*! + * \qmlproperty real CameraLens::fieldOfView + * Holds the current field of view of the camera lens in degrees. + */ + +/*! + * \qmlproperty real CameraLens::aspectRatio + * Holds the current aspect ratio of the camera lens. + */ + +/*! + * \qmlproperty real CameraLens::left + * Holds the current left plane of the camera lens. + */ + +/*! + * \qmlproperty real CameraLens::right + * Holds the current right plane of the camera lens. + */ + +/*! + * \qmlproperty real CameraLens::bottom + * Holds the current bottom plane of the camera lens. + */ + +/*! + * \qmlproperty real CameraLens::top + * Holds the current top plane of the camera lens. + */ + +/*! + * \qmlproperty matrix4x4 CameraLens::projectionMatrix + * Holds the current projection matrix of the camera lens. + * \readonly + */ + + +/*! + * \property QCameraLens::projectionType + * + * Holds the type of the camera projection. + * \sa Qt3DRender::QCameraLens::ProjectionType + */ + +/*! + * \property QCameraLens::nearPlane + * Holds the current near plane of the camera lens. + */ + +/*! + * \property QCameraLens::farPlane + * Holds the current near plane of the camera lens. + */ + +/*! + * \property QCameraLens::fieldOfView + * Holds the current field of view of the camera lens. + * \note: The return value may be undefined if the projection type is not + * Qt3DRender::QCameraLens::PerspectiveProjection. + */ + +/*! + * \property QCameraLens::aspectRatio + * Holds the current aspect ratio of the camera lens. + * \note: The return value may be undefined if the projection type is not + * Qt3DRender::QCameraLens::PerspectiveProjection. + */ + +/*! + * \property QCameraLens::left + * Holds the current left plane of the camera lens. + * \note The return value may be undefined if the projection type is + * Qt3DRender::QCameraLens::PerspectiveProjection. + */ + +/*! + * \property QCameraLens::right + * Holds the current right plane of the camera lens. + * \note The return value may be undefined if the projection type is + * Qt3DRender::QCameraLens::PerspectiveProjection. + */ + +/*! + * \property QCameraLens::bottom + * Holds the current bottom plane of the camera lens. + * \note The return value may be undefined if the projection type is + * Qt3DRender::QCameraLens::PerspectiveProjection. + */ + +/*! + * \property QCameraLens::top + * Holds the current top plane of the camera lens. + * \note The return value may be undefined if the projection type is + * Qt3DRender::QCameraLens::PerspectiveProjection. + */ + +/*! + * \property QCameraLens::projectionMatrix + * Holds the current projection matrix of the camera lens. + * \readonly + */ + +/*! + * \internal + */ QCameraLensPrivate::QCameraLensPrivate() : Qt3DCore::QComponentPrivate() , m_projectionType(QCameraLens::PerspectiveProjection) @@ -61,6 +217,9 @@ QCameraLensPrivate::QCameraLensPrivate() { } +/*! + * Constructs a QCameraLens with given \a parent + */ QCameraLens::QCameraLens(QNode *parent) : Qt3DCore::QComponent(*new QCameraLensPrivate, parent) { @@ -73,14 +232,6 @@ QCameraLens::~QCameraLens() { } -/*! \class Qt3DRender::QCameraLens - * \inmodule Qt3DCore - * - * \brief Qt3DRender::QCameraLens specifies the projection matrix that will be used to - * define a Camera for a 3D scene. - * - * \since 5.5 - */ QCameraLens::QCameraLens(QCameraLensPrivate &dd, QNode *parent) : QComponent(dd, parent) { @@ -88,17 +239,6 @@ QCameraLens::QCameraLens(QCameraLensPrivate &dd, QNode *parent) d->updateOrthographicProjection(); } -/*! - * \enum Qt3DRender::QCameraLens::ProjectionType - * - * Specifies which parameters of Qt3DRender::QCameraLens are used to compute the projection matrix. - * - * \value OrthographicProjection - * \value PerspectiveProjection - * \value FrustumProjection - * \value CustomProjection - */ - /*! * Sets the lens' projection type \a projectionType. * @@ -120,9 +260,6 @@ void QCameraLens::setProjectionType(QCameraLens::ProjectionType projectionType) } } -/*! - * Returns the lens' projection type. - */ QCameraLens::ProjectionType QCameraLens::projectionType() const { Q_D(const QCameraLens); @@ -207,9 +344,6 @@ void QCameraLens::setNearPlane(float nearPlane) d->updateProjectionMatrix(); } -/*! - * Returns the projection's near plane. - */ float QCameraLens::nearPlane() const { Q_D(const QCameraLens); @@ -234,9 +368,6 @@ void QCameraLens::setFarPlane(float farPlane) d->updateProjectionMatrix(); } -/*! - * Returns the projection's far plane. - */ float QCameraLens::farPlane() const { Q_D(const QCameraLens); @@ -264,12 +395,6 @@ void QCameraLens::setFieldOfView(float fieldOfView) d->updateProjectionMatrix(); } -/*! - * Returns the projection's field of view in degrees. - * - * \note: The return value may be undefined if the projection type is not - * Qt3DRender::QCameraLens::PerspectiveProjection. - */ float QCameraLens::fieldOfView() const { Q_D(const QCameraLens); @@ -297,12 +422,6 @@ void QCameraLens::setAspectRatio(float aspectRatio) d->updateProjectionMatrix(); } -/*! - * Returns the projection's aspect ratio. - * - * \note: The return value may be undefined if the projection type is not - * Qt3DRender::QCameraLens::PerspectiveProjection. - */ float QCameraLens::aspectRatio() const { Q_D(const QCameraLens); @@ -330,12 +449,6 @@ void QCameraLens::setLeft(float left) d->updateProjectionMatrix(); } -/*! - * Returns the lower left window coordinate of the projection. - * - * \note The return value may be undefined if the projection type is - * Qt3DRender::QCameraLens::PerspectiveProjection. - */ float QCameraLens::left() const { Q_D(const QCameraLens); @@ -363,12 +476,6 @@ void QCameraLens::setRight(float right) d->updateProjectionMatrix(); } -/*! - * Returns the upper right window coordinate of the projection. - * - * \note The return value may be undefined if the projection type is - * Qt3DRender::QCameraLens::PerspectiveProjection. - */ float QCameraLens::right() const { Q_D(const QCameraLens); @@ -396,12 +503,6 @@ void QCameraLens::setBottom(float bottom) d->updateProjectionMatrix(); } -/*! - * Returns the bottom window coordinate of the projection. - * - * \note The return value may be undefined if the projection type is - * Qt3DRender::QCameraLens::PerspectiveProjection. - */ float QCameraLens::bottom() const { Q_D(const QCameraLens); @@ -429,12 +530,6 @@ void QCameraLens::setTop(float top) d->updateProjectionMatrix(); } -/*! - * Returns the bottom window coordinate of the projection. - * - * \note The return value may be undefined if the projection type is - * Qt3DRender::QCameraLens::PerspectiveProjection. - */ float QCameraLens::top() const { Q_D(const QCameraLens); @@ -442,7 +537,7 @@ float QCameraLens::top() const } /*! - * Sets the project matrix. + * Sets the project matrix to \a projectionMatrix. * * \note This will set the projection type to Qt3DRender::QCameraLens::CustomProjection and thus * ignore all other camera parameters that might have been specified. @@ -457,9 +552,6 @@ void QCameraLens::setProjectionMatrix(const QMatrix4x4 &projectionMatrix) emit projectionMatrixChanged(projectionMatrix); } -/*! - * Returns the projection matrix. - */ QMatrix4x4 QCameraLens::projectionMatrix() const { Q_D(const QCameraLens); @@ -476,59 +568,4 @@ Qt3DCore::QNodeCreatedChangeBasePtr QCameraLens::createNodeCreationChange() cons } // Qt3DRender -/*! - \qmltype CameraLens - \instantiates Qt3DRender::QCameraLens - \inqmlmodule Qt3D.Core - \inherits Component3D - \since 5.5 - \brief Provides the projection matrix that is used to define a Camera for 3D scene. -*/ - -/*! - \qmlproperty enumeration Qt3DCore::CameraLens::projectionType - - Holds the type of the camera projection (orthogonal or perspective). - - \value CameraLens.OrthographicProjection Orthogonal projection - \value CameraLens.PerspectiveProjection Perspective projection -*/ - -/*! - \qmlproperty float Qt3DCore::CameraLens::nearPlane -*/ - -/*! - \qmlproperty float Qt3DCore::CameraLens::farPlane -*/ - -/*! - \qmlproperty float Qt3DCore::CameraLens::fieldOfView -*/ - -/*! - \qmlproperty float Qt3DCore::CameraLens::aspectRatio -*/ - -/*! - \qmlproperty float Qt3DCore::CameraLens::left -*/ - -/*! - \qmlproperty float Qt3DCore::CameraLens::right -*/ - -/*! - \qmlproperty float Qt3DCore::CameraLens::bottom -*/ - -/*! - \qmlproperty float Qt3DCore::CameraLens::top -*/ - -/*! - \qmlproperty matrix4x4 Qt3DCore::CameraLens::projectionMatrix - \readonly -*/ - QT_END_NAMESPACE -- cgit v1.2.3 From 75ff2892bcaaf586856d28524fd461c2eaee5314 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antti=20M=C3=A4=C3=A4tt=C3=A4?= Date: Fri, 2 Sep 2016 14:18:52 +0300 Subject: Update QFrameGraphNode docs Change-Id: I3d974b7ab1f5e0b829b139c71a1469fe35dd5ec1 Reviewed-by: Miikka Heikkinen Reviewed-by: Paul Lemire --- src/render/framegraph/qframegraphnode.cpp | 109 +++++++++++++++++++++++++++--- 1 file changed, 99 insertions(+), 10 deletions(-) diff --git a/src/render/framegraph/qframegraphnode.cpp b/src/render/framegraph/qframegraphnode.cpp index add8fc75d..c60c859ac 100644 --- a/src/render/framegraph/qframegraphnode.cpp +++ b/src/render/framegraph/qframegraphnode.cpp @@ -50,14 +50,57 @@ QFrameGraphNodePrivate::QFrameGraphNodePrivate() } /*! - \class Qt3DRender::QFrameGraphNode - \inmodule Qt3DRender - \since 5.5 - - \brief Base class of all FrameGraph configuration nodes. + \class Qt3DRender::QFrameGraphNode + \inmodule Qt3DRender + \since 5.5 - This is an abstract class so it cannot be instanced directly - but rather through one of its subclasses. + \brief Base class of all FrameGraph configuration nodes. + + This is an abstract class so it cannot be instanced directly + but rather through one of its subclasses. + + The subclasses are: + \table + \header + \li class + \li description + \row + \li Qt3DRender::QCameraSelector + \li Select camera from all available cameras in the scene + \row + \li Qt3DRender::QClearBuffers + \li Specify which buffers to clear and to what values + \row + \li Qt3DRender::QDispatchCompute + \li Specify Compute operation kernels + \row + \li Qt3DRender::QFrustumCulling + \li Enable frustum culling + \row + \li Qt3DRender::QLayerFilter + \li Select which layers to draw + \row + \li Qt3DRender::QNoDraw + \li Disable drawing + \row + \li Qt3DRender::QRenderPassFilter + \li Select which render passes to draw + \row + \li Qt3DRender::QRenderStateSet + \li Set render states + \row + \li Qt3DRender::QRenderSurfaceSelector + \li Select which surface to draw to + \row + \li Qt3DRender::QSortPolicy + \li Specify how entities are sorted to determine draw order + \row + \li Qt3DRender::QTechniqueFilter + \li Select which techniques to draw + \row + \li Qt3DRender::QViewport + \li Specify viewport + \endtable */ @@ -67,11 +110,57 @@ QFrameGraphNodePrivate::QFrameGraphNodePrivate() \instantiates Qt3DRender::QFrameGraphNode \inherits Node \since 5.5 - \qmlabstract + \brief Base class of all FrameGraph configuration nodes. + + This is an abstract class so it cannot be instanced directly + but rather through one of its subclasses. + + The subclasses are: + \table + \header + \li class + \li description + \row + \li CameraSelector + \li Select camera from all available cameras in the scene + \row + \li ClearBuffers + \li Specify which buffers to clear and to what values + \row + \li DispatchCompute + \li Specify Compute operation kernels + \row + \li FrustumCulling + \li Enable frustum culling + \row + \li LayerFilter + \li Select which layers to draw + \row + \li NoDraw + \li Disable drawing + \row + \li RenderPassFilter + \li Select which render passes to draw + \row + \li RenderStateSet + \li Set render states + \row + \li RenderSurfaceSelector + \li Select which surface to draw to + \row + \li SortPolicy + \li Specify how entities are sorted to determine draw order + \row + \li TechniqueFilter + \li Select which techniques to draw + \row + \li Viewport + \li Specify viewport + \endtable */ /*! - The constructor creates an instance with the specified \a parent. + The constructor creates an instance with the specified \a parent. */ QFrameGraphNode::QFrameGraphNode(QNode *parent) : QNode(*new QFrameGraphNodePrivate, parent) @@ -84,7 +173,7 @@ QFrameGraphNode::~QFrameGraphNode() } /*! - Returns a pointer to the parent. + Returns a pointer to the parent. */ QFrameGraphNode *QFrameGraphNode::parentFrameGraphNode() const { -- cgit v1.2.3 From 62870fd336b04e210d1ac5b7a8e5d653c04512c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antti=20M=C3=A4=C3=A4tt=C3=A4?= Date: Fri, 2 Sep 2016 14:38:07 +0300 Subject: Update QSortPolicy docs Change-Id: I28f5d587d81b8c6f2263b68325847872df40e0c3 Reviewed-by: Miikka Heikkinen Reviewed-by: Paul Lemire --- src/render/framegraph/qsortpolicy.cpp | 63 ++++++++++++++++++++--------------- 1 file changed, 37 insertions(+), 26 deletions(-) diff --git a/src/render/framegraph/qsortpolicy.cpp b/src/render/framegraph/qsortpolicy.cpp index 50fcae50f..a20ebd201 100644 --- a/src/render/framegraph/qsortpolicy.cpp +++ b/src/render/framegraph/qsortpolicy.cpp @@ -53,23 +53,34 @@ QSortPolicyPrivate::QSortPolicyPrivate() } /*! - * \class Qt3DRender::QSortPolicy - * \inmodule Qt3DRender - * \brief Provides storage for the sort types to be used - * \since 5.7 - * - * \inherits Qt3DRender::QFrameGraphNode - * + \class Qt3DRender::QSortPolicy + \inmodule Qt3DRender + \brief Provides storage for the sort types to be used + \since 5.7 + + \inherits Qt3DRender::QFrameGraphNode + + A Qt3DRender::QSortPolicy class stores the sorting type used by the FrameGraph. + The sort types determine how drawable entities are sorted before drawing to + determine the drawing order. When QSortPolicy is present in the FrameGraph, + the sorting mechanism is determined by the SortTypes list. Multiple sort types + can be used simultanously. If QSortPolicy is not present in the FrameGraph, + entities are drawn in the order they appear in the entity hierarchy. */ /*! - * \qmltype SortPolicy - * \inqmlmodule Qt3D.Render - * \since 5.7 - * \ingroup - * \instantiates Qt3DRender::QSortPolicy - * \brief Provides storage for the sort types to be used - * + \qmltype SortPolicy + \inqmlmodule Qt3D.Render + \since 5.7 + \instantiates Qt3DRender::QSortPolicy + \brief Provides storage for the sort types to be used + + A SortPolicy class stores the sorting type used by the FrameGraph. + The sort types determine how drawable entities are sorted before drawing to + determine the drawing order. When SortPolicy is present in the FrameGraph, + the sorting mechanism is determined by the SortTypes list. Multiple sort + types can be used simultanously. If SortPolicy is not present in the FrameGraph, + entities are drawn in the order they appear in the entity hierarchy. */ /*! @@ -82,7 +93,17 @@ QSortPolicyPrivate::QSortPolicyPrivate() */ /*! - * Constructs QSortPolicy with given \a parent. + \property QSortPolicy::sortTypes + Specifies the sorting types to be used. +*/ + +/*! + \qmlproperty QVariantList SortPolicy::sortTypes + Specifies the sorting types to be used. +*/ + +/*! + Constructs QSortPolicy with given \a parent. */ QSortPolicy::QSortPolicy(QNode *parent) : QFrameGraphNode(*new QSortPolicyPrivate, parent) @@ -110,17 +131,7 @@ QNodeCreatedChangeBasePtr QSortPolicy::createNodeCreationChange() const } /*! - \property Qt3DRender::QSortPolicy::sortTypes - Specifies the sorting types to be used. -*/ - -/*! - \qmlproperty QVariantList Qt3D.Render::QSortPolicy::sortTypes - Specifies the sorting types to be used. - -*/ -/*! - * \return the current sort types in use + \return the current sort types in use */ QVector QSortPolicy::sortTypes() const { -- cgit v1.2.3 From d804e3026c7e1517ee2dffdabaa7ed31c5d8e629 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antti=20M=C3=A4=C3=A4tt=C3=A4?= Date: Fri, 2 Sep 2016 14:56:36 +0300 Subject: Update QCameraSelector docs Change-Id: I349f40e488465a147970f1d52696cf1fa9e22063 Reviewed-by: Miikka Heikkinen Reviewed-by: Paul Lemire --- src/render/framegraph/qcameraselector.cpp | 38 +++++++++++++++++++------------ 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/src/render/framegraph/qcameraselector.cpp b/src/render/framegraph/qcameraselector.cpp index a9188cd99..c7d299b9b 100644 --- a/src/render/framegraph/qcameraselector.cpp +++ b/src/render/framegraph/qcameraselector.cpp @@ -48,13 +48,15 @@ QT_BEGIN_NAMESPACE namespace Qt3DRender { /*! - \class Qt3DRender::QCameraSelector - \inmodule Qt3DRender - \since 5.5 - \ingroup framegraph + \class Qt3DRender::QCameraSelector + \inmodule Qt3DRender + \since 5.5 + \ingroup framegraph - \brief Class to allow for selection of camera to be used + \brief Class to allow for selection of camera to be used + A Qt3DRender::QCameraSelector can be used to select the camera, which is used + by the FrameGraph when drawing the entities. */ /*! @@ -63,9 +65,25 @@ namespace Qt3DRender { \instantiates Qt3DRender::QCameraSelector \inherits FrameGraphNode \since 5.5 - \qmlabstract + \brief Class to allow for selection of camera to be used + + A CameraSelector can be used to select the camera, which is used + by the FrameGraph when drawing the entities. +*/ + +/*! + \qmlproperty Entity Qt3D.Render::CameraSelector::camera + + Holds the currently selected camera. */ +/*! + \property Qt3DRender::QCameraSelector::camera + + Holds the currently selected camera. +*/ + + /*! \internal */ QCameraSelector::QCameraSelector(QCameraSelectorPrivate &dd, QNode *parent) : QFrameGraphNode(dd, parent) @@ -91,14 +109,6 @@ QCameraSelector::~QCameraSelector() { } -/*! - \property Qt3DRender::QCameraSelector::camera -*/ - -/*! - \qmlproperty Entity Qt3D.Render::CameraSelector::camera - -*/ void QCameraSelector::setCamera(Qt3DCore::QEntity *camera) { Q_D(QCameraSelector); -- cgit v1.2.3 From 9c1e382ac01208699d31fa838ba253a42938566f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antti=20M=C3=A4=C3=A4tt=C3=A4?= Date: Mon, 5 Sep 2016 10:24:14 +0300 Subject: Update QFrameAction docs Change-Id: I4bcde9ed1e1ab8a9d127dd1d4c75d30f8c342641 Reviewed-by: Paul Lemire Reviewed-by: Miikka Heikkinen --- src/logic/qframeaction.cpp | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/src/logic/qframeaction.cpp b/src/logic/qframeaction.cpp index a7ca8d5d4..fa4cefe06 100644 --- a/src/logic/qframeaction.cpp +++ b/src/logic/qframeaction.cpp @@ -55,8 +55,8 @@ QFrameActionPrivate::QFrameActionPrivate() \since 5.5 \brief Provides a way to have a synchronous function executed each frame. - The QFrameAction provides a way to perform tasks each frame in - synchronized with the Qt3D backend. This is useful to implement some + The QFrameAction provides a way to perform tasks each frame in a + synchronized way with the Qt3D backend. This is useful to implement some aspects of application logic and to prototype functionality that can later be folded into an additional Qt3D aspect. @@ -64,7 +64,7 @@ QFrameActionPrivate::QFrameActionPrivate() with the Qt3D engine where a Qt Quick animation element is not perfectly synchronized and may lead to stutters in some cases. - To execute your own code each frame override the onTriggered function. + To execute your own code each frame connect to the QFrameAction::triggered signal. */ /*! @@ -73,6 +73,18 @@ QFrameActionPrivate::QFrameActionPrivate() \instantiates Qt3DLogic::QFrameAction \inherits Component3D \since 5.5 + \brief Provides a way to have a synchronous function executed each frame. + + The FrameAction provides a way to perform tasks each frame in a + synchronized way with the Qt3D backend. This is useful to implement some + aspects of application logic and to prototype functionality that can later + be folded into an additional Qt3D aspect. + + For example, the FrameAction can be used to animate a property in sync + with the Qt3D engine where a Qt Quick animation element is not perfectly + synchronized and may lead to stutters in some cases. + + To execute your own code each frame connect to the FrameAction::triggered signal. */ /*! @@ -107,15 +119,13 @@ void QFrameAction::onTriggered(float dt) } /*! - \qmlsignal Qt3D.Logic::FrameAction::triggered(float dt) + \qmlsignal Qt3D.Logic::FrameAction::triggered(real dt) This signal is emitted each frame. - - The corresponding handler is \c onTriggered */ /*! - \fn QFrameAction::triggered(float dt) - This signal is emitted each frame with \a dt being the time since the last triggering. + \fn QFrameAction::triggered(float dt) + This signal is emitted each frame with \a dt being the time since the last triggering. */ } // namespace Qt3DLogic -- cgit v1.2.3 From 0dc1fb59a1f8716dd51e046d5b375468a51f907c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antti=20M=C3=A4=C3=A4tt=C3=A4?= Date: Mon, 5 Sep 2016 10:48:55 +0300 Subject: Update QMouseDevice docs Change-Id: I6739fb95ed549fa02e9308d89e695f028fec4ed7 Reviewed-by: Paul Lemire --- src/input/frontend/qmousedevice.cpp | 63 +++++++++++++++++++++++-------------- 1 file changed, 40 insertions(+), 23 deletions(-) diff --git a/src/input/frontend/qmousedevice.cpp b/src/input/frontend/qmousedevice.cpp index d0ae0317d..bbf42b793 100644 --- a/src/input/frontend/qmousedevice.cpp +++ b/src/input/frontend/qmousedevice.cpp @@ -45,35 +45,43 @@ QT_BEGIN_NAMESPACE namespace Qt3DInput { + /*! \internal */ QMouseDevicePrivate::QMouseDevicePrivate() : QAbstractPhysicalDevicePrivate() , m_sensitivity(0.1f) { } -/*! - * \qmltype MouseDevice - * \instantiates Qt3DInput::QMouseDevice - * \inqmlmodule Qt3D.Input - * \since 5.5 - * \brief Delegates mouse events to the attached MouseHandler objects. - * \TODO - * \sa MouseHandler - */ /*! - * \class Qt3DInput::QMouseDevice - * \inmodule Qt3DInput - * - * \brief QMouseDevice is in charge of dispatching mouse events to - * attached QMouseHandler objects. - * - * \since 5.5 - * \sa QMouseHandler + \qmltype MouseDevice + \instantiates Qt3DInput::QMouseDevice + \inqmlmodule Qt3D.Input + \since 5.5 + \brief Delegates mouse events to the attached MouseHandler objects. + + A MouseDevice delegates mouse events from physical mouse device to + MouseHandler objects. The sensitivity of the mouse can be controlled + with the \l MouseDevice::sensitivity property, which specifies the rate + in which the logical mouse coordinates change in response to physical + movement of the mouse. + + \sa MouseHandler */ /*! - \qmlproperty real MouseDevice::sensitivity + \class Qt3DInput::QMouseDevice + \inmodule Qt3DInput + \since 5.5 + \brief Delegates mouse events to the attached MouseHandler objects. + + A QMouseDevice delegates mouse events from physical mouse device to + QMouseHandler objects. The sensitivity of the mouse can be controlled + with the \l QMouseDevice::sensitivity property, which specifies the rate + in which the logical mouse coordinates change in response to physical + movement of the mouse. + + \sa QMouseHandler */ /*! @@ -87,6 +95,20 @@ QMouseDevicePrivate::QMouseDevicePrivate() \sa Qt3DInput::QAnalogAxisInput::setAxis */ +/*! + \qmlproperty real MouseDevice::sensitivity + + Holds the current sensitivity of the mouse device. + Default is 0.1. + */ + +/*! + \property Qt3DInput::QMouseDevice::sensitivity + + Holds the sensitivity of the mouse device. + Default is 0.1. + */ + /*! Constructs a new QMouseDevice instance with parent \a parent. */ @@ -158,11 +180,6 @@ int QMouseDevice::axisIdentifier(const QString &name) const return -1; } -/*! - \property Qt3DInput::QMouseDevice::sensitivity - - The sensitivity of the device. - */ float QMouseDevice::sensitivity() const { Q_D(const QMouseDevice); -- cgit v1.2.3 From c40d48102f853788f079c036beb7eb7113472a01 Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Mon, 5 Sep 2016 12:20:54 +0300 Subject: Improve QInputSettings docs Change-Id: I583cca3c0af117b97465f84190663908877d51b0 Reviewed-by: Paul Lemire --- src/input/frontend/qinputsettings.cpp | 56 ++++++++++++++--------------------- 1 file changed, 22 insertions(+), 34 deletions(-) diff --git a/src/input/frontend/qinputsettings.cpp b/src/input/frontend/qinputsettings.cpp index 08e3ce300..34ed3b438 100644 --- a/src/input/frontend/qinputsettings.cpp +++ b/src/input/frontend/qinputsettings.cpp @@ -48,10 +48,15 @@ namespace Qt3DInput { /*! \class Qt3DInput::QInputSettings \inmodule Qt3DInput - \inherits Qt3DCore::QComponant - \brief QInputSettings stores settings for the specified eventSource. - + \inherits Qt3DCore::QComponent + \brief QInputSettings class holds the pointer to an input event source object. \since 5.7 + + The QInputSettings component must be set as a component of the scene root entity. + It stores a pointer to the object that acts as the source of input events to be handled + by various input classes. For example, a QWindow instance can be an event source. + + \sa QMouseDevice, QKeyboardDevice */ /*! @@ -59,10 +64,14 @@ namespace Qt3DInput { \inqmlmodule Qt3D.Input \inherits Component3D \instantiates Qt3DInput::QInputSettings - \brief QML frontend for the Qt3DInput::QInputSettings C++ class. - - Stores settings the specified eventSource + \brief InputSettings holds the pointer to an input event source object. \since 5.7 + + The InputSettings component must be set as a component of the scene root entity. + It stores a pointer to the object that acts as the source of input events to be handled + by various input classes. For example, a Window instance can be an event source. + + \sa MouseDevice, KeyboardDevice */ QInputSettingsPrivate::QInputSettingsPrivate() @@ -71,15 +80,11 @@ QInputSettingsPrivate::QInputSettingsPrivate() { } -/*! - Constructs a new QInputSettings instance with \a parent. - */ QInputSettings::QInputSettings(Qt3DCore::QNode *parent) : Qt3DCore::QComponent(*new QInputSettingsPrivate(), parent) { } -/*! \internal */ QInputSettings::~QInputSettings() { } @@ -87,41 +92,24 @@ QInputSettings::~QInputSettings() /*! \property QInputSettings::eventSource - Holds the source for the QInputSettings. + Holds the current event source. An event source is an object that is capable + of receiving various input events, such as mouse or keyboard events. + Typically it is a QWindow instance. */ -/*! - \fn QInputSettings::eventSourceChanged(QObject *) - - This signal is emitted when the even source associated with the input setting is changed. -*/ /*! - \qmlproperty QObject Qt3D.Input::InputSettings::eventSource + \qmlproperty Object InputSettings::eventSource - The current event source of the InputSettings object + Holds the current event source. An event source is an object that is capable + of receiving various input events, such as mouse or keyboard events. + Typically it is a Window instance. */ - -/*! - \qmlsignal Qt3D.Input::InputSettings::ventSourceChanged(QObject *) - - This signal is emitted when the even source associated with the input setting is changed. - - The corresponding handler is \c onEventSourceChanged -*/ - -/*! - * \brief QInputSettings::eventSource - * \return the current event source of the QInputSettings instance. - */ QObject *QInputSettings::eventSource() const { Q_D(const QInputSettings); return d->m_eventSource; } -/*! - Set the current event source of the QInputSettings instance to \a eventSource. - */ void QInputSettings::setEventSource(QObject *eventSource) { Q_D(QInputSettings); -- cgit v1.2.3 From 9b47f02d9cdd720e937ac22296f4873f6bc66c6b Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Mon, 5 Sep 2016 13:28:33 +0300 Subject: Update QEffect docs Change-Id: I9266413eec2e23457198016cc63be8aaebab3db0 Reviewed-by: Paul Lemire --- src/render/materialsystem/qeffect.cpp | 40 +++++++++++++++++++++++++---------- 1 file changed, 29 insertions(+), 11 deletions(-) diff --git a/src/render/materialsystem/qeffect.cpp b/src/render/materialsystem/qeffect.cpp index 70810676c..7778b5621 100644 --- a/src/render/materialsystem/qeffect.cpp +++ b/src/render/materialsystem/qeffect.cpp @@ -58,12 +58,17 @@ QEffectPrivate::QEffectPrivate() } /*! - \class Qt3DRender::QEffect - \inmodule Qt3DRender - \since 5.7 - \brief The base class for effects in a Qt 3D scene. + \class Qt3DRender::QEffect + \inmodule Qt3DRender + \inherits Qt3DCore::QNode + \since 5.7 + \brief The base class for effects in a Qt 3D scene. - */ + The QEffect class combines a set of techniques and parameters used by those techniques to + produce a rendering effect for a material. + + \sa QMaterial, QTechnique, QParameter +*/ /*! \qmltype Effect @@ -72,18 +77,18 @@ QEffectPrivate::QEffectPrivate() \inqmlmodule Qt3D.Render \since 5.7 \brief The base class for effects in a Qt 3D scene. + + The Effect type combines a set of techniques and parameters used by those techniques to + produce a rendering effect for a material. + + \sa Material, Technique, Parameter */ -/*! - \fn Qt3DRender::QEffect::QEffect(Qt3DCore::QNode *parent) - Constructs a new QEffect with the specified \a parent. - */ QEffect::QEffect(QNode *parent) : QNode(*new QEffectPrivate, parent) { } -/*! \internal */ QEffect::~QEffect() { } @@ -94,9 +99,22 @@ QEffect::QEffect(QEffectPrivate &dd, QNode *parent) { } +/*! + \qmlproperty list Effect::techniques + + Holds the list of techniques used by this effect. +*/ +/*! + \qmlproperty list Effect::parameters + + Holds the list of parameters used by this effect. + A parameter is used to set a corresponding uniform value in the shader used by this effect. +*/ + /*! * Adds \a parameter to the effect. It sends a QPropertyNodeAddedChange to the backend. - * The \a parameter will be used to set a corresponding uniform value in the shader used by this effect. + * The \a parameter will be used to set a corresponding uniform value in the shader used + * by this effect. */ void QEffect::addParameter(QParameter *parameter) { -- cgit v1.2.3 From 27c1f0e1b2a873ecdef1b0c74ca416d6794e7a06 Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Fri, 2 Sep 2016 16:23:36 +0300 Subject: Fix documentation of QRenderSettings and QPickingSettings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Task-number: QTBUG-55697 Change-Id: I7a357f6f00b62c1ef2042f4088374dcd34005110 Reviewed-by: Antti Määttä Reviewed-by: Paul Lemire --- src/render/frontend/qpickingsettings.cpp | 89 +++++++++++++++++++---------- src/render/frontend/qrendersettings.cpp | 96 ++++++++++++++++++++++++-------- 2 files changed, 133 insertions(+), 52 deletions(-) diff --git a/src/render/frontend/qpickingsettings.cpp b/src/render/frontend/qpickingsettings.cpp index 0e152f5f1..e1c403ba3 100644 --- a/src/render/frontend/qpickingsettings.cpp +++ b/src/render/frontend/qpickingsettings.cpp @@ -45,12 +45,25 @@ QT_BEGIN_NAMESPACE namespace Qt3DRender { /*! - * \class Qt3DRender::QPickingSettings - * \brief The QPickingSettings class specifies the current framegraph to be used - * by the renderer and specifies whether rendering is always active or updated - * only on changes. - * \since 5.7 - * \inmodule Qt3DRender + \class Qt3DRender::QPickingSettings + \brief The QPickingSettings class specifies how entity picking is handled. + \since 5.7 + \inmodule Qt3DRender + \inherits Qt3DCore::QNode + + The picking settings determine how the entity picking is handled. For more details about + entity picking, see QObjectPicker component documentation. + */ + +/*! + \qmltype PickingSettings + \brief The PickingSettings class specifies how entity picking is handled. + \since 5.7 + \inqmlmodule Qt3D.Render + \instantiates Qt3DRender::QPickingSettings + + The picking settings determine how the entity picking is handled. For more details about + entity picking, see Qt3DRender::QObjectPicker component documentation. */ QPickingSettingsPrivate::QPickingSettingsPrivate() @@ -60,11 +73,6 @@ QPickingSettingsPrivate::QPickingSettingsPrivate() { } -/*! - * The constructor creates a new Qt3DRender::QPickingSettings - * instance with the specified \a parent. - * \param parent - */ QPickingSettings::QPickingSettings(Qt3DCore::QNode *parent) : Qt3DCore::QNode(*new QPickingSettingsPrivate, parent) { @@ -81,18 +89,12 @@ QPickingSettings::QPickingSettings(QPickingSettingsPrivate &dd, Qt3DCore::QNode { } -/*! - * \return the current pick method. - */ QPickingSettings::PickMethod QPickingSettings::pickMethod() const { Q_D(const QPickingSettings); return d->m_pickMethod; } -/*! - * \return the current pick result mode. - */ QPickingSettings::PickResultMode QPickingSettings::pickResultMode() const { Q_D(const QPickingSettings); @@ -102,16 +104,31 @@ QPickingSettings::PickResultMode QPickingSettings::pickResultMode() const /*! * \enum Qt3DRender::QPickingSettings::PickMethod * - * Specifies which parameters of Qt3DRender::QPickingSettings are used. + * Specifies the picking method. * - * \value BoundingVolumePicking - * \value TrianglePicking + * \value BoundingVolumePicking An entity is considered picked if the picking ray intersects + * the bounding volume of the entity. + * \value TrianglePicking An entity is considered picked if the picking ray intersects with + * any triangle of the entity's mesh component. */ /*! - * Sets the pick method to \a pickMethod - * \param pickMethod - */ + \qmlproperty enumeration PickingSettings::pickMethod + + Holds the current pick method. + + \list + \li PickingSettings.BoundingVolumePicking + \li PickingSettings.TrianglePicking + \endlist + + \sa Qt3DRender::QPickingSettings::PickMethod +*/ +/*! + \property QPickingSettings::pickMethod + + Holds the current pick method. +*/ void QPickingSettings::setPickMethod(QPickingSettings::PickMethod pickMethod) { Q_D(QPickingSettings); @@ -125,16 +142,30 @@ void QPickingSettings::setPickMethod(QPickingSettings::PickMethod pickMethod) /*! * \enum Qt3DRender::QPickingSettings::PickResultMode * - * Specifies which parameters of Qt3DRender::PickResultMode are used. + * Specifies what is included into the picking results. * - * \value NearestPick - * \value AllPicks + * \value NearestPick Only the nearest entity to picking ray origin intersected by the picking ray + * is picked. + * \value AllPicks All entities that intersect the picking ray are picked. */ /*! - * Sets the pick result mode to \a pickResultMode - * \param pickResultMode - */ + \qmlproperty enumeration PickingSettings::pickResultMode + + Holds the current pick results mode. + + \list + \li PickingSettings.NearestPick + \li PickingSettings.AllPicks + \endlist + + \sa Qt3DRender::QPickingSettings::PickResultMode +*/ +/*! + \property QPickingSettings::pickResultMode + + Holds the current pick results mode. +*/ void QPickingSettings::setPickResultMode(QPickingSettings::PickResultMode pickResultMode) { Q_D(QPickingSettings); diff --git a/src/render/frontend/qrendersettings.cpp b/src/render/frontend/qrendersettings.cpp index 715c9cc5e..d9ce3c3c9 100644 --- a/src/render/frontend/qrendersettings.cpp +++ b/src/render/frontend/qrendersettings.cpp @@ -46,10 +46,29 @@ QT_BEGIN_NAMESPACE namespace Qt3DRender { /*! - * \class Qt3DRender::QRenderSettings - * \brief The QRenderSettings class - * \since 5.7 - * \inmodule Qt3DRender + \class Qt3DRender::QRenderSettings + \brief The QRenderSettings class holds settings related to rendering process and host the active + \l{Qt 3D Render Framegraph}{FrameGraph}. + \since 5.7 + \inmodule Qt3DRender + \inherits Qt3DCore::QComponent + + The QRenderSettings component must be set as a component of the scene root entity. It specifies + render policy and picking settings, as well as hosts the active + \l{Qt 3D Render Framegraph}{FrameGraph}. + */ + +/*! + \qmltype RenderSettings + \brief The RenderSettings type holds settings related to rendering process and host the active + \l{Qt 3D Render Framegraph}{FrameGraph}. + \since 5.7 + \inqmlmodule Qt3D.Render + \instantiates Qt3DRender::QRenderSettings + + The RenderSettings component must be set as a component of the scene root entity. It specifies + render policy and picking settings, as well as hosts the active + \l{Qt 3D Render Framegraph}{FrameGraph}. */ /*! \internal */ @@ -82,11 +101,6 @@ void QRenderSettingsPrivate::_q_onPickResultModeChanged(QPickingSettings::PickRe notifyPropertyChange("pickResultMode", pickResultMode); } -/*! - * The constructor creates a new QRenderSettings::QRenderSettings instance with the - * specified \a parent. - * \param parent - */ QRenderSettings::QRenderSettings(Qt3DCore::QNode *parent) : QRenderSettings(*new QRenderSettingsPrivate, parent) {} @@ -104,8 +118,19 @@ QRenderSettings::~QRenderSettings() } /*! - * \return the current picking settings. - */ + \qmlproperty PickingSettings RenderSettings::pickingSettings + + Holds the current pick settings for the \l{Qt 3D Render Framegraph}{FrameGraph}. + + \readonly +*/ +/*! + \property QRenderSettings::pickingSettings + + Holds the current pick settings for the \l{Qt 3D Render Framegraph}{FrameGraph}. + + \readonly +*/ QPickingSettings *QRenderSettings::pickingSettings() { Q_D(QRenderSettings); @@ -113,27 +138,56 @@ QPickingSettings *QRenderSettings::pickingSettings() } /*! - * \return the current active framegraph. - */ + \qmlproperty FrameGraphNode RenderSettings::activeFrameGraph + + Holds the currently active \l{Qt 3D Render Framegraph}{FrameGraph}. +*/ +/*! + \property QRenderSettings::activeFrameGraph + + Holds the currently active \l{Qt 3D Render Framegraph}{FrameGraph}. +*/ QFrameGraphNode *QRenderSettings::activeFrameGraph() const { Q_D(const QRenderSettings); return d->m_activeFrameGraph; } + /*! - * \return the current render policy - */ + \enum QRenderSettings::RenderPolicy + + The render policy. + + \value OnDemand The \l{Qt 3D Render Framegraph}{FrameGraph} is rendered only when something + changes. + \value Always The \l{Qt 3D Render Framegraph}{FrameGraph} is rendered continuously, even if + nothing has changed. +*/ + +/*! + \qmlproperty enumeration RenderSettings::renderPolicy + + Holds the current render policy. + + \list + \li RenderSettings.OnDemand + \li RenderSettings.Always + \endlist + + \sa Qt3DRender::QRenderSettings::RenderPolicy +*/ +/*! + \property QRenderSettings::renderPolicy + + Holds the current render policy. +*/ QRenderSettings::RenderPolicy QRenderSettings::renderPolicy() const { Q_D(const QRenderSettings); return d->m_renderPolicy; } -/*! - * Sets the active framegraph to \a activeFrameGraph. - * \param activeFrameGraph - */ void QRenderSettings::setActiveFrameGraph(QFrameGraphNode *activeFrameGraph) { Q_D(QRenderSettings); @@ -155,10 +209,6 @@ void QRenderSettings::setActiveFrameGraph(QFrameGraphNode *activeFrameGraph) emit activeFrameGraphChanged(activeFrameGraph); } -/*! - * Sets the render policy to \a renderPolicy. - * \param renderPolicy - */ void QRenderSettings::setRenderPolicy(QRenderSettings::RenderPolicy renderPolicy) { Q_D(QRenderSettings); -- cgit v1.2.3 From 2f0dd9a147d74bb5df58c6f402b50b35313ae3ff Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Mon, 5 Sep 2016 14:02:03 +0300 Subject: Update QFilterKey docs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Id6bb471e11de2bf8b33cec603d382f079d0b0e79 Reviewed-by: Antti Määttä Reviewed-by: Paul Lemire --- src/render/materialsystem/qfilterkey.cpp | 40 +++++++++++++++++++------------- 1 file changed, 24 insertions(+), 16 deletions(-) diff --git a/src/render/materialsystem/qfilterkey.cpp b/src/render/materialsystem/qfilterkey.cpp index d4bc26515..547c56d26 100644 --- a/src/render/materialsystem/qfilterkey.cpp +++ b/src/render/materialsystem/qfilterkey.cpp @@ -55,8 +55,12 @@ QFilterKeyPrivate::QFilterKeyPrivate() /*! \class Qt3DRender::QFilterKey \inmodule Qt3DRender + \inherits Qt3DCore::QNode \since 5.5 - \brief The QFilterKey class provides storage for filter keys and their values + \brief The QFilterKey class provides storage for filter keys and their values. + + Filter keys are used by QTechnique and QRenderPass to specify at which stage of rendering the + technique or the render pass is used. */ /*! @@ -65,18 +69,18 @@ QFilterKeyPrivate::QFilterKeyPrivate() \inherits Node \inqmlmodule Qt3D.Render \since 5.5 - \brief For storing filter keys and their value + \brief Stores filter keys and their values. + + A FilterKey is a storage type for filter key and value pair. + Filter keys are used by Technique and RenderPass to specify at which stage of rendering the + technique or the render pass is used. */ -/*! - The constructor creates a new QFilterKey under \a parent. - */ QFilterKey::QFilterKey(QNode *parent) : QNode(*new QFilterKeyPrivate, parent) { } -/*! \internal */ QFilterKey::~QFilterKey() { } @@ -100,13 +104,15 @@ void QFilterKey::setName(const QString &name) } /*! - \property QFilterKey::value - Specifies the value of the filter key + \property QFilterKey::value + + Holds the value of the filter key. */ /*! - \qmlproperty variant Qt3D.Render::Annotation::value - Specifies the value of the filter key + \qmlproperty variant FilterKey::value + + Holds the value of the filter key. */ QVariant QFilterKey::value() const @@ -116,14 +122,16 @@ QVariant QFilterKey::value() const } /*! - \property QFilterKey::name - Specifies the name of the filter key - */ + \property QFilterKey::name + + Holds the name of the filter key. +*/ /*! - \qmlproperty string Qt3D.Render::Annotation::name - Specifies the name of the filter key - */ + \qmlproperty string FilterKey::name + + Holds the name of the filter key. +*/ QString QFilterKey::name() const { -- cgit v1.2.3 From 40fbc1c8e31c3ce10264763f2e9340b789d32563 Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Mon, 5 Sep 2016 14:39:33 +0300 Subject: Update QShaderProgram docs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I733333e6c707d590218fd5b19722e08908e52b49 Reviewed-by: Antti Määttä Reviewed-by: Paul Lemire --- src/render/materialsystem/qshaderprogram.cpp | 139 ++++++++++++++------------- 1 file changed, 74 insertions(+), 65 deletions(-) diff --git a/src/render/materialsystem/qshaderprogram.cpp b/src/render/materialsystem/qshaderprogram.cpp index da954210b..522f021aa 100644 --- a/src/render/materialsystem/qshaderprogram.cpp +++ b/src/render/materialsystem/qshaderprogram.cpp @@ -47,29 +47,37 @@ #include /*! - * \qmltype ShaderProgram - * \instantiates Qt3DRender::QShaderProgram - * \inqmlmodule Qt3D.Render - * \brief Encapsulates a Shader Program. - */ + \class Qt3DRender::QShaderProgram + \inmodule Qt3DRender + \brief Encapsulates a Shader Program. + \inherits Qt3DCore::QNode + \since 5.5 + + A shader program consists of several different shaders, such as vertex and fragment shaders. +*/ /*! - * \class Qt3DRender::QShaderProgram - * \inmodule Qt3DRender - * - * \brief Encapsulates a Shader Program. - */ + \qmltype ShaderProgram + \instantiates Qt3DRender::QShaderProgram + \inqmlmodule Qt3D.Render + \brief Encapsulates a Shader Program. + \since 5.5 + + ShaderProgram class encapsulates a shader program. A shader program consists of several + different shaders, such as vertex and fragment shaders. +*/ /*! \enum QShaderProgram::ShaderType - This enum identifies the type of shader used - \value Vertex - \value Fragment - \value TessellationControl - \value TessellationEvaluation - \value Geometry - \value Compute + This enum identifies the type of shader used. + + \value Vertex Vertex shader + \value Fragment Fragment shader + \value TessellationControl Tesselation control shader + \value TessellationEvaluation Tesselation evaluation shader + \value Geometry Geometry shader + \value Compute Compute shader */ QT_BEGIN_NAMESPACE @@ -81,16 +89,11 @@ QShaderProgramPrivate::QShaderProgramPrivate() { } -/*! - \fn Qt3DRender::QShaderProgram::QShaderProgram(Qt3DCore::QNode *parent) - Constructs a new QShaderProgram with the specified \a parent. - */ QShaderProgram::QShaderProgram(QNode *parent) : QNode(*new QShaderProgramPrivate, parent) { } -/*! \internal */ QShaderProgram::~QShaderProgram() { } @@ -102,14 +105,15 @@ QShaderProgram::QShaderProgram(QShaderProgramPrivate &dd, QNode *parent) } /*! - \qmlproperty QByteArray Qt3D.Render::ShaderProgram::vertexShaderCode - Specifies the vertex shader code to be used -*/ + \qmlproperty string ShaderProgram::vertexShaderCode + Holds the vertex shader code used by this shader program. +*/ /*! - \property Qt3DRender::QShaderProgram::vertexShaderCode - Specifies the vertex shader code to be used - */ + \property QShaderProgram::vertexShaderCode + + Holds the vertex shader code used by this shader program. +*/ void QShaderProgram::setVertexShaderCode(const QByteArray &vertexShaderCode) { Q_D(QShaderProgram); @@ -126,14 +130,15 @@ QByteArray QShaderProgram::vertexShaderCode() const } /*! - \qmlproperty QByteArray Qt3D.Render::ShaderProgram::tessellationControlShaderCode - Specifies the tessellation control shader code to be used -*/ + \qmlproperty string ShaderProgram::tessellationControlShaderCode + Holds the tesselation control shader code used by this shader program. +*/ /*! - \property Qt3DRender::QShaderProgram::tessellationControlShaderCode - Specifies the tessellation control shader code to be used - */ + \property QShaderProgram::tessellationControlShaderCode + + Holds the tesselation control shader code used by this shader program. +*/ void QShaderProgram::setTessellationControlShaderCode(const QByteArray &tessellationControlShaderCode) { Q_D(QShaderProgram); @@ -150,14 +155,15 @@ QByteArray QShaderProgram::tessellationControlShaderCode() const } /*! - \qmlproperty QByteArray Qt3D.Render::ShaderProgram::tessellationEvaluationShaderCode - Specifies the tessellation evaluation shader code to be used -*/ + \qmlproperty string ShaderProgram::tessellationEvaluationShaderCode + Holds the tesselation evaluation shader code used by this shader program. +*/ /*! - \property Qt3DRender::QShaderProgram::tessellationEvaluationShaderCode - Specifies the tessellation evaluation shader code to be used - */ + \property QShaderProgram::tessellationEvaluationShaderCode + + Holds the tesselation evaluation shader code used by this shader program. +*/ void QShaderProgram::setTessellationEvaluationShaderCode(const QByteArray &tessellationEvaluationShaderCode) { Q_D(QShaderProgram); @@ -174,14 +180,15 @@ QByteArray QShaderProgram::tessellationEvaluationShaderCode() const } /*! - \qmlproperty QByteArray Qt3D.Render::ShaderProgram::geometryShaderCode - Specifies the geometry shader code to be used -*/ + \qmlproperty string ShaderProgram::geometryShaderCode + Holds the geometry shader code used by this shader program. +*/ /*! - \property Qt3DRender::QShaderProgram::geometryShaderCode - Specifies the geometry shader code to be used - */ + \property QShaderProgram::geometryShaderCode + + Holds the geometry shader code used by this shader program. +*/ void QShaderProgram::setGeometryShaderCode(const QByteArray &geometryShaderCode) { Q_D(QShaderProgram); @@ -198,14 +205,15 @@ QByteArray QShaderProgram::geometryShaderCode() const } /*! - \qmlproperty QByteArray Qt3D.Render::ShaderProgram::fragmentShaderCode - Specifies the fragment shader code to be used -*/ + \qmlproperty string ShaderProgram::fragmentShaderCode + Holds the fragment shader code used by this shader program. +*/ /*! - \property Qt3DRender::QShaderProgram::fragmentShaderCode - Specifies the fragment shader code to be used - */ + \property QShaderProgram::fragmentShaderCode + + Holds the fragment shader code used by this shader program. +*/ void QShaderProgram::setFragmentShaderCode(const QByteArray &fragmentShaderCode) { Q_D(QShaderProgram); @@ -222,14 +230,15 @@ QByteArray QShaderProgram::fragmentShaderCode() const } /*! - \qmlproperty QByteArray Qt3D.Render::ShaderProgram::computeShaderCode - Specifies the compute shader code to be used -*/ + \qmlproperty string ShaderProgram::computeShaderCode + Holds the compute shader code used by this shader program. +*/ /*! - \property Qt3DRender::QShaderProgram::computeShaderCode - Specifies the compute shader code to be used - */ + \property QShaderProgram::computeShaderCode + + Holds the compute shader code used by this shader program. +*/ void QShaderProgram::setComputeShaderCode(const QByteArray &computeShaderCode) { Q_D(QShaderProgram); @@ -247,8 +256,8 @@ QByteArray QShaderProgram::computeShaderCode() const /*! - * Sets the \a type shader from raw data in \a shaderCode. - */ + Sets the shader code for \a type of shader to the \a shaderCode. +*/ void QShaderProgram::setShaderCode(ShaderType type, const QByteArray &shaderCode) { switch (type) { @@ -276,8 +285,8 @@ void QShaderProgram::setShaderCode(ShaderType type, const QByteArray &shaderCode } /*! - * Returns the \a type shader code. - */ + Returns the shader code for \a type. +*/ QByteArray QShaderProgram::shaderCode(ShaderType type) const { Q_D(const QShaderProgram); @@ -332,13 +341,13 @@ static QByteArray deincludify(const QString &filePath) } /*! - \qmlmethod QByteArray ShaderProgram::loadSource(const QUrl &sourceUrl) + \qmlmethod string ShaderProgram::loadSource(url sourceUrl) Returns the shader code loaded from \a sourceUrl. */ /*! - * Returns the shader code loaded from \a sourceUrl. - */ + Returns the shader code loaded from \a sourceUrl. +*/ QByteArray QShaderProgram::loadSource(const QUrl &sourceUrl) { // TO DO: Handle remote path -- cgit v1.2.3 From d41e6f9640c28d85fb5ade26a1a7f91406f6aa9e Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Mon, 5 Sep 2016 16:24:13 +0300 Subject: Update QMaterial docs Change-Id: Ib1e5304f96f1d39615102f72584f54dba2586e6c Reviewed-by: Paul Lemire --- src/render/materialsystem/qmaterial.cpp | 80 +++++++++++++++++---------------- 1 file changed, 42 insertions(+), 38 deletions(-) diff --git a/src/render/materialsystem/qmaterial.cpp b/src/render/materialsystem/qmaterial.cpp index 5b3fe63af..ca0f86463 100644 --- a/src/render/materialsystem/qmaterial.cpp +++ b/src/render/materialsystem/qmaterial.cpp @@ -48,29 +48,37 @@ #include /*! - * \qmltype Material - * \instantiates Qt3DRender::QMaterial - * \inqmlmodule Qt3D.Render - * \brief Non-creatable abstract base for materials. - * \inherits Component - */ + \qmltype Material + \instantiates Qt3DRender::QMaterial + \inqmlmodule Qt3D.Render + \brief Non-creatable abstract base for materials. + \since 5.5 + + Material provides a way to specify the rendering of an \l{Qt3D.Core::Entity}{entity}. + Any aspect can define its own subtype of Material so that a + Material can be used to describe a visual element; for example, the way + sound should reflect off an element, the temperature of a surface, + and so on. + + \sa Effect +*/ /*! - * \class Qt3DRender::QMaterial - * \inmodule Qt3DRender - * - * - * \brief Provides an abstract class that should be the base of all - * Material component classes in a scene. - * - * QMaterial provides a way to specify the rendering of an Entity. - * Any aspect can define its own subclass of QMaterial so that a - * Material can be used to describe a visual element; for example, the way - * sound should reflect off an element, the temperature of a surface, - * and so on. - * - * \sa QEffect, QMesh, {Qt3DCore::}{QComponent} - */ + \class Qt3DRender::QMaterial + \inmodule Qt3DRender + \inherits Qt3DCore::QComponent + \brief Provides an abstract class that should be the base of all material component classes + in a scene. + \since 5.5 + + QMaterial provides a way to specify the rendering of an \l{Qt3DCore::QEntity}{entity}. + Any aspect can define its own subclass of QMaterial so that a + Material can be used to describe a visual element; for example, the way + sound should reflect off an element, the temperature of a surface, + and so on. + + \sa QEffect +*/ QT_BEGIN_NAMESPACE @@ -88,16 +96,11 @@ QMaterialPrivate::~QMaterialPrivate() { } -/*! - \fn Qt3DRender::QMaterial::QMaterial(Qt3DCore::QNode *parent) - Constructs a new QMaterial with the specified \a parent. - */ QMaterial::QMaterial(QNode *parent) : QComponent(*new QMaterialPrivate, parent) { } -/*! \internal */ QMaterial::~QMaterial() { } @@ -109,16 +112,20 @@ QMaterial::QMaterial(QMaterialPrivate &dd, QNode *parent) } /*! - \qmlproperty QEffect Qt3D.Render::Material::effect - Specifies the effect to be used with the material + \qmlproperty list Material::parameters + + Holds the list of parameters used by the material. */ /*! - \property Qt3DRender::QMaterial::effect - Specifies the effect to be used with the material - */ + \qmlproperty Effect Material::effect + + Specifies the effect to be used with the material. +*/ /*! - * Sets the \a effect to be used with the Material. + \property QMaterial::effect + + Specifies the effect to be used with the material. */ void QMaterial::setEffect(QEffect *effect) { @@ -144,9 +151,6 @@ void QMaterial::setEffect(QEffect *effect) } } -/*! - * Returns the effect used by the Material. - */ QEffect *QMaterial::effect() const { Q_D(const QMaterial); @@ -154,7 +158,7 @@ QEffect *QMaterial::effect() const } /*! - * Add \a parameter to the Materials parameter. + * Add a \a parameter to the material's parameters. */ void QMaterial::addParameter(QParameter *parameter) { @@ -182,7 +186,7 @@ void QMaterial::addParameter(QParameter *parameter) } /*! - * Remove \a parameter from the Material parameters. + * Remove a \a parameter from the material's parameters. */ void QMaterial::removeParameter(QParameter *parameter) { @@ -197,7 +201,7 @@ void QMaterial::removeParameter(QParameter *parameter) } /*! - * Returns a vector of the materials current parameters + * Returns a vector of the material's current parameters */ QVector QMaterial::parameters() const { -- cgit v1.2.3 From c576d9f2ef0ddbab6159d969105c54a9183cfd21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antti=20M=C3=A4=C3=A4tt=C3=A4?= Date: Mon, 5 Sep 2016 14:58:23 +0300 Subject: Update QTechnique docs Change-Id: I5345954047540ef1d03ba42841bfca221cc35b7e Reviewed-by: Miikka Heikkinen Reviewed-by: Paul Lemire --- src/render/materialsystem/qtechnique.cpp | 90 +++++++++++++++++++++----------- 1 file changed, 59 insertions(+), 31 deletions(-) diff --git a/src/render/materialsystem/qtechnique.cpp b/src/render/materialsystem/qtechnique.cpp index f114e2754..768397e76 100644 --- a/src/render/materialsystem/qtechnique.cpp +++ b/src/render/materialsystem/qtechnique.cpp @@ -61,25 +61,62 @@ QTechniquePrivate::~QTechniquePrivate() } /*! - * \qmltype Technique - * \instantiates Qt3DRender::QTechnique - * \inqmlmodule Qt3D.Render - * \brief Encapsulates a Technique. + \qmltype Technique + \instantiates Qt3DRender::QTechnique + \inqmlmodule Qt3D.Render + \inherits Qt3DCore::QNode + \since 5.7 + \brief Encapsulates a Technique. + + A Technique specifies a set of RenderPass objects, FilterKey objects, Parameter objects + and a GraphicsApiFilter, which together define a rendering technique the given + graphics API can render. The filter keys are used by TechniqueFilter + to select specific techinques at specific parts of the FrameGraph. + If the same parameter is specified both in Technique and RenderPass, the one + in Technique overrides the one used in the RenderPass. + + \sa Qt3D.Render::Effect */ /*! - * \class Qt3DRender::QTechnique - * \inmodule Qt3DRender - * - * \inherits Node - * - * \brief Encapsulates a Technique. + \class Qt3DRender::QTechnique + \inmodule Qt3DRender + \inherits Node + \since 5.7 + \brief Encapsulates a Technique. + + A Qt3DRender::QTechnique specifies a set of Qt3DRender::QRenderPass objects, + Qt3DRender::QFilterKey objects, Qt3DRender::QParameter objects and + a Qt3DRender::QGraphicsApiFilter, which together define a rendering technique the given + graphics API can render. The filter keys are used by Qt3DRender::QTechniqueFilter + to select specific techinques at specific parts of the FrameGraph. + If the same parameter is specified both in QTechnique and QRenderPass, the one + in QTechnique overrides the one used in the QRenderPass. + + \sa Qt3DRender::QEffect */ /*! - \fn Qt3DRender::QTechnique::QTechnique(Qt3DCore::QNode *parent) - Constructs a new QTechnique with the specified \a parent. + \qmlproperty GraphicsApiFilter Qt3D.Render::Technique::graphicsApiFilter + Specifies the graphics API filter being used +*/ +/*! + \qmlproperty list Qt3D.Render::Technique::filterKeys + Specifies the list of filter keys enabling this technique +*/ +/*! + \qmlproperty list Qt3D.Render::Technique::renderPasses + Specifies the render passes used by the tehcnique +*/ +/*! + \qmlproperty list Qt3D.Render::Technique::parameters + Specifies the parameters used by the technique +*/ +/*! + \property Qt3DRender::QTechnique::graphicsApiFilter + Specifies the graphics API filter being used */ + QTechnique::QTechnique(QNode *parent) : QNode(*new QTechniquePrivate, parent) { @@ -112,7 +149,7 @@ void QTechniquePrivate::_q_graphicsApiFilterChanged() } /*! - * Add \a filterKey to the Qt3DRender::QTechnique local filter keys. + Add \a filterKey to the Qt3DRender::QTechnique local filter keys. */ void QTechnique::addFilterKey(QFilterKey *filterKey) { @@ -140,7 +177,7 @@ void QTechnique::addFilterKey(QFilterKey *filterKey) } /*! - * Removes \a filterKey from the Qt3DRender::QTechnique local filter keys. + Removes \a filterKey from the Qt3DRender::QTechnique local filter keys. */ void QTechnique::removeFilterKey(QFilterKey *filterKey) { @@ -157,8 +194,8 @@ void QTechnique::removeFilterKey(QFilterKey *filterKey) } /*! - * Returns the list of Qt3DCore::QFilterKey key objects making up the filter keys - * of the Qt3DRender::QTechnique. + Returns the list of Qt3DCore::QFilterKey key objects making up the filter keys + of the Qt3DRender::QTechnique. */ QVector QTechnique::filterKeys() const { @@ -167,7 +204,7 @@ QVector QTechnique::filterKeys() const } /*! - * Add \a parameter to the techniques parameters. + Add \a parameter to the technique's parameters. */ void QTechnique::addParameter(QParameter *parameter) { @@ -195,7 +232,7 @@ void QTechnique::addParameter(QParameter *parameter) } /*! - * Remove \a parameter from the techniques parameters. + Remove \a parameter from the technique's parameters. */ void QTechnique::removeParameter(QParameter *parameter) { @@ -212,7 +249,7 @@ void QTechnique::removeParameter(QParameter *parameter) } /*! - * Appends a \a pass to the technique. + Appends a \a pass to the technique. */ void QTechnique::addRenderPass(QRenderPass *pass) { @@ -240,7 +277,7 @@ void QTechnique::addRenderPass(QRenderPass *pass) } /*! - * Removes a \a pass from the technique. + Removes a \a pass from the technique. */ void QTechnique::removeRenderPass(QRenderPass *pass) { @@ -257,7 +294,7 @@ void QTechnique::removeRenderPass(QRenderPass *pass) } /*! - * Returns the list of render passes contained in the technique. + Returns the list of render passes contained in the technique. */ QVector QTechnique::renderPasses() const { @@ -266,7 +303,7 @@ QVector QTechnique::renderPasses() const } /*! - * Returns a vector of the techniques current parameters + Returns a vector of the techniques current parameters */ QVector QTechnique::parameters() const { @@ -274,15 +311,6 @@ QVector QTechnique::parameters() const return d->m_parameters; } -/*! - \qmlproperty QByteArray Qt3D.Render::Technique::graphicsApiFilter - Specifies the graphics API filter being used -*/ - -/*! - \property Qt3DRender::QTechnique::graphicsApiFilter - Specifies the graphics API filter being used - */ QGraphicsApiFilter *QTechnique::graphicsApiFilter() { Q_D(QTechnique); -- cgit v1.2.3 From 0c7e6a3904624e80e53c15c3ecffac8eb96cdfab Mon Sep 17 00:00:00 2001 From: Paul Lemire Date: Fri, 12 Aug 2016 09:04:06 +0200 Subject: ShaderData: refactoring Only store the original properties (does not store transformed values anymore as these can change on a per thread basis and lead to races in the ShaderData). Instead introduce a method to check if a property needs to be transformed and a method which given a viewMatrix returns the transformed value. This can then be used concurrently by each UniformBlockValueBuilder without introducing races. Also since building UBO from a ShaderData has been disabled since 5.7, remove all the nested ShaderData update logic. Unit tests updated. Change-Id: Id0e5956b9f7d93f8d019c3d8999268fc3ad68e79 Task-number: QTBUG-54818 Reviewed-by: Kevin Ottens --- src/render/backend/renderview.cpp | 9 +- src/render/jobs/renderviewjobutils.cpp | 17 +- src/render/jobs/renderviewjobutils_p.h | 5 +- src/render/materialsystem/shaderdata.cpp | 173 +++++++-------------- src/render/materialsystem/shaderdata_p.h | 24 +-- .../render/renderviewutils/tst_renderviewutils.cpp | 44 ++++++ 6 files changed, 132 insertions(+), 140 deletions(-) diff --git a/src/render/backend/renderview.cpp b/src/render/backend/renderview.cpp index 9226f8fac..64f8bacca 100644 --- a/src/render/backend/renderview.cpp +++ b/src/render/backend/renderview.cpp @@ -654,10 +654,8 @@ void RenderView::setDefaultUniformBlockShaderDataValue(ShaderParameterPack &unif UniformBlockValueBuilder *builder = m_localData.localData(); builder->activeUniformNamesToValue.clear(); - // updates transformed properties; - // Fix me: this will lead to races when having multiple cameras - shaderData->updateViewTransform(m_data.m_viewMatrix); - + // Set the view matrix to be used to transform "Transformed" properties in the ShaderData + builder->viewMatrix = m_data.m_viewMatrix; // Force to update the whole block builder->updatedPropertiesOnly = false; // Retrieve names and description of each active uniforms in the uniform block @@ -802,6 +800,9 @@ void RenderView::setShaderAndUniforms(RenderCommand *command, RenderPass *rPass, setUniformValue(command->m_parameterPack, LIGHT_COLOR_NAMES[lightIdx], QVector3D(1.0f, 1.0f, 1.0f)); setUniformValue(command->m_parameterPack, LIGHT_INTENSITY_NAMES[lightIdx], 0.5f); + // There is no risk in doing that even if multithreaded + // since we are sure that a shaderData is unique for a given light + // and won't ever be referenced as a Component either QMatrix4x4 *worldTransform = lightEntity->worldTransform(); if (worldTransform) shaderData->updateWorldTransform(*worldTransform); diff --git a/src/render/jobs/renderviewjobutils.cpp b/src/render/jobs/renderviewjobutils.cpp index f81615959..760e931dd 100644 --- a/src/render/jobs/renderviewjobutils.cpp +++ b/src/render/jobs/renderviewjobutils.cpp @@ -428,7 +428,7 @@ UniformBlockValueBuilder::~UniformBlockValueBuilder() { } -void UniformBlockValueBuilder::buildActiveUniformNameValueMapHelper(const QString &blockName, const QString &qmlPropertyName, const QVariant &value) +void UniformBlockValueBuilder::buildActiveUniformNameValueMapHelper(ShaderData *currentShaderData, const QString &blockName, const QString &qmlPropertyName, const QVariant &value) { // In the end, values are either scalar or a scalar array // Composed elements (structs, structs array) are simplified into simple scalars @@ -461,20 +461,29 @@ void UniformBlockValueBuilder::buildActiveUniformNameValueMapHelper(const QStrin QString varName = blockName + QLatin1Char('.') + qmlPropertyName; if (uniforms.contains(varName)) { qCDebug(Shaders) << "UBO scalar member " << varName << " set for update"; - activeUniformNamesToValue.insert(StringToInt::lookupId(varName), value); + + // If the property needs to be transformed, we transform it here as + // the shaderdata cannot hold transformed properties for multiple + // thread contexts at once + if (currentShaderData->isPropertyToBeTransformed(qmlPropertyName)) + activeUniformNamesToValue.insert(StringToInt::lookupId(varName), + currentShaderData->getTransformedProperty(qmlPropertyName, viewMatrix)); + else + activeUniformNamesToValue.insert(StringToInt::lookupId(varName), value); } } } void UniformBlockValueBuilder::buildActiveUniformNameValueMapStructHelper(ShaderData *rShaderData, const QString &blockName, const QString &qmlPropertyName) { - const QHash &properties = updatedPropertiesOnly ? rShaderData->updatedProperties() : rShaderData->properties(); + const QHash &properties = rShaderData->properties(); QHash::const_iterator it = properties.begin(); const QHash::const_iterator end = properties.end(); while (it != end) { const auto prefix = qmlPropertyName.isEmpty() ? QLatin1String("") : QLatin1String("."); - buildActiveUniformNameValueMapHelper(blockName + prefix + qmlPropertyName, + buildActiveUniformNameValueMapHelper(rShaderData, + blockName + prefix + qmlPropertyName, it.key(), it.value()); ++it; diff --git a/src/render/jobs/renderviewjobutils_p.h b/src/render/jobs/renderviewjobutils_p.h index 7f70690d7..fa133ef4c 100644 --- a/src/render/jobs/renderviewjobutils_p.h +++ b/src/render/jobs/renderviewjobutils_p.h @@ -55,6 +55,7 @@ #include #include #include +#include QT_BEGIN_NAMESPACE @@ -157,7 +158,8 @@ struct Q_AUTOTEST_EXPORT UniformBlockValueBuilder UniformBlockValueBuilder(); ~UniformBlockValueBuilder(); - void buildActiveUniformNameValueMapHelper(const QString &blockName, + void buildActiveUniformNameValueMapHelper(ShaderData *currentShaderData, + const QString &blockName, const QString &qmlPropertyName, const QVariant &value); void buildActiveUniformNameValueMapStructHelper(ShaderData *rShaderData, @@ -168,6 +170,7 @@ struct Q_AUTOTEST_EXPORT UniformBlockValueBuilder QHash uniforms; UniformBlockValueBuilderHash activeUniformNamesToValue; ShaderDataManager *shaderDataManager; + QMatrix4x4 viewMatrix; }; } // namespace Render diff --git a/src/render/materialsystem/shaderdata.cpp b/src/render/materialsystem/shaderdata.cpp index 1f68bed13..d6873e7dc 100644 --- a/src/render/materialsystem/shaderdata.cpp +++ b/src/render/materialsystem/shaderdata.cpp @@ -94,7 +94,6 @@ void ShaderData::initializeFromPeer(const QNodeCreatedChangeBasePtr &change) const QVariant &propertyValue = entry.second; const QString propertyName = QString::fromLatin1(entry.first); - m_properties.insert(propertyName, propertyValue); m_originalProperties.insert(propertyName, propertyValue); // We check if the property is a QNodeId or QVector so that we can @@ -108,14 +107,15 @@ void ShaderData::initializeFromPeer(const QNodeCreatedChangeBasePtr &change) } } - // We look for transformed properties - QHash::iterator it = m_properties.begin(); - const QHash::iterator end = m_properties.end(); + // We look for transformed properties once the complete hash of + // originalProperties is available + QHash::iterator it = m_originalProperties.begin(); + const QHash::iterator end = m_originalProperties.end(); while (it != end) { if (static_cast(it.value().type()) == QMetaType::QVector3D) { // if there is a matching QShaderData::TransformType propertyTransformed - QVariant value = m_properties.value(it.key() + QLatin1String("Transformed")); + QVariant value = m_originalProperties.value(it.key() + QLatin1String("Transformed")); // if that's the case, we apply a space transformation to the property if (value.isValid() && value.type() == QVariant::Int) m_transformedProperties.insert(it.key(), static_cast(value.toInt())); @@ -138,38 +138,39 @@ ShaderData *ShaderData::lookupResource(QNodeId id) // Call by cleanup job (single thread) void ShaderData::clearUpdatedProperties() { - m_updatedProperties.clear(); - const QHash::const_iterator end = m_nestedShaderDataProperties.end(); - QHash::const_iterator it = m_nestedShaderDataProperties.begin(); - - while (it != end) { - if (it.value().userType() == QMetaType::QVariantList) { - const auto values = it.value().value(); - for (const QVariant &v : values) { - ShaderData *nested = lookupResource(v.value()); - if (nested != nullptr) - nested->clearUpdatedProperties(); - } - } else { - ShaderData *nested = lookupResource(it.value().value()); - if (nested != nullptr) - nested->clearUpdatedProperties(); - } - ++it; - } + // DISABLED: Is only useful when building UBO from a ShaderData, which is disable since 5.7 + // const QHash::const_iterator end = m_nestedShaderDataProperties.end(); + // QHash::const_iterator it = m_nestedShaderDataProperties.begin(); + + // while (it != end) { + // if (it.value().userType() == QMetaType::QVariantList) { + // const auto values = it.value().value(); + // for (const QVariant &v : values) { + // ShaderData *nested = lookupResource(v.value()); + // if (nested != nullptr) + // nested->clearUpdatedProperties(); + // } + // } else { + // ShaderData *nested = lookupResource(it.value().value()); + // if (nested != nullptr) + // nested->clearUpdatedProperties(); + // } + // ++it; + // } } void ShaderData::cleanup(NodeManagers *managers) { - for (Qt3DCore::QNodeId id : qAsConst(m_updatedShaderData)) { - ShaderData *shaderData = ShaderData::lookupResource(managers, id); - if (shaderData) - shaderData->clearUpdatedProperties(); - } + Q_UNUSED(managers) + // DISABLED: Is only useful when building UBO from a ShaderData, which is disable since 5.7 + // for (Qt3DCore::QNodeId id : qAsConst(m_updatedShaderData)) { + // ShaderData *shaderData = ShaderData::lookupResource(managers, id); + // if (shaderData) + // shaderData->clearUpdatedProperties(); + // } m_updatedShaderData.clear(); } -// Called by renderview jobs (several concurrent threads) /*! \internal Lookup if the current ShaderData or a nested ShaderData has updated properties. @@ -179,94 +180,38 @@ void ShaderData::cleanup(NodeManagers *managers) \note This needs to be performed for every top level ShaderData every time it is used. As we don't know if the transformed properties use the same viewMatrix for all RenderViews. */ -bool ShaderData::updateViewTransform(const QMatrix4x4 &viewMatrix) -{ - // We can't perform this only once as we don't know if we would be call as the root or a - // nested ShaderData - QMutexLocker lock(&m_mutex); - // Update transformed properties - // We check the matrices and decide if the transform has changed since the previous call to needsUpdate - if (m_viewMatrix != viewMatrix) { - m_viewMatrix = viewMatrix; - const QHash::const_iterator transformedEnd = m_transformedProperties.end(); - QHash::const_iterator transformedIt = m_transformedProperties.begin(); - - while (transformedIt != transformedEnd) { - if (transformedIt.value() == ModelToEye) { - m_updatedProperties.insert(transformedIt.key(), m_viewMatrix * m_worldMatrix * m_originalProperties.value(transformedIt.key()).value()); - m_properties.insert(transformedIt.key(), m_viewMatrix * m_worldMatrix * m_originalProperties.value(transformedIt.key()).value()); - } - ++transformedIt; - } - } - const QHash::const_iterator end = m_nestedShaderDataProperties.end(); - QHash::const_iterator it = m_nestedShaderDataProperties.begin(); +bool ShaderData::isPropertyToBeTransformed(const QString &name) const +{ + return m_transformedProperties.contains(name); +} - while (it != end) { - const int userType = it.value().userType(); - - if (userType == QMetaType::QVariantList) { - QVariantList updatedNodes; - bool nestedNeedsUpdate = false; - const QVariantList values = variant_value(it.value()); - for (const QVariant &v : values) { - if (v.userType() != qNodeIdTypeId) - continue; - - const Qt3DCore::QNodeId nestedId = variant_value(v); - ShaderData *nested = lookupResource(nestedId); - if (nested != nullptr) { - // We need to add the nested nodes to the updated property list - // as we need to maintain order - // if node[0] doesn't need update but node[1] does, - // if we only have a single element, the renderer would update element [0] - nestedNeedsUpdate |= nested->updateViewTransform(viewMatrix); - updatedNodes << v; - } - } - // Of course we only add all the nodes if at least one of the nested nodes required and update - if (nestedNeedsUpdate && !updatedNodes.empty()) - m_updatedProperties.insert(it.key(), updatedNodes); - } else if (userType == qNodeIdTypeId) { - const Qt3DCore::QNodeId nestedId = variant_value(it.value()); - ShaderData *nested = lookupResource(nestedId); - if (nested != nullptr && nested->updateViewTransform(viewMatrix)) - m_updatedProperties.insert(it.key(), it.value()); +QVariant ShaderData::getTransformedProperty(const QString &name, const QMatrix4x4 &viewMatrix) +{ + // Note protecting m_worldMatrix at this point as we assume all world updates + // have been performed when reaching this point + auto it = m_transformedProperties.find(name); + if (it != m_transformedProperties.end()) { + const TransformType transformType = it.value(); + switch (transformType) { + case ModelToEye: + return QVariant::fromValue(viewMatrix * m_worldMatrix * m_originalProperties.value(name).value()); + case ModelToWorld: + return QVariant::fromValue(m_worldMatrix * m_originalProperties.value(it.key()).value()); + case ModelToWorldDirection: + return QVariant::fromValue((m_worldMatrix * QVector4D(m_originalProperties.value(it.key()).value(), 0.0f)).toVector3D()); } - ++it; } - return m_updatedProperties.size() > 0; + return QVariant(); } -bool ShaderData::updateWorldTransform(const QMatrix4x4 &worldMatrix) +// Called by FramePreparationJob or by RenderView when dealing with lights +void ShaderData::updateWorldTransform(const QMatrix4x4 &worldMatrix) { - // TODO: Factor this out into a job that populates data in the corresponding - // renderview or other intermediate data structure. See QTBUG-54818 QMutexLocker lock(&m_mutex); if (m_worldMatrix != worldMatrix) { m_worldMatrix = worldMatrix; - - const QHash::const_iterator transformedEnd = m_transformedProperties.end(); - QHash::const_iterator transformedIt = m_transformedProperties.begin(); - - while (transformedIt != transformedEnd) { - if (transformedIt.value() == ModelToEye) { - m_updatedProperties.insert(transformedIt.key(), m_viewMatrix * m_worldMatrix * m_originalProperties.value(transformedIt.key()).value()); - m_properties.insert(transformedIt.key(), m_viewMatrix * m_worldMatrix * m_originalProperties.value(transformedIt.key()).value()); - } else if (transformedIt.value() == ModelToWorldDirection) { - auto localDirection = QVector4D(m_originalProperties.value(transformedIt.key()).value(), 0.0f); - auto worldDirection = (m_worldMatrix * localDirection).toVector3D(); - m_updatedProperties.insert(transformedIt.key(), worldDirection); - m_properties.insert(transformedIt.key(), worldDirection); - } else { - m_updatedProperties.insert(transformedIt.key(), m_worldMatrix * m_originalProperties.value(transformedIt.key()).value()); - m_properties.insert(transformedIt.key(), m_worldMatrix * m_originalProperties.value(transformedIt.key()).value()); - } - ++transformedIt; - } } - return m_updatedProperties.size() > 0; } // This will add the ShaderData to be cleared from updates at the end of the frame @@ -297,19 +242,7 @@ void ShaderData::sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e) // Note we aren't notified about nested QShaderData in this call // only scalar / vec properties - if (m_properties.contains(propertyName)) { - // If this is a Transformed property, we need to multiply against the correct - // matrices - m_originalProperties.insert(propertyName, propertyValue); - if (m_transformedProperties.contains(propertyName)) { - if (m_transformedProperties[propertyName] == ModelToEye) - propertyValue = m_viewMatrix * m_worldMatrix * propertyValue.value(); - else - propertyValue = m_worldMatrix * propertyValue.value(); - } - m_properties.insert(propertyName, propertyValue); - m_updatedProperties.insert(propertyName, propertyValue); - } + m_originalProperties.insert(propertyName, propertyValue); BackendNode::markDirty(AbstractRenderer::AllDirty); } diff --git a/src/render/materialsystem/shaderdata_p.h b/src/render/materialsystem/shaderdata_p.h index 46dd26faf..90568eaea 100644 --- a/src/render/materialsystem/shaderdata_p.h +++ b/src/render/materialsystem/shaderdata_p.h @@ -79,15 +79,16 @@ public: ShaderData(); ~ShaderData(); - QHash properties() const { return m_properties; } - QHash updatedProperties() const { return m_updatedProperties; } + QHash properties() const { return m_originalProperties; } // Called by FramePreparationJob - bool updateWorldTransform(const QMatrix4x4 &worldMatrix); + void updateWorldTransform(const QMatrix4x4 &worldMatrix); // Call by RenderViewJob void markDirty(); - bool updateViewTransform(const QMatrix4x4 &viewMatrix); + + bool isPropertyToBeTransformed(const QString &name) const; + QVariant getTransformedProperty(const QString &name, const QMatrix4x4 &viewMatrix); // Called by FrameCleanupJob static void cleanup(NodeManagers *managers); @@ -98,17 +99,18 @@ protected: void initializeFromPeer(const Qt3DCore::QNodeCreatedChangeBasePtr &change) Q_DECL_OVERRIDE; void sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e) Q_DECL_OVERRIDE; + PropertyReaderInterfacePtr m_propertyReader; + // 1 to 1 match with frontend properties, modified only by sceneChangeEvent QHash m_originalProperties; - // 1 to 1 match with frontend properties apart from Transformed - // properties which contain the matrices product - QHash m_properties; - // only updated properties, Transformed properties have the same - // value as in m_properties - QHash m_updatedProperties; - PropertyReaderInterfacePtr m_propertyReader; + + // Contains properties thar are of type ShaderData QHash m_nestedShaderDataProperties; + + // Contains property that are defined like: postionTransformed: ModelToEye QHash m_transformedProperties; + + QMutex m_mutex; static QVector m_updatedShaderData; QMatrix4x4 m_worldMatrix; diff --git a/tests/auto/render/renderviewutils/tst_renderviewutils.cpp b/tests/auto/render/renderviewutils/tst_renderviewutils.cpp index df68a61d4..b3ef1ba74 100644 --- a/tests/auto/render/renderviewutils/tst_renderviewutils.cpp +++ b/tests/auto/render/renderviewutils/tst_renderviewutils.cpp @@ -47,6 +47,7 @@ private Q_SLOTS: void topLevelStructValue_data(); void topLevelStructValue(); void topLevelDynamicProperties(); + void transformedProperties(); void shouldNotifyDynamicPropertyChanges(); private: @@ -496,6 +497,49 @@ void tst_RenderViewUtils::topLevelDynamicProperties() shaderData->property("array")); } +void tst_RenderViewUtils::transformedProperties() +{ + // GIVEN + QScopedPointer shaderData(new Qt3DRender::QShaderData()); + QScopedPointer manager(new Qt3DRender::Render::ShaderDataManager()); + + // WHEN + const QVector3D position = QVector3D(15.0f, -5.0f, 10.0f); + QMatrix4x4 worldMatrix; + QMatrix4x4 viewMatrix; + + worldMatrix.translate(-3.0f, 2.0f, 7.5f); + viewMatrix.translate(9.0f, 6.0f, 12.0f); + + shaderData->setProperty("position0", position); + shaderData->setProperty("position1", position); + shaderData->setProperty("position2", position); + shaderData->setProperty("position3", position); + shaderData->setProperty("position1Transformed", Qt3DRender::Render::ShaderData::ModelToEye); + shaderData->setProperty("position2Transformed", Qt3DRender::Render::ShaderData::ModelToWorld); + shaderData->setProperty("position3Transformed", Qt3DRender::Render::ShaderData::ModelToWorldDirection); + initBackendShaderData(shaderData.data(), manager.data()); + + // THEN + Qt3DRender::Render::ShaderData *backendShaderData = manager->lookupResource(shaderData->id()); + QVERIFY(backendShaderData != nullptr); + QVERIFY(!backendShaderData->isPropertyToBeTransformed(QStringLiteral("position0"))); + QVERIFY(backendShaderData->isPropertyToBeTransformed(QStringLiteral("position1"))); + QVERIFY(backendShaderData->isPropertyToBeTransformed(QStringLiteral("position2"))); + QVERIFY(backendShaderData->isPropertyToBeTransformed(QStringLiteral("position3"))); + + // WHEN + backendShaderData->updateWorldTransform(worldMatrix); + const QVector3D position1Value = backendShaderData->getTransformedProperty(QStringLiteral("position1"), viewMatrix).value(); + const QVector3D position2Value = backendShaderData->getTransformedProperty(QStringLiteral("position2"), viewMatrix).value(); + const QVector3D position3Value = backendShaderData->getTransformedProperty(QStringLiteral("position3"), viewMatrix).value(); + + // THEN + QCOMPARE(position1Value, viewMatrix * worldMatrix * position); + QCOMPARE(position2Value, worldMatrix * position); + QCOMPARE(position3Value, (worldMatrix * QVector4D(position, 0.0f)).toVector3D()); +} + void tst_RenderViewUtils::shouldNotifyDynamicPropertyChanges() { // GIVEN -- cgit v1.2.3 From 88ca1827cf6532b0e8d4fbacb4bc87a515c2cff4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antti=20M=C3=A4=C3=A4tt=C3=A4?= Date: Mon, 5 Sep 2016 14:31:17 +0300 Subject: Update QRenderPass docs Change-Id: I62bcba620c3d222fc6d26151b21c0de1e196fc8d Reviewed-by: Paul Lemire --- src/render/materialsystem/qrenderpass.cpp | 112 +++++++++++++++++++----------- src/render/materialsystem/qrenderpass.h | 4 +- 2 files changed, 75 insertions(+), 41 deletions(-) diff --git a/src/render/materialsystem/qrenderpass.cpp b/src/render/materialsystem/qrenderpass.cpp index b10660730..dd6363816 100644 --- a/src/render/materialsystem/qrenderpass.cpp +++ b/src/render/materialsystem/qrenderpass.cpp @@ -60,19 +60,65 @@ QRenderPassPrivate::QRenderPassPrivate() { } /*! - * \qmltype RenderPass - * \instantiates Qt3DRender::QRenderPass - * \inqmlmodule Qt3D.Render - * \brief Encapsulates a Render Pass. + \qmltype RenderPass + \instantiates Qt3DRender::QRenderPass + \inqmlmodule Qt3D.Render + \inherits Node + \since 5.7 + \brief Encapsulates a Render Pass. + + A RenderPass specifies a single rendering pass - an instance of shader program + execution - used by Technique. A Render pass consists of a ShaderProgram and + a list of FilterKey objects, a list of RenderState objects and a list + of \l Parameter objects. + + RenderPass executes the ShaderProgram using the given render states and parameters + when its filter keys match the filter keys in RenderPassFilter or when no filter + keys are specified and no RenderPassFilter is present in the FrameGraph. */ /*! - * \class Qt3DRender::QRenderPass - * \inmodule Qt3DRender - * - * \inherits Node - * - * \brief Encapsulates a Render Pass. + \class Qt3DRender::QRenderPass + \inmodule Qt3DRender + \since 5.7 + \brief Encapsulates a Render Pass. + + A Qt3DRender::QRenderPass specifies a single rendering pass - an instance of shader + program execution - used by Qt3DRender::QTechnique. Render pass consists + of a Qt3DRender::QShaderProgram and a list of Qt3DRender::QFilterKey objects, + a list of Qt3DRender::QRenderState objects and a list of Qt3DRender::QParameter objects. + + QRenderPass executes the QShaderProgram using the given render states and parameters + when its filter keys match the filter keys in Qt3DRender::QRenderPassFilter or + when no filter keys are specified and no QRenderPassFilter is present + in the FrameGraph. + */ +/*! + \typedef ParameterList + \relates Qt3DRender::QRenderPass + + A list of Qt3DRender::QParameter parameters. +*/ +/*! + \qmlproperty ShaderProgram Qt3D.Render::RenderPass::shaderProgram + Holds the shader program to be used for this render pass. +*/ +/*! + \qmlproperty list Qt3D.Render::RenderPass::filterKeys + Holds the filter keys enabling the use of this render pass. +*/ +/*! + \qmlproperty list Qt3D.Render::RenderPass::renderStates + Holds the render states used by the render pass. +*/ +/*! + \qmlproperty list Qt3D.Render::RenderPass::parameters + Holds the shader parameter values used by the render pass. +*/ + +/*! + \property Qt3DRender::QRenderPass::shaderProgram + Specifies the shader program to be used for this render pass. */ /*! @@ -95,18 +141,6 @@ QRenderPass::QRenderPass(QRenderPassPrivate &dd, QNode *parent) { } -/*! - \qmlproperty ShaderProgram Qt3D.Render::RenderPass::shaderProgram - Specifies the shader program to be used for this render pass -*/ - -/*! - \property Qt3DRender::QRenderPass::shaderProgram - Specifies the shader program to be used for this render pass - */ -/*! - * Sets the pass' \a shaderProgram. - */ void QRenderPass::setShaderProgram(QShaderProgram *shaderProgram) { Q_D(QRenderPass); @@ -145,7 +179,7 @@ QShaderProgram *QRenderPass::shaderProgram() const } /*! - * Adds \a filterKey from to the Qt3DRender::QRenderPass local filter keys. + Adds \a filterKey to the Qt3DRender::QRenderPass local filter keys. */ void QRenderPass::addFilterKey(QFilterKey *filterKey) { @@ -173,7 +207,7 @@ void QRenderPass::addFilterKey(QFilterKey *filterKey) } /*! - * Removes \a filterKey from the Qt3DRender::QRenderPass local filter keys. + Removes \a filterKey from the Qt3DRender::QRenderPass local filter keys. */ void QRenderPass::removeFilterKey(QFilterKey *filterKey) { @@ -190,8 +224,8 @@ void QRenderPass::removeFilterKey(QFilterKey *filterKey) } /*! - * Returns the list of Qt3DCore::QFilterKey key objects making up the filter keys - * of the Qt3DRender::QRenderPass. + Returns the list of Qt3DRender::QFilterKey key objects making up the filter keys + of the Qt3DRender::QRenderPass. */ QVector QRenderPass::filterKeys() const { @@ -200,12 +234,12 @@ QVector QRenderPass::filterKeys() const } /*! - * Adds a Qt3DCore::QRenderState \a state to the rendering pass. That implies that - * when the pass is executed at render time, the globally set render state will - * be modifed by the states defined locally by the Qt3DRender::QRenderPass. - * - * \note not defining any Qt3DCore::QRenderState in a pass will result in the pass using - * the globally set render state for a given FrameGraph branch execution path. + Adds a render \a state to the rendering pass. That implies that + when the pass is executed at render time, the globally set render state will + be modifed by the states defined locally by the Qt3DRender::QRenderPass. + + \note not defining any Qt3DRender::QRenderState in a pass will result in the pass using + the globally set render state for a given FrameGraph branch execution path. */ void QRenderPass::addRenderState(QRenderState *state) { @@ -229,7 +263,7 @@ void QRenderPass::addRenderState(QRenderState *state) } /*! - * Removes \a state from the Qt3DRender::QRenderPass local render state. + Removes \a state from the Qt3DRender::QRenderPass local render state. */ void QRenderPass::removeRenderState(QRenderState *state) { @@ -246,8 +280,8 @@ void QRenderPass::removeRenderState(QRenderState *state) } /*! - * Returns the list of Qt3DCore::QRenderState state objects making up the render - * state of the Qt3DRender::QRenderPass. + Returns the list of Qt3DRender::QRenderState state objects making up the render + state of the Qt3DRender::QRenderPass. */ QVector QRenderPass::renderStates() const { @@ -256,7 +290,7 @@ QVector QRenderPass::renderStates() const } /*! - * Add \a parameter to the render pass' parameters. + Add \a parameter to the render pass' parameters. */ void QRenderPass::addParameter(QParameter *parameter) { @@ -284,7 +318,7 @@ void QRenderPass::addParameter(QParameter *parameter) } /*! - * Remove \a parameter from the render pass' parameters. + Remove \a parameter from the render pass' parameters. */ void QRenderPass::removeParameter(QParameter *parameter) { @@ -301,9 +335,9 @@ void QRenderPass::removeParameter(QParameter *parameter) } /*! - * Returns a vector of the render pass' current parameters + Returns a vector of the render pass' current parameters */ -QVector QRenderPass::parameters() const +ParameterList QRenderPass::parameters() const { Q_D(const QRenderPass); return d->m_parameters; diff --git a/src/render/materialsystem/qrenderpass.h b/src/render/materialsystem/qrenderpass.h index e2eb96a9a..9c608d0c4 100644 --- a/src/render/materialsystem/qrenderpass.h +++ b/src/render/materialsystem/qrenderpass.h @@ -70,8 +70,8 @@ public: QShaderProgram *shaderProgram() const; - void addFilterKey(QFilterKey*filterKey); - void removeFilterKey(QFilterKey*filterKey); + void addFilterKey(QFilterKey *filterKey); + void removeFilterKey(QFilterKey *filterKey); QVector filterKeys() const; void addRenderState(QRenderState *state); -- cgit v1.2.3 From 447bc4a541010bb6f37bdfc6a3c1bbf700b93d3b Mon Sep 17 00:00:00 2001 From: Paul Lemire Date: Fri, 26 Aug 2016 09:31:40 +0200 Subject: LoadSceneJob: set the status after the subtree MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I826e599bf188162eaa4b2bed1ce34741192d05b9 Reviewed-by: Tomi Korpipää Reviewed-by: Sean Harmer Reviewed-by: Kevin Ottens --- src/render/jobs/loadscenejob.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/render/jobs/loadscenejob.cpp b/src/render/jobs/loadscenejob.cpp index 79ac91d9a..701942976 100644 --- a/src/render/jobs/loadscenejob.cpp +++ b/src/render/jobs/loadscenejob.cpp @@ -90,9 +90,11 @@ void LoadSceneJob::run() // Reset status scene->setStatus(QSceneLoader::None); + QSceneLoader::Status finalStatus = QSceneLoader::None; // Perform the loading only if the source wasn't explicitly set to empty if (!m_source.isEmpty()) { + finalStatus = QSceneLoader::Error; for (QSceneIOHandler *sceneIOHandler : qAsConst(m_sceneIOHandlers)) { if (!sceneIOHandler->isFileTypeSupported(m_source)) continue; @@ -102,15 +104,11 @@ void LoadSceneJob::run() // File type is supported, try to load it sceneIOHandler->setSource(m_source); - Qt3DCore::QEntity *sub = sceneIOHandler->scene(); - if (sub) { - sceneSubTree = sub; + sceneSubTree = sceneIOHandler->scene(); + if (sceneSubTree != nullptr) { // Successfully built a subtree - scene->setStatus(QSceneLoader::Ready); + finalStatus = QSceneLoader::Ready; break; - } else { - // Tree wasn't build so something went wrong obviously - scene->setStatus(QSceneLoader::Error); } } } @@ -120,6 +118,10 @@ void LoadSceneJob::run() // Set clone of sceneTree in sceneComponent. This will move the sceneSubTree // to the QCoreApplication thread which is where the frontend object tree lives. scene->setSceneSubtree(sceneSubTree); + + // Note: the status is set after the subtree so that bindinds depending on the status + // in the frontend will be consistent + scene->setStatus(finalStatus); } } // namespace Render -- cgit v1.2.3 From c8531f512eda3074aa66d8a5c7f9525b3be7f75d Mon Sep 17 00:00:00 2001 From: Paul Lemire Date: Fri, 26 Aug 2016 10:25:01 +0200 Subject: Add unit tests for LoadSceneJob Change-Id: I6a570f16a303277b8305b36bef805991680ae1ea Reviewed-by: Sean Harmer --- tests/auto/render/loadscenejob/loadscenejob.pro | 12 + .../auto/render/loadscenejob/tst_loadscenejob.cpp | 287 +++++++++++++++++++++ tests/auto/render/render.pro | 3 +- 3 files changed, 301 insertions(+), 1 deletion(-) create mode 100644 tests/auto/render/loadscenejob/loadscenejob.pro create mode 100644 tests/auto/render/loadscenejob/tst_loadscenejob.cpp diff --git a/tests/auto/render/loadscenejob/loadscenejob.pro b/tests/auto/render/loadscenejob/loadscenejob.pro new file mode 100644 index 000000000..3901c3545 --- /dev/null +++ b/tests/auto/render/loadscenejob/loadscenejob.pro @@ -0,0 +1,12 @@ +TEMPLATE = app + +TARGET = tst_loadscenejob + +QT += 3dcore 3dcore-private 3drender 3drender-private testlib + +CONFIG += testcase + +SOURCES += tst_loadscenejob.cpp + +include(../../core/common/common.pri) +include(../commons/commons.pri) diff --git a/tests/auto/render/loadscenejob/tst_loadscenejob.cpp b/tests/auto/render/loadscenejob/tst_loadscenejob.cpp new file mode 100644 index 000000000..3428ecbea --- /dev/null +++ b/tests/auto/render/loadscenejob/tst_loadscenejob.cpp @@ -0,0 +1,287 @@ +/**************************************************************************** +** +** Copyright (C) 2016 Paul Lemire +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt3D module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "testpostmanarbiter.h" + +class TestIOSceneHandler : public Qt3DRender::QSceneIOHandler +{ +public: + explicit TestIOSceneHandler(bool supportsFormat, bool shouldFail) + : m_supportsFormat(supportsFormat) + , m_shouldFail(shouldFail) + {} + + void setSource(const QUrl &source) Q_DECL_OVERRIDE + { + m_source = source; + } + + bool isFileTypeSupported(const QUrl &) const Q_DECL_OVERRIDE + { + return m_supportsFormat; + } + + Qt3DCore::QEntity *scene(const QString &) Q_DECL_OVERRIDE + { + return m_shouldFail ? nullptr : new Qt3DCore::QEntity(); + } + + Qt3DCore::QEntity *node(const QString &) Q_DECL_OVERRIDE + { + return m_shouldFail ? nullptr : new Qt3DCore::QEntity(); + } + + QUrl source() const + { + return m_source; + } + +private: + QUrl m_source; + bool m_supportsFormat; + bool m_shouldFail; +}; + +class tst_LoadSceneJob : public QObject +{ + Q_OBJECT + +private Q_SLOTS: + + void checkInitialState() + { + // GIVEN + QUrl url; + Qt3DCore::QNodeId nodeId; + Qt3DRender::Render::LoadSceneJob backendLoadSceneJob(url, nodeId); + + // THEN + QCOMPARE(backendLoadSceneJob.source(), url); + QCOMPARE(backendLoadSceneJob.sceneComponentId(), nodeId); + QVERIFY(backendLoadSceneJob.nodeManagers() == nullptr); + QCOMPARE(backendLoadSceneJob.sceneIOHandlers().size(), 0); + } + + void checkInitialize() + { + // GIVEN + const QUrl url(QStringLiteral("URL")); + const Qt3DCore::QNodeId sceneId = Qt3DCore::QNodeId::createId(); + Qt3DRender::Render::NodeManagers nodeManagers; + TestIOSceneHandler fakeHandler(true, true); + + // WHEN + Qt3DRender::Render::LoadSceneJob backendLoadSceneJob(url, sceneId); + backendLoadSceneJob.setNodeManagers(&nodeManagers); + backendLoadSceneJob.setSceneIOHandlers(QList() << &fakeHandler); + + // THEN + QCOMPARE(backendLoadSceneJob.source(), url); + QCOMPARE(backendLoadSceneJob.sceneComponentId(), sceneId); + QVERIFY(backendLoadSceneJob.nodeManagers() == &nodeManagers); + QCOMPARE(backendLoadSceneJob.sceneIOHandlers().size(), 1); + QCOMPARE(backendLoadSceneJob.sceneIOHandlers().first(), &fakeHandler); + } + + void checkRunValidSourceSupportedFormat() + { + // GIVEN + const QUrl url(QStringLiteral("URL")); + TestArbiter arbiter; + Qt3DRender::Render::NodeManagers nodeManagers; + TestIOSceneHandler fakeHandler(true, false); + Qt3DCore::QNodeId sceneId = Qt3DCore::QNodeId::createId(); + Qt3DRender::Render::Scene *scene = nodeManagers.sceneManager()->getOrCreateResource(sceneId); + + // THEN + QVERIFY(scene != nullptr); + Qt3DCore::QBackendNodePrivate::get(scene)->setArbiter(&arbiter); + + // WHEN + Qt3DRender::Render::LoadSceneJob loadSceneJob(url, sceneId); + loadSceneJob.setNodeManagers(&nodeManagers); + loadSceneJob.setSceneIOHandlers(QList() << &fakeHandler); + loadSceneJob.run(); + + // THEN + QCOMPARE(arbiter.events.count(), 4); + auto change = arbiter.events.at(0).staticCast(); + QCOMPARE(change->subjectId(), scene->peerId()); + QCOMPARE(change->propertyName(), "status"); + QCOMPARE(change->value().value(), Qt3DRender::QSceneLoader::None); + + change = arbiter.events.at(1).staticCast(); + QCOMPARE(change->subjectId(), scene->peerId()); + QCOMPARE(change->propertyName(), "status"); + QCOMPARE(change->value().value(), Qt3DRender::QSceneLoader::Loading); + + change = arbiter.events.at(2).staticCast(); + QCOMPARE(change->subjectId(), scene->peerId()); + QCOMPARE(change->propertyName(), "scene"); + QVERIFY(change->value().value() != nullptr); + delete change->value().value(); + + change = arbiter.events.at(3).staticCast(); + QCOMPARE(change->subjectId(), scene->peerId()); + QCOMPARE(change->propertyName(), "status"); + QCOMPARE(change->value().value(), Qt3DRender::QSceneLoader::Ready); + } + + void checkEmptySource() + { + // GIVEN + QUrl url; + TestArbiter arbiter; + Qt3DRender::Render::NodeManagers nodeManagers; + TestIOSceneHandler fakeHandler(true, false); + Qt3DCore::QNodeId sceneId = Qt3DCore::QNodeId::createId(); + Qt3DRender::Render::Scene *scene = nodeManagers.sceneManager()->getOrCreateResource(sceneId); + + // THEN + QVERIFY(scene != nullptr); + Qt3DCore::QBackendNodePrivate::get(scene)->setArbiter(&arbiter); + + // WHEN + Qt3DRender::Render::LoadSceneJob loadSceneJob(url, sceneId); + loadSceneJob.setNodeManagers(&nodeManagers); + loadSceneJob.setSceneIOHandlers(QList() << &fakeHandler); + loadSceneJob.run(); + + // THEN + QCOMPARE(arbiter.events.count(), 3); + auto change = arbiter.events.at(0).staticCast(); + QCOMPARE(change->subjectId(), scene->peerId()); + QCOMPARE(change->propertyName(), "status"); + QCOMPARE(change->value().value(), Qt3DRender::QSceneLoader::None); + + change = arbiter.events.at(1).staticCast(); + QCOMPARE(change->subjectId(), scene->peerId()); + QCOMPARE(change->propertyName(), "scene"); + QVERIFY(change->value().value() == nullptr); + + change = arbiter.events.at(2).staticCast(); + QCOMPARE(change->subjectId(), scene->peerId()); + QCOMPARE(change->propertyName(), "status"); + QCOMPARE(change->value().value(), Qt3DRender::QSceneLoader::None); + } + + void checkRunValidSourceUnsupportedFormat() + { + // GIVEN + const QUrl url(QStringLiteral("URL")); + TestArbiter arbiter; + Qt3DRender::Render::NodeManagers nodeManagers; + TestIOSceneHandler fakeHandler(false, false); + Qt3DCore::QNodeId sceneId = Qt3DCore::QNodeId::createId(); + Qt3DRender::Render::Scene *scene = nodeManagers.sceneManager()->getOrCreateResource(sceneId); + + // THEN + QVERIFY(scene != nullptr); + Qt3DCore::QBackendNodePrivate::get(scene)->setArbiter(&arbiter); + + // WHEN + Qt3DRender::Render::LoadSceneJob loadSceneJob(url, sceneId); + loadSceneJob.setNodeManagers(&nodeManagers); + loadSceneJob.setSceneIOHandlers(QList() << &fakeHandler); + loadSceneJob.run(); + + // THEN + QCOMPARE(arbiter.events.count(), 3); + auto change = arbiter.events.at(0).staticCast(); + QCOMPARE(change->subjectId(), scene->peerId()); + QCOMPARE(change->propertyName(), "status"); + QCOMPARE(change->value().value(), Qt3DRender::QSceneLoader::None); + + change = arbiter.events.at(1).staticCast(); + QCOMPARE(change->subjectId(), scene->peerId()); + QCOMPARE(change->propertyName(), "scene"); + QVERIFY(change->value().value() == nullptr); + + change = arbiter.events.at(2).staticCast(); + QCOMPARE(change->subjectId(), scene->peerId()); + QCOMPARE(change->propertyName(), "status"); + QCOMPARE(change->value().value(), Qt3DRender::QSceneLoader::Error); + } + + void checkRunErrorAtLoading() + { + // GIVEN + const QUrl url(QStringLiteral("URL")); + TestArbiter arbiter; + Qt3DRender::Render::NodeManagers nodeManagers; + TestIOSceneHandler fakeHandler(true, true); + Qt3DCore::QNodeId sceneId = Qt3DCore::QNodeId::createId(); + Qt3DRender::Render::Scene *scene = nodeManagers.sceneManager()->getOrCreateResource(sceneId); + + // THEN + QVERIFY(scene != nullptr); + Qt3DCore::QBackendNodePrivate::get(scene)->setArbiter(&arbiter); + + // WHEN + Qt3DRender::Render::LoadSceneJob loadSceneJob(url, sceneId); + loadSceneJob.setNodeManagers(&nodeManagers); + loadSceneJob.setSceneIOHandlers(QList() << &fakeHandler); + loadSceneJob.run(); + + // THEN + QCOMPARE(arbiter.events.count(), 4); + auto change = arbiter.events.at(0).staticCast(); + QCOMPARE(change->subjectId(), scene->peerId()); + QCOMPARE(change->propertyName(), "status"); + QCOMPARE(change->value().value(), Qt3DRender::QSceneLoader::None); + + change = arbiter.events.at(1).staticCast(); + QCOMPARE(change->subjectId(), scene->peerId()); + QCOMPARE(change->propertyName(), "status"); + QCOMPARE(change->value().value(), Qt3DRender::QSceneLoader::Loading); + + change = arbiter.events.at(2).staticCast(); + QCOMPARE(change->subjectId(), scene->peerId()); + QCOMPARE(change->propertyName(), "scene"); + QVERIFY(change->value().value() == nullptr); + delete change->value().value(); + + change = arbiter.events.at(3).staticCast(); + QCOMPARE(change->subjectId(), scene->peerId()); + QCOMPARE(change->propertyName(), "status"); + QCOMPARE(change->value().value(), Qt3DRender::QSceneLoader::Error); + } +}; + +QTEST_MAIN(tst_LoadSceneJob) + +#include "tst_loadscenejob.moc" diff --git a/tests/auto/render/render.pro b/tests/auto/render/render.pro index d86e73c96..9c91e0c6e 100644 --- a/tests/auto/render/render.pro +++ b/tests/auto/render/render.pro @@ -56,5 +56,6 @@ contains(QT_CONFIG, private_tests) { qsceneloader \ qrendertargetoutput \ qcameralens \ - qcomputecommand + qcomputecommand \ + loadscenejob } -- cgit v1.2.3 From 73a386d4f62dcf83576d8f3e8b7ee7bb688b661d Mon Sep 17 00:00:00 2001 From: Paul Lemire Date: Mon, 5 Sep 2016 09:03:05 +0200 Subject: ShaderData: add getter to retrieve transform type of properties Replaces isPropertyToBeTransformed by propertyTransformType which returns the TransformType (NoTransform) if the property isn't transformed. Change-Id: Ib7d91bdcfe18409e6ad6d6f5bc119c46dd7fb143 Reviewed-by: Sean Harmer --- src/render/jobs/renderviewjobutils.cpp | 2 +- src/render/materialsystem/shaderdata.cpp | 32 ++++++++++++---------- src/render/materialsystem/shaderdata_p.h | 3 +- .../render/renderviewutils/tst_renderviewutils.cpp | 10 ++++--- 4 files changed, 26 insertions(+), 21 deletions(-) diff --git a/src/render/jobs/renderviewjobutils.cpp b/src/render/jobs/renderviewjobutils.cpp index 760e931dd..8ffd5ea10 100644 --- a/src/render/jobs/renderviewjobutils.cpp +++ b/src/render/jobs/renderviewjobutils.cpp @@ -465,7 +465,7 @@ void UniformBlockValueBuilder::buildActiveUniformNameValueMapHelper(ShaderData * // If the property needs to be transformed, we transform it here as // the shaderdata cannot hold transformed properties for multiple // thread contexts at once - if (currentShaderData->isPropertyToBeTransformed(qmlPropertyName)) + if (currentShaderData->propertyTransformType(qmlPropertyName) != ShaderData::NoTransform) activeUniformNamesToValue.insert(StringToInt::lookupId(varName), currentShaderData->getTransformedProperty(qmlPropertyName, viewMatrix)); else diff --git a/src/render/materialsystem/shaderdata.cpp b/src/render/materialsystem/shaderdata.cpp index d6873e7dc..e7c8a1c37 100644 --- a/src/render/materialsystem/shaderdata.cpp +++ b/src/render/materialsystem/shaderdata.cpp @@ -171,21 +171,6 @@ void ShaderData::cleanup(NodeManagers *managers) m_updatedShaderData.clear(); } -/*! - \internal - Lookup if the current ShaderData or a nested ShaderData has updated properties. - UpdateProperties contains either the value of the propertie of a QNodeId if it's another ShaderData. - Transformed properties are updated for all of ShaderData that have ones at the point. - - \note This needs to be performed for every top level ShaderData every time it is used. - As we don't know if the transformed properties use the same viewMatrix for all RenderViews. - */ - -bool ShaderData::isPropertyToBeTransformed(const QString &name) const -{ - return m_transformedProperties.contains(name); -} - QVariant ShaderData::getTransformedProperty(const QString &name, const QMatrix4x4 &viewMatrix) { // Note protecting m_worldMatrix at this point as we assume all world updates @@ -200,6 +185,8 @@ QVariant ShaderData::getTransformedProperty(const QString &name, const QMatrix4x return QVariant::fromValue(m_worldMatrix * m_originalProperties.value(it.key()).value()); case ModelToWorldDirection: return QVariant::fromValue((m_worldMatrix * QVector4D(m_originalProperties.value(it.key()).value(), 0.0f)).toVector3D()); + case NoTransform: + break; } } return QVariant(); @@ -224,6 +211,21 @@ void ShaderData::markDirty() ShaderData::m_updatedShaderData.append(peerId()); } +/*! + \internal + Lookup if the current ShaderData or a nested ShaderData has updated properties. + UpdateProperties contains either the value of the propertie of a QNodeId if it's another ShaderData. + Transformed properties are updated for all of ShaderData that have ones at the point. + + \note This needs to be performed for every top level ShaderData every time it is used. + As we don't know if the transformed properties use the same viewMatrix for all RenderViews. + */ + +ShaderData::TransformType ShaderData::propertyTransformType(const QString &name) const +{ + return m_transformedProperties.value(name, TransformType::NoTransform); +} + void ShaderData::sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e) { if (!m_propertyReader.isNull() && e->type() == PropertyUpdated) { diff --git a/src/render/materialsystem/shaderdata_p.h b/src/render/materialsystem/shaderdata_p.h index 90568eaea..6ce0c734c 100644 --- a/src/render/materialsystem/shaderdata_p.h +++ b/src/render/materialsystem/shaderdata_p.h @@ -71,6 +71,7 @@ class Q_AUTOTEST_EXPORT ShaderData : public BackendNode { public: enum TransformType { + NoTransform = -1, ModelToEye = 0, ModelToWorld, ModelToWorldDirection @@ -87,7 +88,7 @@ public: // Call by RenderViewJob void markDirty(); - bool isPropertyToBeTransformed(const QString &name) const; + TransformType propertyTransformType(const QString &name) const; QVariant getTransformedProperty(const QString &name, const QMatrix4x4 &viewMatrix); // Called by FrameCleanupJob diff --git a/tests/auto/render/renderviewutils/tst_renderviewutils.cpp b/tests/auto/render/renderviewutils/tst_renderviewutils.cpp index b3ef1ba74..e4681a257 100644 --- a/tests/auto/render/renderviewutils/tst_renderviewutils.cpp +++ b/tests/auto/render/renderviewutils/tst_renderviewutils.cpp @@ -523,18 +523,20 @@ void tst_RenderViewUtils::transformedProperties() // THEN Qt3DRender::Render::ShaderData *backendShaderData = manager->lookupResource(shaderData->id()); QVERIFY(backendShaderData != nullptr); - QVERIFY(!backendShaderData->isPropertyToBeTransformed(QStringLiteral("position0"))); - QVERIFY(backendShaderData->isPropertyToBeTransformed(QStringLiteral("position1"))); - QVERIFY(backendShaderData->isPropertyToBeTransformed(QStringLiteral("position2"))); - QVERIFY(backendShaderData->isPropertyToBeTransformed(QStringLiteral("position3"))); + QCOMPARE(backendShaderData->propertyTransformType(QStringLiteral("position0")), Qt3DRender::Render::ShaderData::NoTransform); + QCOMPARE(backendShaderData->propertyTransformType(QStringLiteral("position1")), Qt3DRender::Render::ShaderData::ModelToEye); + QCOMPARE(backendShaderData->propertyTransformType(QStringLiteral("position2")), Qt3DRender::Render::ShaderData::ModelToWorld); + QCOMPARE(backendShaderData->propertyTransformType(QStringLiteral("position3")), Qt3DRender::Render::ShaderData::ModelToWorldDirection); // WHEN backendShaderData->updateWorldTransform(worldMatrix); const QVector3D position1Value = backendShaderData->getTransformedProperty(QStringLiteral("position1"), viewMatrix).value(); const QVector3D position2Value = backendShaderData->getTransformedProperty(QStringLiteral("position2"), viewMatrix).value(); const QVector3D position3Value = backendShaderData->getTransformedProperty(QStringLiteral("position3"), viewMatrix).value(); + const QVariant position0Value = backendShaderData->getTransformedProperty(QStringLiteral("position0"), viewMatrix); // THEN + QCOMPARE(position0Value, QVariant()); QCOMPARE(position1Value, viewMatrix * worldMatrix * position); QCOMPARE(position2Value, worldMatrix * position); QCOMPARE(position3Value, (worldMatrix * QVector4D(position, 0.0f)).toVector3D()); -- cgit v1.2.3 From 377cab78bbbbbf37a3ed87e9eec7602c6cb6837e Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Wed, 7 Sep 2016 15:29:01 +0300 Subject: Fix non-symmetric extents and resolutions for QCuboidMesh Task-number: QTBUG-55836 Change-Id: Ic5ee72f5ffb236fe15e46fa667159a139ad05b03 Reviewed-by: Sean Harmer --- src/extras/geometries/qcuboidgeometry.cpp | 34 ++-- .../extras/qcuboidgeometry/tst_qcuboidgeometry.cpp | 180 +++++++++++++++++++-- 2 files changed, 185 insertions(+), 29 deletions(-) diff --git a/src/extras/geometries/qcuboidgeometry.cpp b/src/extras/geometries/qcuboidgeometry.cpp index f720f1367..4e644b24a 100644 --- a/src/extras/geometries/qcuboidgeometry.cpp +++ b/src/extras/geometries/qcuboidgeometry.cpp @@ -76,23 +76,23 @@ void createPlaneVertexData(float w, float h, const QSize &resolution, switch (normal) { case NegativeX: // Iterate over z - for (int j = resolution.width() - 1; j >= 0; --j) { - const float a = a0 + static_cast(j) * da; - const float u = static_cast(j) * du; + for (int j = resolution.height() - 1; j >= 0; --j) { + const float b = b0 + static_cast(j) * db; + const float v = static_cast(j) * dv; // Iterate over y - for (int i = 0; i < resolution.height(); ++i) { - const float b = b0 + static_cast(i) * db; - const float v = static_cast(i) * dv; + for (int i = 0; i < resolution.width(); ++i) { + const float a = a0 + static_cast(i) * da; + const float u = static_cast(i) * du; // position *vertices++ = planeDistance; - *vertices++ = b; *vertices++ = a; + *vertices++ = b; // texture coordinates - *vertices++ = 1.0f - u; *vertices++ = v; + *vertices++ = u; // normal *vertices++ = -1.0f; @@ -102,8 +102,8 @@ void createPlaneVertexData(float w, float h, const QSize &resolution, // tangent *vertices++ = 0.0f; *vertices++ = 0.0f; - *vertices++ = -1.0f; - *vertices++ = -1.0f; + *vertices++ = 1.0f; + *vertices++ = 1.0f; } } break; @@ -111,22 +111,22 @@ void createPlaneVertexData(float w, float h, const QSize &resolution, case PositiveX: { // Iterate over z for (int j = 0; j < resolution.height(); ++j) { - const float a = a0 + static_cast(j) * da; - const float u = static_cast(j) * du; + const float b = b0 + static_cast(j) * db; + const float v = static_cast(j) * dv; // Iterate over y for (int i = 0; i < resolution.width(); ++i) { - const float b = b0 + static_cast(i) * db; - const float v = static_cast(i) * dv; + const float a = a0 + static_cast(i) * da; + const float u = static_cast(i) * du; // position *vertices++ = planeDistance; - *vertices++ = b; *vertices++ = a; + *vertices++ = b; // texture coordinates + *vertices++ = 1.0f - v; *vertices++ = u; - *vertices++ = v; // normal *vertices++ = 1.0f; @@ -136,8 +136,8 @@ void createPlaneVertexData(float w, float h, const QSize &resolution, // tangent *vertices++ = 0.0f; *vertices++ = 0.0f; - *vertices++ = 1.0f; *vertices++ = -1.0f; + *vertices++ = 1.0f; } } break; diff --git a/tests/auto/extras/qcuboidgeometry/tst_qcuboidgeometry.cpp b/tests/auto/extras/qcuboidgeometry/tst_qcuboidgeometry.cpp index ddd9eed22..fa1657732 100644 --- a/tests/auto/extras/qcuboidgeometry/tst_qcuboidgeometry.cpp +++ b/tests/auto/extras/qcuboidgeometry/tst_qcuboidgeometry.cpp @@ -286,13 +286,13 @@ private Q_SLOTS: << QVector3D(1.0f, 0.0f, 0.0f) << QVector3D(1.0f, 0.0f, 0.0f)); const auto texCoords = (QVector() - << QVector2D(0.0f, 0.0f) - << QVector2D(0.0f, 1.0f) - << QVector2D(1.0f, 0.0f)); + << QVector2D(1.0f, 0.0f) + << QVector2D(1.0f, 1.0f) + << QVector2D(0.0f, 0.0f)); const auto tangents = (QVector() - << QVector4D(0.0f, 0.0f, 1.0f, -1.0f) - << QVector4D(0.0f, 0.0f, 1.0f, -1.0f) - << QVector4D(0.0f, 0.0f, 1.0f, -1.0f)); + << QVector4D(0.0f, 0.0f, -1.0f, 1.0f) + << QVector4D(0.0f, 0.0f, -1.0f, 1.0f) + << QVector4D(0.0f, 0.0f, -1.0f, 1.0f)); QTest::newRow("default_positiveX_firstTriangle") << 1.0f << 1.0f << 1.0f << QSize(2,2) << QSize(2,2) << QSize(2,2) @@ -312,13 +312,13 @@ private Q_SLOTS: << QVector3D(-1.0f, 0.0f, 0.0f) << QVector3D(-1.0f, 0.0f, 0.0f)); const auto texCoords = (QVector() - << QVector2D(1.0f, 0.0f) - << QVector2D(0.0f, 1.0f) - << QVector2D(1.0f, 1.0f)); + << QVector2D(0.0f, 0.0f) + << QVector2D(1.0f, 1.0f) + << QVector2D(0.0f, 1.0f)); const auto tangents = (QVector() - << QVector4D(0.0f, 0.0f, -1.0f, -1.0f) - << QVector4D(0.0f, 0.0f, -1.0f, -1.0f) - << QVector4D(0.0f, 0.0f, -1.0f, -1.0f)); + << QVector4D(0.0f, 0.0f, 1.0f, 1.0f) + << QVector4D(0.0f, 0.0f, 1.0f, 1.0f) + << QVector4D(0.0f, 0.0f, 1.0f, 1.0f)); QTest::newRow("default_negativeX_lastTriangle") << 1.0f << 1.0f << 1.0f << QSize(2,2) << QSize(2,2) << QSize(2,2) @@ -429,6 +429,162 @@ private Q_SLOTS: << triangleIndex << indices << positions << normals << texCoords << tangents; } + + { + const int triangleIndex = 0; + const auto indices = (QVector() << 0 << 1 << 2); + const auto positions = (QVector() + << QVector3D(1.0f, -1.5f, -2.5f) + << QVector3D(1.0f, 1.5f, -2.5f) + << QVector3D(1.0f, -1.5f, -1.25f)); + const auto normals = (QVector() + << QVector3D(1.0f, 0.0f, 0.0f) + << QVector3D(1.0f, 0.0f, 0.0f) + << QVector3D(1.0f, 0.0f, 0.0f)); + const auto texCoords = (QVector() + << QVector2D(1.0f, 0.0f) + << QVector2D(1.0f, 1.0f) + << QVector2D(0.75f, 0.0f)); + const auto tangents = (QVector() + << QVector4D(0.0f, 0.0f, -1.0f, 1.0f) + << QVector4D(0.0f, 0.0f, -1.0f, 1.0f) + << QVector4D(0.0f, 0.0f, -1.0f, 1.0f)); + QTest::newRow("default_positiveX_firstTriangle_nonSymmetric") + << 2.0f << 3.0f << 5.0f + << QSize(2,3) << QSize(2,5) << QSize(2,9) + << triangleIndex + << indices << positions << normals << texCoords << tangents; + } + + { + const int triangleIndex = 15; + const auto indices = (QVector() << 18 << 17 << 19); + const auto positions = (QVector() + << QVector3D(-1.0f, -1.5f, -2.5f) + << QVector3D(-1.0f, 1.5f, -1.25f) + << QVector3D(-1.0f, 1.5f, -2.5f)); + const auto normals = (QVector() + << QVector3D(-1.0f, 0.0f, 0.0f) + << QVector3D(-1.0f, 0.0f, 0.0f) + << QVector3D(-1.0f, 0.0f, 0.0f)); + const auto texCoords = (QVector() + << QVector2D(0.0f, 0.0f) + << QVector2D(0.25f, 1.0f) + << QVector2D(0.0f, 1.0f)); + const auto tangents = (QVector() + << QVector4D(0.0f, 0.0f, 1.0f, 1.0f) + << QVector4D(0.0f, 0.0f, 1.0f, 1.0f) + << QVector4D(0.0f, 0.0f, 1.0f, 1.0f)); + QTest::newRow("default_negativeX_lastTriangle_nonSymmetric") + << 2.0f << 3.0f << 5.0f + << QSize(2,3) << QSize(2,5) << QSize(2,9) + << triangleIndex + << indices << positions << normals << texCoords << tangents; + } + + { + const int triangleIndex = 16; + const auto indices = (QVector() << 20 << 21 << 22); + const auto positions = (QVector() + << QVector3D(-1.0f, 1.5f, 2.5f) + << QVector3D(1.0f, 1.5f, 2.5f) + << QVector3D(-1.0f, 1.5f, 1.875f)); + const auto normals = (QVector() + << QVector3D(0.0f, 1.0f, 0.0f) + << QVector3D(0.0f, 1.0f, 0.0f) + << QVector3D(0.0f, 1.0f, 0.0f)); + const auto texCoords = (QVector() + << QVector2D(0.0f, 0.0f) + << QVector2D(1.0f, 0.0f) + << QVector2D(0.0f, 0.125f)); + const auto tangents = (QVector() + << QVector4D(1.0f, 0.0f, 0.0f, 1.0f) + << QVector4D(1.0f, 0.0f, 0.0f, 1.0f) + << QVector4D(1.0f, 0.0f, 0.0f, 1.0f)); + QTest::newRow("default_positiveY_firstTriangle_nonSymmetric") + << 2.0f << 3.0f << 5.0f + << QSize(2,3) << QSize(2,5) << QSize(2,9) + << triangleIndex + << indices << positions << normals << texCoords << tangents; + } + + { + const int triangleIndex = 47; + const auto indices = (QVector() << 54 << 53 << 55); + const auto positions = (QVector() + << QVector3D(-1.0f, -1.5f, 2.5f) + << QVector3D(1.0f, -1.5f, 1.875f) + << QVector3D(1.0f, -1.5f, 2.5f)); + const auto normals = (QVector() + << QVector3D(0.0f, -1.0f, 0.0f) + << QVector3D(0.0f, -1.0f, 0.0f) + << QVector3D(0.0f, -1.0f, 0.0f)); + const auto texCoords = (QVector() + << QVector2D(0.0f, 1.0f) + << QVector2D(1.0f, 0.875f) + << QVector2D(1.0f, 1.0f)); + const auto tangents = (QVector() + << QVector4D(1.0f, 0.0f, 0.0f, 1.0f) + << QVector4D(1.0f, 0.0f, 0.0f, 1.0f) + << QVector4D(1.0f, 0.0f, 0.0f, 1.0f)); + QTest::newRow("default_negativeY_lastTriangle_nonSymmetric") + << 2.0f << 3.0f << 5.0f + << QSize(2,3) << QSize(2,5) << QSize(2,9) + << triangleIndex + << indices << positions << normals << texCoords << tangents; + } + + { + const int triangleIndex = 48; + const auto indices = (QVector() << 56 << 57 << 58); + const auto positions = (QVector() + << QVector3D(-1.0f, -1.5f, 2.5f) + << QVector3D(1.0f, -1.5f, 2.5f) + << QVector3D(-1.0f, 0.0f, 2.5f)); + const auto normals = (QVector() + << QVector3D(0.0f, 0.0f, 1.0f) + << QVector3D(0.0f, 0.0f, 1.0f) + << QVector3D(0.0f, 0.0f, 1.0f)); + const auto texCoords = (QVector() + << QVector2D(0.0f, 0.0f) + << QVector2D(1.0f, 0.0f) + << QVector2D(0.0f, 0.5f)); + const auto tangents = (QVector() + << QVector4D(1.0f, 0.0f, 0.0f, 1.0f) + << QVector4D(1.0f, 0.0f, 0.0f, 1.0f) + << QVector4D(1.0f, 0.0f, 0.0f, 1.0f)); + QTest::newRow("default_positiveZ_firstTriangle_nonSymmetric") + << 2.0f << 3.0f << 5.0f + << QSize(2,3) << QSize(2,5) << QSize(2,9) + << triangleIndex + << indices << positions << normals << texCoords << tangents; + } + + { + const int triangleIndex = 55; + const auto indices = (QVector() << 66 << 65 << 67); + const auto positions = (QVector() + << QVector3D(1.0f, 1.5f, -2.5f) + << QVector3D(-1.0f, 0.0f, -2.5f) + << QVector3D(-1.0f, 1.5f, -2.5f)); + const auto normals = (QVector() + << QVector3D(0.0f, 0.0f, -1.0f) + << QVector3D(0.0f, 0.0f, -1.0f) + << QVector3D(0.0f, 0.0f, -1.0f)); + const auto texCoords = (QVector() + << QVector2D(0.0f, 1.0f) + << QVector2D(1.0f, 0.5f) + << QVector2D(1.0f, 1.0f)); + const auto tangents = (QVector() + << QVector4D(-1.0f, 0.0f, 0.0f, 1.0f) + << QVector4D(-1.0f, 0.0f, 0.0f, 1.0f) + << QVector4D(-1.0f, 0.0f, 0.0f, 1.0f)); + QTest::newRow("default_negativeZ_lastTriangle_nonSymmetric") + << 2.0f << 3.0f << 5.0f + << QSize(2,3) << QSize(2,5) << QSize(2,9) + << triangleIndex + << indices << positions << normals << texCoords << tangents; + } } void generatedGeometryShouldBeConsistent() -- cgit v1.2.3 From ddac1eed1d39f5f924d88820472cca414b2b9f0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antti=20M=C3=A4=C3=A4tt=C3=A4?= Date: Tue, 6 Sep 2016 15:44:19 +0300 Subject: Fix QCameraLens module MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It's in render module not in core. Change-Id: Ic42b65c365308915e38a42561f167f81d30c3b72 Reviewed-by: Miikka Heikkinen Reviewed-by: Tomi Korpipää Reviewed-by: Paul Lemire Reviewed-by: Sean Harmer --- src/render/frontend/qcameralens.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/render/frontend/qcameralens.cpp b/src/render/frontend/qcameralens.cpp index 3073fbc3f..4725251b5 100644 --- a/src/render/frontend/qcameralens.cpp +++ b/src/render/frontend/qcameralens.cpp @@ -46,7 +46,7 @@ namespace Qt3DRender { /*! * \class Qt3DRender::QCameraLens - * \inmodule Qt3DCore + * \inmodule Qt3DRender * * \brief Qt3DRender::QCameraLens specifies the projection matrix that will be used to * define a Camera for a 3D scene. @@ -57,7 +57,7 @@ namespace Qt3DRender { /*! * \qmltype CameraLens * \instantiates Qt3DRender::QCameraLens - * \inqmlmodule Qt3D.Core + * \inqmlmodule Qt3D.Render * \inherits Component3D * \since 5.5 * \brief Provides the projection matrix that is used to define a Camera for 3D scene. -- cgit v1.2.3 From 73e1f94e557709a3c4d59eb94314701319c3c1d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antti=20M=C3=A4=C3=A4tt=C3=A4?= Date: Thu, 8 Sep 2016 16:19:29 +0300 Subject: Update QClearbuffers docs Change-Id: I1209a4ec7c0775e16debbce864e965eb3df13771 Reviewed-by: Sean Harmer --- src/render/framegraph/qclearbuffers.cpp | 56 ++++++++++++++++++--------------- 1 file changed, 31 insertions(+), 25 deletions(-) diff --git a/src/render/framegraph/qclearbuffers.cpp b/src/render/framegraph/qclearbuffers.cpp index 1e8a5c6e3..6fec60364 100644 --- a/src/render/framegraph/qclearbuffers.cpp +++ b/src/render/framegraph/qclearbuffers.cpp @@ -45,12 +45,14 @@ QT_BEGIN_NAMESPACE namespace Qt3DRender { /*! - \class Qt3DRender::QClearBuffers - \inmodule Qt3DRender - \since 5.7 - \ingroup framegraph + \class Qt3DRender::QClearBuffers + \inmodule Qt3DRender + \since 5.7 + \ingroup framegraph + \brief Class to clear buffers - \brief Class to clear buffers + A Qt3DRender::QClearBuffers FrameGraph node enables clearing of the specific + render target buffers with specific values. */ /*! @@ -59,21 +61,24 @@ namespace Qt3DRender { \instantiates Qt3DRender::QClearBuffers \inherits FrameGraphNode \since 5.7 - \qmlabstract + \brief Class to clear buffers + + A Qt3DRender::QClearBuffers FrameGraph node enables clearing of the specific + render target buffers with specific values. */ /*! \enum QClearBuffers::BufferType This enum type describes types of buffer to be cleared. - \value None - \value ColorBuffer - \value DepthBuffer - \value StencilBuffer - \value DepthStencilBuffer - \value ColorDepthBuffer - \value ColorDepthStencilBuffer - \value AllBuffers + \value None No buffers will be cleared + \value ColorBuffer Clear color buffers + \value DepthBuffer Clear depth buffer + \value StencilBuffer Clear stencil buffer + \value DepthStencilBuffer Clear depth and stencil buffers + \value ColorDepthBuffer Clear color and depth buffers + \value ColorDepthStencilBuffer Clear color, depth and stencil buffers + \value AllBuffers Clear all buffers */ QClearBuffersPrivate::QClearBuffersPrivate() @@ -86,7 +91,7 @@ QClearBuffersPrivate::QClearBuffersPrivate() } /*! - The constructor creates an instance with the specified \a parent. + The constructor creates an instance with the specified \a parent. */ QClearBuffers::QClearBuffers(QNode *parent) : QFrameGraphNode(*new QClearBuffersPrivate, parent) @@ -141,8 +146,8 @@ QRenderTargetOutput *QClearBuffers::colorBuffer() const */ /*! - \qmlproperty BufferType Qt3D.Render::ClearBuffers::buffers - + \qmlproperty enumeration Qt3D.Render::ClearBuffers::buffers + Specifies the buffer type to be used. */ void QClearBuffers::setBuffers(QClearBuffers::BufferType buffers) { @@ -158,8 +163,8 @@ void QClearBuffers::setBuffers(QClearBuffers::BufferType buffers) Specifies the clear color to be used. */ /*! - \qmlproperty Color Qt3D.Render::ClearBuffers::color - + \qmlproperty color Qt3D.Render::ClearBuffers::color + Specifies the clear color to be used. */ void QClearBuffers::setClearColor(const QColor &color) { @@ -176,8 +181,8 @@ void QClearBuffers::setClearColor(const QColor &color) Specifies the clear depth value to be used. */ /*! - \qmlproperty float Qt3D.Render::ClearBuffers::clearDepthValue - + \qmlproperty real Qt3D.Render::ClearBuffers::clearDepthValue + Specifies the clear depth value to be used. */ void QClearBuffers::setClearDepthValue(float clearDepthValue) { @@ -196,8 +201,8 @@ void QClearBuffers::setClearDepthValue(float clearDepthValue) Specifies the stencil value to be used. */ /*! - \qmlproperty int Qt3D.Render::ClearBuffers::clearStencilValue - + \qmlproperty int Qt3D.Render::ClearBuffers::clearStencilValue + Specifies the stencil value to be used. */ void QClearBuffers::setClearStencilValue(int clearStencilValue) { @@ -214,8 +219,9 @@ void QClearBuffers::setClearStencilValue(int clearStencilValue) ColorBuffer flag is set, all color buffers will be cleared. */ /*! - \qmlproperty Qt3D.Render::RenderTargetOutput Qt3D.Render::ClearBuffers::colorbuffer - + \qmlproperty RenderTargetOutput Qt3D.Render::ClearBuffers::colorbuffer + Specifies a specific color buffer to clear. If set to NULL (default), and + ColorBuffer flag is set, all color buffers will be cleared. */ void QClearBuffers::setColorBuffer(QRenderTargetOutput *buffer) { -- cgit v1.2.3 From 7e638edbd15640302516f9a69d20f62d26d4af06 Mon Sep 17 00:00:00 2001 From: Paul Lemire Date: Mon, 5 Sep 2016 11:15:14 +0200 Subject: QTechnique fix: was sending wrong change type Change-Id: Ide125bd292f10d2363cd0928af2513efe9f25eaf Reviewed-by: Kevin Ottens Reviewed-by: Sean Harmer --- src/render/materialsystem/qtechnique.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/render/materialsystem/qtechnique.cpp b/src/render/materialsystem/qtechnique.cpp index 768397e76..74505bfbd 100644 --- a/src/render/materialsystem/qtechnique.cpp +++ b/src/render/materialsystem/qtechnique.cpp @@ -284,7 +284,7 @@ void QTechnique::removeRenderPass(QRenderPass *pass) Q_ASSERT(pass); Q_D(QTechnique); if (d->m_changeArbiter) { - const auto change = QPropertyNodeAddedChangePtr::create(id(), pass); + const auto change = QPropertyNodeRemovedChangePtr::create(id(), pass); change->setPropertyName("pass"); d->notifyObservers(change); } -- cgit v1.2.3