summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMike Krus <mike.krus@kdab.com>2018-01-16 22:02:23 +0000
committerMike Krus <mike.krus@kdab.com>2018-02-01 21:26:06 +0000
commit13791f59f8fe9863fbacb7985d06f29522046bad (patch)
tree790f9c7c178e6b302da440f60a8d7d1f78eed779
parent89ec1b820a3be3ab5d3abb408bea4408954e82ac (diff)
Introduce QScreenRayCaster
Split common functionality into abstract base class. Both frontend classes use the same backend implementation. Split common pick functionality for the object picking and ray casting jobs into abstract base class. Change-Id: Ieb8bdcf65d81db12234841d72c6cb0160e145bf6 Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
-rw-r--r--src/render/backend/entity.cpp3
-rw-r--r--src/render/frontend/qrenderaspect.cpp3
-rw-r--r--src/render/jobs/abstractpickingjob.cpp138
-rw-r--r--src/render/jobs/abstractpickingjob_p.h114
-rw-r--r--src/render/jobs/jobs.pri2
-rw-r--r--src/render/jobs/pickboundingvolumejob.cpp77
-rw-r--r--src/render/jobs/pickboundingvolumejob_p.h46
-rw-r--r--src/render/jobs/raycastingjob.cpp125
-rw-r--r--src/render/jobs/raycastingjob_p.h26
-rw-r--r--src/render/picking/picking.pri6
-rw-r--r--src/render/picking/qabstractraycaster.cpp153
-rw-r--r--src/render/picking/qabstractraycaster.h98
-rw-r--r--src/render/picking/qabstractraycaster_p.h (renamed from src/render/picking/qraycaster_p.h)42
-rw-r--r--src/render/picking/qraycaster.cpp83
-rw-r--r--src/render/picking/qraycaster.h31
-rw-r--r--src/render/picking/qraycasterhit.h4
-rw-r--r--src/render/picking/qscreenraycaster.cpp116
-rw-r--r--src/render/picking/qscreenraycaster.h80
-rw-r--r--src/render/picking/raycaster.cpp32
-rw-r--r--src/render/picking/raycaster_p.h14
-rw-r--r--tests/auto/render/raycasting/tst_raycasting.cpp12
21 files changed, 864 insertions, 341 deletions
diff --git a/src/render/backend/entity.cpp b/src/render/backend/entity.cpp
index c38c8ea9f..1a0e877d6 100644
--- a/src/render/backend/entity.cpp
+++ b/src/render/backend/entity.cpp
@@ -45,6 +45,7 @@
#include <Qt3DRender/qlayer.h>
#include <Qt3DRender/qlevelofdetail.h>
#include <Qt3DRender/qraycaster.h>
+#include <Qt3DRender/qscreenraycaster.h>
#include <Qt3DRender/qmaterial.h>
#include <Qt3DRender/qmesh.h>
#include <Qt3DRender/private/renderlogging_p.h>
@@ -317,6 +318,8 @@ void Entity::addComponent(Qt3DCore::QNodeIdTypePair idAndType)
m_levelOfDetailComponents.append(id);
} else if (type->inherits(&QRayCaster::staticMetaObject)) {
m_rayCasterComponents.append(id);
+ } else if (type->inherits(&QScreenRayCaster::staticMetaObject)) {
+ m_rayCasterComponents.append(id);
} else if (type->inherits(&QMaterial::staticMetaObject)) {
m_materialComponent = id;
} else if (type->inherits(&QAbstractLight::staticMetaObject)) { // QAbstractLight subclasses QShaderData
diff --git a/src/render/frontend/qrenderaspect.cpp b/src/render/frontend/qrenderaspect.cpp
index bbbb08a09..3b63f43eb 100644
--- a/src/render/frontend/qrenderaspect.cpp
+++ b/src/render/frontend/qrenderaspect.cpp
@@ -74,6 +74,7 @@
#include <Qt3DRender/qgeometryrenderer.h>
#include <Qt3DRender/qobjectpicker.h>
#include <Qt3DRender/qraycaster.h>
+#include <Qt3DRender/qscreenraycaster.h>
#include <Qt3DRender/qfrustumculling.h>
#include <Qt3DRender/qabstractlight.h>
#include <Qt3DRender/qenvironmentlight.h>
@@ -292,6 +293,7 @@ void QRenderAspectPrivate::registerBackendTypes()
// Picking
q->registerBackendType<QObjectPicker>(QSharedPointer<Render::NodeFunctor<Render::ObjectPicker, Render::ObjectPickerManager> >::create(m_renderer));
q->registerBackendType<QRayCaster>(QSharedPointer<Render::NodeFunctor<Render::RayCaster, Render::RayCasterManager> >::create(m_renderer));
+ q->registerBackendType<QScreenRayCaster>(QSharedPointer<Render::NodeFunctor<Render::RayCaster, Render::RayCasterManager> >::create(m_renderer));
// Plugins
for (const QString &plugin : qAsConst(m_pluginConfig))
@@ -358,6 +360,7 @@ void QRenderAspectPrivate::unregisterBackendTypes()
// Picking
unregisterBackendType<QObjectPicker>();
unregisterBackendType<QRayCaster>();
+ unregisterBackendType<QScreenRayCaster>();
// Plugins
for (Render::QRenderPlugin *plugin : qAsConst(m_renderPlugins))
diff --git a/src/render/jobs/abstractpickingjob.cpp b/src/render/jobs/abstractpickingjob.cpp
new file mode 100644
index 000000000..417ac6b65
--- /dev/null
+++ b/src/render/jobs/abstractpickingjob.cpp
@@ -0,0 +1,138 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 Klaralvdalens Datakonsult AB (KDAB).
+** 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$
+**
+****************************************************************************/
+
+#include "abstractpickingjob_p.h"
+#include <Qt3DRender/qgeometryrenderer.h>
+#include <Qt3DRender/private/renderer_p.h>
+#include <Qt3DRender/private/nodemanagers_p.h>
+#include <Qt3DRender/private/entity_p.h>
+#include <Qt3DRender/private/objectpicker_p.h>
+#include <Qt3DRender/private/managers_p.h>
+#include <Qt3DRender/private/geometryrenderer_p.h>
+#include <Qt3DRender/private/rendersettings_p.h>
+#include <Qt3DRender/private/trianglesvisitor_p.h>
+#include <Qt3DRender/private/job_common_p.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3DRender {
+
+namespace Render {
+
+AbstractPickingJob::AbstractPickingJob()
+ : m_manager(nullptr)
+ , m_node(nullptr)
+ , m_frameGraphRoot(nullptr)
+ , m_renderSettings(nullptr)
+{
+}
+
+void AbstractPickingJob::setRoot(Entity *root)
+{
+ m_node = root;
+}
+
+void AbstractPickingJob::setFrameGraphRoot(FrameGraphNode *frameGraphRoot)
+{
+ m_frameGraphRoot = frameGraphRoot;
+}
+
+void AbstractPickingJob::setRenderSettings(RenderSettings *settings)
+{
+ m_renderSettings = settings;
+}
+
+void AbstractPickingJob::setManagers(NodeManagers *manager)
+{
+ m_manager = manager;
+}
+
+void AbstractPickingJob::run()
+{
+ Q_ASSERT(m_frameGraphRoot && m_renderSettings && m_node && m_manager);
+ runHelper();
+}
+
+RayCasting::QRay3D AbstractPickingJob::intersectionRay(const QPoint &pos, const QMatrix4x4 &viewMatrix,
+ const QMatrix4x4 &projectionMatrix, const QRect &viewport)
+{
+ QVector3D nearPos = QVector3D(pos.x(), pos.y(), 0.0f);
+ nearPos = nearPos.unproject(viewMatrix, projectionMatrix, viewport);
+ QVector3D farPos = QVector3D(pos.x(), pos.y(), 1.0f);
+ farPos = farPos.unproject(viewMatrix, projectionMatrix, viewport);
+
+ return RayCasting::QRay3D(nearPos,
+ (farPos - nearPos).normalized(),
+ (farPos - nearPos).length());
+}
+
+QRect AbstractPickingJob::windowViewport(const QSize &area, const QRectF &relativeViewport) const
+{
+ if (area.isValid()) {
+ const int areaWidth = area.width();
+ const int areaHeight = area.height();
+ return QRect(relativeViewport.x() * areaWidth,
+ (1.0 - relativeViewport.y() - relativeViewport.height()) * areaHeight,
+ relativeViewport.width() * areaWidth,
+ relativeViewport.height() * areaHeight);
+ }
+ return relativeViewport.toRect();
+}
+
+RayCasting::QRay3D AbstractPickingJob::rayForViewportAndCamera(const QSize &area,
+ const QPoint &pos,
+ const QRectF &relativeViewport,
+ const Qt3DCore::QNodeId cameraId) const
+{
+ QMatrix4x4 viewMatrix;
+ QMatrix4x4 projectionMatrix;
+ Render::CameraLens::viewMatrixForCamera(m_manager->renderNodesManager(), cameraId, viewMatrix, projectionMatrix);
+ const QRect viewport = windowViewport(area, relativeViewport);
+
+ // In GL the y is inverted compared to Qt
+ const QPoint glCorrectPos = QPoint(pos.x(), area.isValid() ? area.height() - pos.y() : pos.y());
+ const auto ray = intersectionRay(glCorrectPos, viewMatrix, projectionMatrix, viewport);
+ return ray;
+}
+
+} // namespace Render
+
+} // namespace Qt3DRender
+
+QT_END_NAMESPACE
diff --git a/src/render/jobs/abstractpickingjob_p.h b/src/render/jobs/abstractpickingjob_p.h
new file mode 100644
index 000000000..b527d754a
--- /dev/null
+++ b/src/render/jobs/abstractpickingjob_p.h
@@ -0,0 +1,114 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 Klaralvdalens Datakonsult AB (KDAB).
+** 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$
+**
+****************************************************************************/
+
+#ifndef QT3DRENDER_RENDER_ABSTRACTPICKINGJOB_P_H
+#define QT3DRENDER_RENDER_ABSTRACTPICKINGJOB_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists for the convenience
+// of other Qt classes. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <Qt3DCore/qaspectjob.h>
+#include <Qt3DRender/private/qray3d_p.h>
+#include <Qt3DRender/private/handle_types_p.h>
+#include <Qt3DRender/private/qboundingvolumeprovider_p.h>
+#include <Qt3DRender/private/qcollisionqueryresult_p.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3DCore {
+class QNodeId;
+}
+
+namespace Qt3DRender {
+namespace Render {
+
+class Entity;
+class Renderer;
+class NodeManagers;
+class RenderSettings;
+
+class Q_AUTOTEST_EXPORT AbstractPickingJob : public Qt3DCore::QAspectJob
+{
+public:
+ AbstractPickingJob();
+
+ void setRoot(Entity *root);
+ void setFrameGraphRoot(FrameGraphNode *frameGraphRoot);
+ void setRenderSettings(RenderSettings *settings);
+ void setManagers(NodeManagers *manager);
+
+ // public for unit tests
+ virtual bool runHelper() = 0;
+ static RayCasting::QRay3D intersectionRay(const QPoint &pos,
+ const QMatrix4x4 &viewMatrix,
+ const QMatrix4x4 &projectionMatrix,
+ const QRect &viewport);
+
+protected:
+ void run() final;
+
+ NodeManagers *m_manager;
+ Entity *m_node;
+ FrameGraphNode *m_frameGraphRoot;
+ RenderSettings *m_renderSettings;
+
+ bool m_oneEnabledAtLeast;
+
+ QRect windowViewport(const QSize &area, const QRectF &relativeViewport) const;
+ RayCasting::QRay3D rayForViewportAndCamera(const QSize &area,
+ const QPoint &pos,
+ const QRectF &relativeViewport,
+ const Qt3DCore::QNodeId cameraId) const;
+};
+
+} // namespace Render
+
+} // namespace Qt3DRender
+
+QT_END_NAMESPACE
+
+#endif // QT3DRENDER_RENDER_ABSTRACTPICKINGJOB_P_H
diff --git a/src/render/jobs/jobs.pri b/src/render/jobs/jobs.pri
index 42219da49..74c8c598a 100644
--- a/src/render/jobs/jobs.pri
+++ b/src/render/jobs/jobs.pri
@@ -34,6 +34,7 @@ HEADERS += \
$$PWD/loadskeletonjob_p.h \
$$PWD/updateskinningpalettejob_p.h \
$$PWD/filterproximitydistancejob_p.h \
+ $$PWD/abstractpickingjob_p.h \
$$PWD/raycastingjob_p.h
SOURCES += \
@@ -67,5 +68,6 @@ SOURCES += \
$$PWD/loadskeletonjob.cpp \
$$PWD/updateskinningpalettejob.cpp \
$$PWD/filterproximitydistancejob.cpp \
+ $$PWD/abstractpickingjob.cpp \
$$PWD/raycastingjob.cpp
diff --git a/src/render/jobs/pickboundingvolumejob.cpp b/src/render/jobs/pickboundingvolumejob.cpp
index ed6944d31..f75e47839 100644
--- a/src/render/jobs/pickboundingvolumejob.cpp
+++ b/src/render/jobs/pickboundingvolumejob.cpp
@@ -105,20 +105,12 @@ void setEventButtonAndModifiers(const QMouseEvent &event, QPickEvent::Buttons &e
} // anonymous
PickBoundingVolumeJob::PickBoundingVolumeJob()
- : m_manager(nullptr)
- , m_node(nullptr)
- , m_frameGraphRoot(nullptr)
- , m_renderSettings(nullptr)
+ : AbstractPickingJob()
, m_pickersDirty(true)
{
SET_JOB_RUN_STAT_TYPE(this, JobTypes::PickBoundingVolume, 0);
}
-void PickBoundingVolumeJob::setRoot(Entity *root)
-{
- m_node = root;
-}
-
void PickBoundingVolumeJob::setMouseEvents(const QList<QMouseEvent> &pendingEvents)
{
m_pendingMouseEvents = pendingEvents;
@@ -129,27 +121,9 @@ void PickBoundingVolumeJob::setKeyEvents(const QList<QKeyEvent> &pendingEvents)
m_pendingKeyEvents = pendingEvents;
}
-void PickBoundingVolumeJob::setFrameGraphRoot(FrameGraphNode *frameGraphRoot)
-{
- m_frameGraphRoot = frameGraphRoot;
-}
-
-void PickBoundingVolumeJob::setRenderSettings(RenderSettings *settings)
-{
- m_renderSettings = settings;
-}
-
-RayCasting::QRay3D PickBoundingVolumeJob::intersectionRay(const QPoint &pos, const QMatrix4x4 &viewMatrix,
- const QMatrix4x4 &projectionMatrix, const QRect &viewport)
+void PickBoundingVolumeJob::markPickersDirty()
{
- QVector3D nearPos = QVector3D(pos.x(), pos.y(), 0.0f);
- nearPos = nearPos.unproject(viewMatrix, projectionMatrix, viewport);
- QVector3D farPos = QVector3D(pos.x(), pos.y(), 1.0f);
- farPos = farPos.unproject(viewMatrix, projectionMatrix, viewport);
-
- return RayCasting::QRay3D(nearPos,
- (farPos - nearPos).normalized(),
- (farPos - nearPos).length());
+ m_pickersDirty = true;
}
bool PickBoundingVolumeJob::runHelper()
@@ -297,22 +271,6 @@ bool PickBoundingVolumeJob::runHelper()
return true;
}
-void PickBoundingVolumeJob::setManagers(NodeManagers *manager)
-{
- m_manager = manager;
-}
-
-void PickBoundingVolumeJob::markPickersDirty()
-{
- m_pickersDirty = true;
-}
-
-void PickBoundingVolumeJob::run()
-{
- Q_ASSERT(m_frameGraphRoot && m_renderSettings && m_node && m_manager);
- runHelper();
-}
-
void PickBoundingVolumeJob::dispatchPickEvents(const QMouseEvent &event,
const PickingUtils::HitList &sphereHits,
QPickEvent::Buttons eventButton,
@@ -461,35 +419,6 @@ void PickBoundingVolumeJob::dispatchPickEvents(const QMouseEvent &event,
}
}
-QRect PickBoundingVolumeJob::windowViewport(const QSize &area, const QRectF &relativeViewport) const
-{
- if (area.isValid()) {
- const int areaWidth = area.width();
- const int areaHeight = area.height();
- return QRect(relativeViewport.x() * areaWidth,
- (1.0 - relativeViewport.y() - relativeViewport.height()) * areaHeight,
- relativeViewport.width() * areaWidth,
- relativeViewport.height() * areaHeight);
- }
- return relativeViewport.toRect();
-}
-
-RayCasting::QRay3D PickBoundingVolumeJob::rayForViewportAndCamera(const QSize &area,
- const QPoint &pos,
- const QRectF &relativeViewport,
- const Qt3DCore::QNodeId cameraId) const
-{
- QMatrix4x4 viewMatrix;
- QMatrix4x4 projectionMatrix;
- Render::CameraLens::viewMatrixForCamera(m_manager->renderNodesManager(), cameraId, viewMatrix, projectionMatrix);
- const QRect viewport = windowViewport(area, relativeViewport);
-
- // In GL the y is inverted compared to Qt
- const QPoint glCorrectPos = QPoint(pos.x(), area.isValid() ? area.height() - pos.y() : pos.y());
- const auto ray = intersectionRay(glCorrectPos, viewMatrix, projectionMatrix, viewport);
- return ray;
-}
-
void PickBoundingVolumeJob::clearPreviouslyHoveredPickers()
{
for (const HObjectPicker &pickHandle : qAsConst(m_hoveredPickersToClear)) {
diff --git a/src/render/jobs/pickboundingvolumejob_p.h b/src/render/jobs/pickboundingvolumejob_p.h
index da1a8f040..407cc37a5 100644
--- a/src/render/jobs/pickboundingvolumejob_p.h
+++ b/src/render/jobs/pickboundingvolumejob_p.h
@@ -51,11 +51,7 @@
// We mean it.
//
-#include <Qt3DCore/qaspectjob.h>
-#include <Qt3DRender/private/qray3d_p.h>
-#include <Qt3DRender/private/handle_types_p.h>
-#include <Qt3DRender/private/qboundingvolumeprovider_p.h>
-#include <Qt3DRender/private/qcollisionqueryresult_p.h>
+#include "abstractpickingjob_p.h"
#include <Qt3DRender/qpickevent.h>
#include <QMouseEvent>
#include <QKeyEvent>
@@ -63,48 +59,29 @@
QT_BEGIN_NAMESPACE
-namespace Qt3DCore {
-class QNodeId;
-}
-
namespace Qt3DRender {
namespace Render {
-class Entity;
-class Renderer;
-class NodeManagers;
-class RenderSettings;
-
namespace PickingUtils {
typedef QVector<RayCasting::QCollisionQueryResult::Hit> HitList;
}
-class Q_AUTOTEST_EXPORT PickBoundingVolumeJob : public Qt3DCore::QAspectJob
+class Q_AUTOTEST_EXPORT PickBoundingVolumeJob : public AbstractPickingJob
{
public:
PickBoundingVolumeJob();
- void setRoot(Entity *root);
void setMouseEvents(const QList<QMouseEvent> &pendingEvents);
void setKeyEvents(const QList<QKeyEvent> &pendingEvents);
- void setFrameGraphRoot(FrameGraphNode *frameGraphRoot);
- void setRenderSettings(RenderSettings *settings);
- void setManagers(NodeManagers *manager);
void markPickersDirty();
bool pickersDirty() const { return m_pickersDirty; }
- static RayCasting::QRay3D intersectionRay(const QPoint &pos,
- const QMatrix4x4 &viewMatrix,
- const QMatrix4x4 &projectionMatrix,
- const QRect &viewport);
-
// For unit tests
inline HObjectPicker currentPicker() const { return m_currentPicker; }
inline QVector<HObjectPicker> hoveredPickers() const { return m_hoveredPickers; }
- bool runHelper();
+ bool runHelper() override;
protected:
- void run() final;
void dispatchPickEvents(const QMouseEvent &event,
const PickingUtils::HitList &sphereHits,
QPickEvent::Buttons eventButton,
@@ -113,26 +90,15 @@ protected:
bool allHitsRequested);
private:
- NodeManagers *m_manager;
- Entity *m_node;
- FrameGraphNode *m_frameGraphRoot;
- RenderSettings *m_renderSettings;
QList<QMouseEvent> m_pendingMouseEvents;
+ QList<QKeyEvent> m_pendingKeyEvents;
bool m_pickersDirty;
- bool m_oneEnabledAtLeast;
bool m_oneHoverAtLeast;
-
- QList<QKeyEvent> m_pendingKeyEvents;
-
- QRect windowViewport(const QSize &area, const QRectF &relativeViewport) const;
- RayCasting::QRay3D rayForViewportAndCamera(const QSize &area,
- const QPoint &pos,
- const QRectF &relativeViewport,
- const Qt3DCore::QNodeId cameraId) const;
- void clearPreviouslyHoveredPickers();
HObjectPicker m_currentPicker;
QVector<HObjectPicker> m_hoveredPickers;
QVector<HObjectPicker> m_hoveredPickersToClear;
+
+ void clearPreviouslyHoveredPickers();
};
typedef QSharedPointer<PickBoundingVolumeJob> PickBoundingVolumeJobPtr;
diff --git a/src/render/jobs/raycastingjob.cpp b/src/render/jobs/raycastingjob.cpp
index ad69f81be..3a44cd113 100644
--- a/src/render/jobs/raycastingjob.cpp
+++ b/src/render/jobs/raycastingjob.cpp
@@ -101,46 +101,17 @@ private:
RayCastingJob::RayCastingJob()
- : m_manager(nullptr)
- , m_node(nullptr)
- , m_frameGraphRoot(nullptr)
- , m_renderSettings(nullptr)
+ : AbstractPickingJob()
, m_castersDirty(true)
{
SET_JOB_RUN_STAT_TYPE(this, JobTypes::RayCasting, 0);
}
-void RayCastingJob::setRoot(Entity *root)
-{
- m_node = root;
-}
-
-void RayCastingJob::setFrameGraphRoot(FrameGraphNode *frameGraphRoot)
-{
- m_frameGraphRoot = frameGraphRoot;
-}
-
-void RayCastingJob::setRenderSettings(RenderSettings *settings)
-{
- m_renderSettings = settings;
-}
-
-void RayCastingJob::setManagers(NodeManagers *manager)
-{
- m_manager = manager;
-}
-
void RayCastingJob::markCastersDirty()
{
m_castersDirty = true;
}
-void RayCastingJob::run()
-{
- Q_ASSERT(m_frameGraphRoot && m_renderSettings && m_node && m_manager);
- runHelper();
-}
-
bool RayCastingJob::runHelper()
{
// Quickly look which caster settings we've got
@@ -175,47 +146,65 @@ bool RayCastingJob::runHelper()
EntityCasterGatherer gatherer(m_node);
const EntityCasterGatherer::EntityCasterList &entities = gatherer.result();
+
+ PickingUtils::ViewportCameraAreaGatherer vcaGatherer;
+ const QVector<PickingUtils::ViewportCameraAreaTriplet> vcaTriplets = vcaGatherer.gather(m_frameGraphRoot);
+
for (const EntityCasterGatherer::EntityCasterList::value_type &pair: entities) {
- QRay3D ray(pair.second->origin(), pair.second->direction(), pair.second->length());
- ray.transform(*pair.first->worldTransform());
+ QVector<QRay3D> rays;
- PickingUtils::HitList sphereHits;
- PickingUtils::HierarchicalEntityPicker entityPicker(ray, false);
- if (entityPicker.collectHits(m_node)) {
- if (trianglePickingRequested) {
- PickingUtils::TriangleCollisionGathererFunctor gathererFunctor;
- gathererFunctor.m_frontFaceRequested = frontFaceRequested;
- gathererFunctor.m_backFaceRequested = backFaceRequested;
- gathererFunctor.m_manager = m_manager;
- gathererFunctor.m_ray = ray;
- gathererFunctor.m_objectPickersRequired = false;
- sphereHits << gathererFunctor.computeHits(entityPicker.entities(), true);
- }
- if (edgePickingRequested) {
- PickingUtils::LineCollisionGathererFunctor gathererFunctor;
- gathererFunctor.m_manager = m_manager;
- gathererFunctor.m_ray = ray;
- gathererFunctor.m_pickWorldSpaceTolerance = pickWorldSpaceTolerance;
- gathererFunctor.m_objectPickersRequired = false;
- sphereHits << gathererFunctor.computeHits(entityPicker.entities(), true);
- PickingUtils::AbstractCollisionGathererFunctor::sortHits(sphereHits);
- }
- if (pointPickingRequested) {
- PickingUtils::PointCollisionGathererFunctor gathererFunctor;
- gathererFunctor.m_manager = m_manager;
- gathererFunctor.m_ray = ray;
- gathererFunctor.m_pickWorldSpaceTolerance = pickWorldSpaceTolerance;
- gathererFunctor.m_objectPickersRequired = false;
- sphereHits << gathererFunctor.computeHits(entityPicker.entities(), true);
- PickingUtils::AbstractCollisionGathererFunctor::sortHits(sphereHits);
- }
- if (!primitivePickingRequested) {
- sphereHits << entityPicker.hits();
- PickingUtils::AbstractCollisionGathererFunctor::sortHits(sphereHits);
- }
+ switch (pair.second->type()) {
+ case QAbstractRayCasterPrivate::WorldSpaceRayCaster:
+ rays << QRay3D(pair.second->origin(), pair.second->direction(), pair.second->length());
+ rays.back().transform(*pair.first->worldTransform());
+ break;
+ case QAbstractRayCasterPrivate::ScreenScapeRayCaster:
+ for (const PickingUtils::ViewportCameraAreaTriplet &vca : vcaTriplets)
+ rays << rayForViewportAndCamera(vca.area, pair.second->position(), vca.viewport, vca.cameraId);
+ break;
+ default:
+ Q_UNREACHABLE();
}
- dispatchHits(pair.second, sphereHits);
+ for (const QRay3D &ray: qAsConst(rays)) {
+ PickingUtils::HitList sphereHits;
+ PickingUtils::HierarchicalEntityPicker entityPicker(ray, false);
+ if (entityPicker.collectHits(m_node)) {
+ if (trianglePickingRequested) {
+ PickingUtils::TriangleCollisionGathererFunctor gathererFunctor;
+ gathererFunctor.m_frontFaceRequested = frontFaceRequested;
+ gathererFunctor.m_backFaceRequested = backFaceRequested;
+ gathererFunctor.m_manager = m_manager;
+ gathererFunctor.m_ray = ray;
+ gathererFunctor.m_objectPickersRequired = false;
+ sphereHits << gathererFunctor.computeHits(entityPicker.entities(), true);
+ }
+ if (edgePickingRequested) {
+ PickingUtils::LineCollisionGathererFunctor gathererFunctor;
+ gathererFunctor.m_manager = m_manager;
+ gathererFunctor.m_ray = ray;
+ gathererFunctor.m_pickWorldSpaceTolerance = pickWorldSpaceTolerance;
+ gathererFunctor.m_objectPickersRequired = false;
+ sphereHits << gathererFunctor.computeHits(entityPicker.entities(), true);
+ PickingUtils::AbstractCollisionGathererFunctor::sortHits(sphereHits);
+ }
+ if (pointPickingRequested) {
+ PickingUtils::PointCollisionGathererFunctor gathererFunctor;
+ gathererFunctor.m_manager = m_manager;
+ gathererFunctor.m_ray = ray;
+ gathererFunctor.m_pickWorldSpaceTolerance = pickWorldSpaceTolerance;
+ gathererFunctor.m_objectPickersRequired = false;
+ sphereHits << gathererFunctor.computeHits(entityPicker.entities(), true);
+ PickingUtils::AbstractCollisionGathererFunctor::sortHits(sphereHits);
+ }
+ if (!primitivePickingRequested) {
+ sphereHits << entityPicker.hits();
+ PickingUtils::AbstractCollisionGathererFunctor::sortHits(sphereHits);
+ }
+ }
+
+ dispatchHits(pair.second, sphereHits);
+ }
}
return true;
@@ -223,7 +212,7 @@ bool RayCastingJob::runHelper()
void RayCastingJob::dispatchHits(RayCaster *rayCaster, const PickingUtils::HitList &sphereHits)
{
- QRayCaster::Hits hits;
+ QAbstractRayCaster::Hits hits;
for (const PickingUtils::HitList::value_type &sphereHit: sphereHits) {
Entity *entity = m_manager->renderNodesManager()->lookupResource(sphereHit.m_entityId);
QVector3D localIntersection = sphereHit.m_intersection;
diff --git a/src/render/jobs/raycastingjob_p.h b/src/render/jobs/raycastingjob_p.h
index 7ae7721d0..0bd8d445a 100644
--- a/src/render/jobs/raycastingjob_p.h
+++ b/src/render/jobs/raycastingjob_p.h
@@ -51,7 +51,7 @@
// We mean it.
//
-#include <Qt3DCore/qaspectjob.h>
+#include "abstractpickingjob_p.h"
#include <Qt3DRender/qpickevent.h>
#include <Qt3DRender/private/handle_types_p.h>
#include <Qt3DRender/private/qcollisionqueryresult_p.h>
@@ -61,45 +61,25 @@
QT_BEGIN_NAMESPACE
-namespace Qt3DCore {
-class QNodeId;
-}
-
namespace Qt3DRender {
namespace Render {
-class Entity;
-class NodeManagers;
-class RenderSettings;
-class RayCaster;
-
namespace PickingUtils {
typedef QVector<RayCasting::QCollisionQueryResult::Hit> HitList;
}
-class Q_AUTOTEST_EXPORT RayCastingJob : public Qt3DCore::QAspectJob
+class Q_AUTOTEST_EXPORT RayCastingJob : public AbstractPickingJob
{
public:
RayCastingJob();
- void setRoot(Entity *root);
- void setFrameGraphRoot(FrameGraphNode *frameGraphRoot);
- void setRenderSettings(RenderSettings *settings);
- void setManagers(NodeManagers *manager);
-
void markCastersDirty();
- bool runHelper();
+ bool runHelper() override;
protected:
- void run() final;
void dispatchHits(RayCaster *rayCaster, const PickingUtils::HitList &sphereHits);
private:
- NodeManagers *m_manager;
- Entity *m_node;
- FrameGraphNode *m_frameGraphRoot;
- RenderSettings *m_renderSettings;
-
bool m_castersDirty;
bool m_oneEnabledAtLeast;
};
diff --git a/src/render/picking/picking.pri b/src/render/picking/picking.pri
index 88e6f2529..89c549de0 100644
--- a/src/render/picking/picking.pri
+++ b/src/render/picking/picking.pri
@@ -10,9 +10,11 @@ HEADERS += \
$$PWD/objectpicker_p.h \
$$PWD/pickeventfilter_p.h \
$$PWD/qobjectpicker_p.h \
+ $$PWD/qabstractraycaster.h \
+ $$PWD/qabstractraycaster_p.h \
$$PWD/qraycasterhit.h \
$$PWD/qraycaster.h \
- $$PWD/qraycaster_p.h \
+ $$PWD/qscreenraycaster.h \
$$PWD/raycaster_p.h
SOURCES += \
@@ -23,6 +25,8 @@ SOURCES += \
$$PWD/qpicktriangleevent.cpp \
$$PWD/objectpicker.cpp \
$$PWD/pickeventfilter.cpp \
+ $$PWD/qabstractraycaster.cpp \
$$PWD/qraycasterhit.cpp \
$$PWD/qraycaster.cpp \
+ $$PWD/qscreenraycaster.cpp \
$$PWD/raycaster.cpp
diff --git a/src/render/picking/qabstractraycaster.cpp b/src/render/picking/qabstractraycaster.cpp
new file mode 100644
index 000000000..5f29b1956
--- /dev/null
+++ b/src/render/picking/qabstractraycaster.cpp
@@ -0,0 +1,153 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 Klaralvdalens Datakonsult AB (KDAB).
+** 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$
+**
+****************************************************************************/
+
+#include "qabstractraycaster.h"
+#include "qabstractraycaster_p.h"
+#include <Qt3DCore/qentity.h>
+#include <Qt3DCore/qpropertyupdatedchange.h>
+#include <Qt3DCore/private/qcomponent_p.h>
+#include <Qt3DCore/private/qscene_p.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3DRender {
+
+QAbstractRayCasterPrivate::QAbstractRayCasterPrivate()
+ : QComponentPrivate()
+{
+ m_enabled = false;
+}
+
+QAbstractRayCasterPrivate *QAbstractRayCasterPrivate::get(QAbstractRayCaster *obj)
+{
+ return obj->d_func();
+}
+
+const QAbstractRayCasterPrivate *QAbstractRayCasterPrivate::get(const QAbstractRayCaster *obj)
+{
+ return obj->d_func();
+}
+
+void QAbstractRayCasterPrivate::updateHitEntites(QAbstractRayCaster::Hits &hits, Qt3DCore::QScene *scene)
+{
+ for (int i = 0; i < hits.size(); i++)
+ hits[i].setEntity(qobject_cast<Qt3DCore::QEntity *>(scene->lookupNode(hits[i].entityId())));
+}
+
+void QAbstractRayCasterPrivate::dispatchHits(const QAbstractRayCaster::Hits &hits)
+{
+ Q_Q(QAbstractRayCaster);
+ m_hits = hits;
+ updateHitEntites(m_hits, m_scene);
+ bool v = q->blockNotifications(true);
+ emit q->hitsChanged(m_hits);
+ q->blockNotifications(v);
+}
+
+
+QAbstractRayCaster::QAbstractRayCaster(Qt3DCore::QNode *parent)
+ : Qt3DCore::QComponent(*new QAbstractRayCasterPrivate(), parent)
+{
+}
+
+QAbstractRayCaster::QAbstractRayCaster(QAbstractRayCasterPrivate &dd, Qt3DCore::QNode *parent)
+ : Qt3DCore::QComponent(dd, parent)
+{
+}
+
+/*! \internal */
+QAbstractRayCaster::~QAbstractRayCaster()
+{
+}
+
+QAbstractRayCaster::RunMode QAbstractRayCaster::runMode() const
+{
+ Q_D(const QAbstractRayCaster);
+ return d->m_runMode;
+}
+
+void QAbstractRayCaster::setRunMode(QAbstractRayCaster::RunMode runMode)
+{
+ Q_D(QAbstractRayCaster);
+ if (d->m_runMode != runMode) {
+ d->m_runMode = runMode;
+ emit runModeChanged(d->m_runMode);
+ }
+}
+
+QAbstractRayCaster::Hits QAbstractRayCaster::hits() const
+{
+ Q_D(const QAbstractRayCaster);
+ return d->m_hits;
+}
+
+/*! \internal */
+void QAbstractRayCaster::sceneChangeEvent(const Qt3DCore::QSceneChangePtr &change)
+{
+ Q_D(QAbstractRayCaster);
+ Qt3DCore::QPropertyUpdatedChangePtr e = qSharedPointerCast<Qt3DCore::QPropertyUpdatedChange>(change);
+ if (e->type() == Qt3DCore::PropertyUpdated) {
+ const QByteArray propertyName = e->propertyName();
+ if (propertyName == QByteArrayLiteral("hits")) {
+ Hits hits = e->value().value<Hits>();
+ d->dispatchHits(hits);
+ }
+ }
+
+ QComponent::sceneChangeEvent(change);
+}
+
+/*! \internal */
+Qt3DCore::QNodeCreatedChangeBasePtr QAbstractRayCaster::createNodeCreationChange() const
+{
+ auto creationChange = Qt3DCore::QNodeCreatedChangePtr<QAbstractRayCasterData>::create(this);
+ auto &data = creationChange->data;
+ Q_D(const QAbstractRayCaster);
+ data.casterType = d->m_rayCasterType;
+ data.runMode = d->m_runMode;
+ data.origin = d->m_origin;
+ data.direction = d->m_direction;
+ data.length = d->m_length;
+ data.position = d->m_position;
+ return creationChange;
+}
+
+} // Qt3DRender
+
+QT_END_NAMESPACE
diff --git a/src/render/picking/qabstractraycaster.h b/src/render/picking/qabstractraycaster.h
new file mode 100644
index 000000000..3d6357ce8
--- /dev/null
+++ b/src/render/picking/qabstractraycaster.h
@@ -0,0 +1,98 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 Klaralvdalens Datakonsult AB (KDAB).
+** 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$
+**
+****************************************************************************/
+
+#ifndef QT3DRENDER_QABSTRACTRAYCASTER_H
+#define QT3DRENDER_QABSTRACTRAYCASTER_H
+
+#include <Qt3DCore/qcomponent.h>
+#include <Qt3DRender/qraycasterhit.h>
+#include <Qt3DRender/qt3drender_global.h>
+
+#include <QtGui/QVector3D>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3DRender {
+
+class QAbstractRayCasterPrivate;
+
+class QT3DRENDERSHARED_EXPORT QAbstractRayCaster : public Qt3DCore::QComponent
+{
+ Q_OBJECT
+ Q_PROPERTY(RunMode runMode READ runMode WRITE setRunMode NOTIFY runModeChanged)
+ Q_PROPERTY(Hits hits READ hits NOTIFY hitsChanged)
+
+public:
+ enum RunMode {
+ Continuous,
+ SingleShot
+ };
+ Q_ENUM(RunMode)
+
+ using Hits = QVector<QRayCasterHit>;
+
+ explicit QAbstractRayCaster(QNode *parent = nullptr);
+ ~QAbstractRayCaster();
+
+ RunMode runMode() const;
+ Hits hits() const;
+
+public Q_SLOTS:
+ void setRunMode(RunMode runMode);
+
+Q_SIGNALS:
+ void runModeChanged(RunMode runMode);
+ void hitsChanged(const Hits &hits);
+
+protected:
+ explicit QAbstractRayCaster(QAbstractRayCasterPrivate &dd, QNode *parent = nullptr);
+ void sceneChangeEvent(const Qt3DCore::QSceneChangePtr &change) override;
+ Qt3DCore::QNodeCreatedChangeBasePtr createNodeCreationChange() const override;
+
+private:
+ Q_DECLARE_PRIVATE(QAbstractRayCaster)
+};
+
+} // Qt3D
+
+QT_END_NAMESPACE
+
+Q_DECLARE_METATYPE(Qt3DRender::QAbstractRayCaster::Hits) // LCOV_EXCL_LINE
+
+#endif // QT3DRENDER_QABSTRACTRAYCASTER_H
diff --git a/src/render/picking/qraycaster_p.h b/src/render/picking/qabstractraycaster_p.h
index c04a63368..cca95b4d6 100644
--- a/src/render/picking/qraycaster_p.h
+++ b/src/render/picking/qabstractraycaster_p.h
@@ -34,8 +34,8 @@
**
****************************************************************************/
-#ifndef QT3DRENDER_QRAYCASTER_P_H
-#define QT3DRENDER_QRAYCASTER_P_H
+#ifndef QT3DRENDER_QABSTRACTRAYCASTER_P_H
+#define QT3DRENDER_QABSTRACTRAYCASTER_P_H
//
// W A R N I N G
@@ -50,7 +50,7 @@
#include <Qt3DCore/private/qcomponent_p.h>
#include <Qt3DCore/qnodeid.h>
-#include <Qt3DRender/QRayCaster>
+#include <Qt3DRender/QAbstractRayCaster>
#include <Qt3DRender/private/qt3drender_global_p.h>
#include <QtGui/QVector3D>
@@ -62,28 +62,38 @@ namespace Qt3DRender {
/*!
\internal
*/
-class QT3DRENDERSHARED_PRIVATE_EXPORT QRayCasterPrivate : public Qt3DCore::QComponentPrivate
+class QT3DRENDERSHARED_PRIVATE_EXPORT QAbstractRayCasterPrivate : public Qt3DCore::QComponentPrivate
{
public:
- QRayCasterPrivate()
- : QComponentPrivate()
- {
- }
+ QAbstractRayCasterPrivate();
- QRayCaster::RunMode m_runMode = QRayCaster::SingleShot;
+ enum RayCasterType {
+ WorldSpaceRayCaster,
+ ScreenScapeRayCaster
+ };
+
+ static QAbstractRayCasterPrivate *get(QAbstractRayCaster *obj);
+ static const QAbstractRayCasterPrivate *get(const QAbstractRayCaster *obj);
+ static void updateHitEntites(QAbstractRayCaster::Hits &hits, Qt3DCore::QScene *scene);
+
+ RayCasterType m_rayCasterType = WorldSpaceRayCaster;
+ QAbstractRayCaster::RunMode m_runMode = QAbstractRayCaster::SingleShot;
+ QAbstractRayCaster::Hits m_hits;
+ QPoint m_position;
QVector3D m_origin;
- QVector3D m_direction = QVector3D(0.f, 0.f, 1.f);
+ QVector3D m_direction = QVector3D(0., 0., 1.f);
float m_length = 0.f;
- QRayCaster::Hits m_hits;
- virtual void dispatchHits(const QRayCaster::Hits &hits);
+ virtual void dispatchHits(const QAbstractRayCaster::Hits &hits);
- Q_DECLARE_PUBLIC(QRayCaster)
+ Q_DECLARE_PUBLIC(QAbstractRayCaster)
};
-struct QRayCasterData
+struct QAbstractRayCasterData
{
- QRayCaster::RunMode runMode;
+ QAbstractRayCaster::RunMode runMode;
+ QAbstractRayCasterPrivate::RayCasterType casterType;
+ QPoint position;
QVector3D origin;
QVector3D direction;
float length = 0.f;
@@ -93,4 +103,4 @@ struct QRayCasterData
QT_END_NAMESPACE
-#endif // QT3DRENDER_QRAYCASTER_P_H
+#endif // QT3DRENDER_QABSTRACTRAYCASTER_P_H
diff --git a/src/render/picking/qraycaster.cpp b/src/render/picking/qraycaster.cpp
index 2eba29b59..7f969e683 100644
--- a/src/render/picking/qraycaster.cpp
+++ b/src/render/picking/qraycaster.cpp
@@ -38,7 +38,7 @@
****************************************************************************/
#include "qraycaster.h"
-#include "qraycaster_p.h"
+#include "qabstractraycaster_p.h"
#include <Qt3DCore/qentity.h>
#include <Qt3DCore/qpropertyupdatedchange.h>
#include <Qt3DCore/private/qcomponent_p.h>
@@ -48,17 +48,6 @@ QT_BEGIN_NAMESPACE
namespace Qt3DRender {
-void QRayCasterPrivate::dispatchHits(const QRayCaster::Hits &hits)
-{
- Q_Q(QRayCaster);
- m_hits = hits;
- for (int i = 0; i < m_hits.size(); i++)
- m_hits[i].setEntity(qobject_cast<Qt3DCore::QEntity *>(m_scene->lookupNode(m_hits[i].entityId())));
- bool v = q->blockNotifications(true);
- emit q->hitsChanged(m_hits);
- q->blockNotifications(v);
-}
-
/*!
\class Qt3DRender::QRayCaster
\inmodule Qt3DRender
@@ -80,13 +69,15 @@ void QRayCasterPrivate::dispatchHits(const QRayCaster::Hits &hits)
QRayCaster::QRayCaster(Qt3DCore::QNode *parent)
- : Qt3DCore::QComponent(*new QRayCasterPrivate(), parent)
+ : QAbstractRayCaster(parent)
{
+ QAbstractRayCasterPrivate::get(this)->m_rayCasterType = QAbstractRayCasterPrivate::WorldSpaceRayCaster;
}
-QRayCaster::QRayCaster(QRayCasterPrivate &dd, Qt3DCore::QNode *parent)
- : Qt3DCore::QComponent(dd, parent)
+QRayCaster::QRayCaster(QAbstractRayCasterPrivate &dd, Qt3DCore::QNode *parent)
+ : QAbstractRayCaster(dd, parent)
{
+ QAbstractRayCasterPrivate::get(this)->m_rayCasterType = QAbstractRayCasterPrivate::WorldSpaceRayCaster;
}
/*! \internal */
@@ -94,30 +85,15 @@ QRayCaster::~QRayCaster()
{
}
-QRayCaster::RunMode QRayCaster::runMode() const
-{
- Q_D(const QRayCaster);
- return d->m_runMode;
-}
-
-void QRayCaster::setRunMode(QRayCaster::RunMode runMode)
-{
- Q_D(QRayCaster);
- if (d->m_runMode != runMode) {
- d->m_runMode = runMode;
- emit runModeChanged(d->m_runMode);
- }
-}
-
QVector3D QRayCaster::origin() const
{
- Q_D(const QRayCaster);
+ auto d = QAbstractRayCasterPrivate::get(this);
return d->m_origin;
}
void QRayCaster::setOrigin(const QVector3D &origin)
{
- Q_D(QRayCaster);
+ auto d = QAbstractRayCasterPrivate::get(this);
if (d->m_origin != origin) {
d->m_origin = origin;
emit originChanged(d->m_origin);
@@ -126,13 +102,13 @@ void QRayCaster::setOrigin(const QVector3D &origin)
QVector3D QRayCaster::direction() const
{
- Q_D(const QRayCaster);
+ auto d = QAbstractRayCasterPrivate::get(this);
return d->m_direction;
}
void QRayCaster::setDirection(const QVector3D &direction)
{
- Q_D(QRayCaster);
+ auto d = QAbstractRayCasterPrivate::get(this);
if (d->m_direction != direction) {
d->m_direction = direction;
emit directionChanged(d->m_direction);
@@ -141,25 +117,19 @@ void QRayCaster::setDirection(const QVector3D &direction)
float QRayCaster::length() const
{
- Q_D(const QRayCaster);
+ auto d = QAbstractRayCasterPrivate::get(this);
return d->m_length;
}
void QRayCaster::setLength(float length)
{
- Q_D(QRayCaster);
+ auto d = QAbstractRayCasterPrivate::get(this);
if (!qFuzzyCompare(d->m_length, length)) {
d->m_length = length;
emit lengthChanged(d->m_length);
}
}
-QRayCaster::Hits QRayCaster::hits() const
-{
- Q_D(const QRayCaster);
- return d->m_hits;
-}
-
void QRayCaster::trigger()
{
setEnabled(true);
@@ -174,35 +144,6 @@ void QRayCaster::trigger(const QVector3D &origin, const QVector3D &direction, fl
setEnabled(true);
}
-/*! \internal */
-void QRayCaster::sceneChangeEvent(const Qt3DCore::QSceneChangePtr &change)
-{
- Q_D(QRayCaster);
- Qt3DCore::QPropertyUpdatedChangePtr e = qSharedPointerCast<Qt3DCore::QPropertyUpdatedChange>(change);
- if (e->type() == Qt3DCore::PropertyUpdated) {
- const QByteArray propertyName = e->propertyName();
- if (propertyName == QByteArrayLiteral("hits")) {
- Hits hits = e->value().value<Hits>();
- d->dispatchHits(hits);
- }
- }
-
- QComponent::sceneChangeEvent(change);
-}
-
-/*! \internal */
-Qt3DCore::QNodeCreatedChangeBasePtr QRayCaster::createNodeCreationChange() const
-{
- auto creationChange = Qt3DCore::QNodeCreatedChangePtr<QRayCasterData>::create(this);
- auto &data = creationChange->data;
- Q_D(const QRayCaster);
- data.runMode = d->m_runMode;
- data.origin = d->m_origin;
- data.direction = d->m_direction;
- data.length = d->m_length;
- return creationChange;
-}
-
} // Qt3DRender
QT_END_NAMESPACE
diff --git a/src/render/picking/qraycaster.h b/src/render/picking/qraycaster.h
index d7d988836..da269d56e 100644
--- a/src/render/picking/qraycaster.h
+++ b/src/render/picking/qraycaster.h
@@ -40,9 +40,8 @@
#ifndef QT3DRENDER_QRAYCASTER_H
#define QT3DRENDER_QRAYCASTER_H
-#include <Qt3DCore/qcomponent.h>
#include <Qt3DRender/qt3drender_global.h>
-#include <Qt3DRender/qraycasterhit.h>
+#include <Qt3DRender/QAbstractRayCaster>
#include <QtGui/QVector3D>
@@ -50,37 +49,22 @@ QT_BEGIN_NAMESPACE
namespace Qt3DRender {
-class QRayCasterPrivate;
-
-class QT3DRENDERSHARED_EXPORT QRayCaster : public Qt3DCore::QComponent
+class QT3DRENDERSHARED_EXPORT QRayCaster : public QAbstractRayCaster
{
Q_OBJECT
- Q_PROPERTY(RunMode runMode READ runMode WRITE setRunMode NOTIFY runModeChanged)
Q_PROPERTY(QVector3D origin READ origin WRITE setOrigin NOTIFY originChanged)
Q_PROPERTY(QVector3D direction READ direction WRITE setDirection NOTIFY directionChanged)
Q_PROPERTY(float length READ length WRITE setLength NOTIFY lengthChanged)
- Q_PROPERTY(Hits hits READ hits NOTIFY hitsChanged)
public:
- enum RunMode {
- Continuous,
- SingleShot
- };
- Q_ENUM(RunMode)
-
- using Hits = QVector<QRayCasterHit>;
-
explicit QRayCaster(QNode *parent = nullptr);
~QRayCaster();
- RunMode runMode() const;
QVector3D origin() const;
QVector3D direction() const;
float length() const;
- Hits hits() const;
public Q_SLOTS:
- void setRunMode(RunMode runMode);
void setOrigin(const QVector3D& origin);
void setDirection(const QVector3D& direction);
void setLength(float length);
@@ -89,25 +73,16 @@ public Q_SLOTS:
void trigger(const QVector3D& origin, const QVector3D& direction, float length = -1.f);
Q_SIGNALS:
- void runModeChanged(RunMode runMode);
void originChanged(const QVector3D &origin);
void directionChanged(const QVector3D &direction);
void lengthChanged(float length);
- void hitsChanged(const Hits &hits);
protected:
- explicit QRayCaster(QRayCasterPrivate &dd, QNode *parent = nullptr);
- void sceneChangeEvent(const Qt3DCore::QSceneChangePtr &change) override;
-
-private:
- Q_DECLARE_PRIVATE(QRayCaster)
- Qt3DCore::QNodeCreatedChangeBasePtr createNodeCreationChange() const override;
+ explicit QRayCaster(QAbstractRayCasterPrivate &dd, QNode *parent = nullptr);
};
} // Qt3D
QT_END_NAMESPACE
-Q_DECLARE_METATYPE(Qt3DRender::QRayCaster::Hits) // LCOV_EXCL_LINE
-
#endif // QT3DRENDER_QRAYCASTER_H
diff --git a/src/render/picking/qraycasterhit.h b/src/render/picking/qraycasterhit.h
index c1fa38635..4764994df 100644
--- a/src/render/picking/qraycasterhit.h
+++ b/src/render/picking/qraycasterhit.h
@@ -51,7 +51,7 @@ QT_BEGIN_NAMESPACE
namespace Qt3DRender {
class QRayCasterHitData;
-class QRayCasterPrivate;
+class QAbstractRayCasterPrivate;
class QT3DRENDERSHARED_EXPORT QRayCasterHit
{
@@ -86,7 +86,7 @@ public:
uint vertex3Index() const;
private:
- friend class QRayCasterPrivate;
+ friend class QAbstractRayCasterPrivate;
void setEntity(Qt3DCore::QEntity *entity) const;
QSharedDataPointer<QRayCasterHitData> d;
diff --git a/src/render/picking/qscreenraycaster.cpp b/src/render/picking/qscreenraycaster.cpp
new file mode 100644
index 000000000..5dd1420c8
--- /dev/null
+++ b/src/render/picking/qscreenraycaster.cpp
@@ -0,0 +1,116 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 Klaralvdalens Datakonsult AB (KDAB).
+** 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$
+**
+****************************************************************************/
+
+#include "qscreenraycaster.h"
+#include "qabstractraycaster_p.h"
+#include <Qt3DCore/qentity.h>
+#include <Qt3DCore/qpropertyupdatedchange.h>
+#include <Qt3DCore/private/qcomponent_p.h>
+#include <Qt3DCore/private/qscene_p.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3DRender {
+
+/*!
+ \class Qt3DRender::QScreenRayCaster
+ \inmodule Qt3DRender
+
+ \brief The QScreenRayCaster...
+
+ \sa Qt3DRender::QPickingSettings, Qt3DRender::QObjectPicker
+
+ \since 5.11
+*/
+
+/*!
+ \qmltype ScreenRayCaster
+ \instantiates Qt3DRender::QScreenRayCaster
+ \inqmlmodule Qt3D.Render
+ \brief The ScreenRayCaster
+ \sa PickingSettings, ObjectPicker
+ */
+
+
+QScreenRayCaster::QScreenRayCaster(Qt3DCore::QNode *parent)
+ : QAbstractRayCaster(parent)
+{
+ QAbstractRayCasterPrivate::get(this)->m_rayCasterType = QAbstractRayCasterPrivate::ScreenScapeRayCaster;
+}
+
+QScreenRayCaster::QScreenRayCaster(QAbstractRayCasterPrivate &dd, Qt3DCore::QNode *parent)
+ : QAbstractRayCaster(dd, parent)
+{
+ QAbstractRayCasterPrivate::get(this)->m_rayCasterType = QAbstractRayCasterPrivate::ScreenScapeRayCaster;
+}
+
+/*! \internal */
+QScreenRayCaster::~QScreenRayCaster()
+{
+}
+
+QPoint QScreenRayCaster::position() const
+{
+ auto d = QAbstractRayCasterPrivate::get(this);
+ return d->m_position;
+}
+
+void QScreenRayCaster::setPosition(const QPoint &position)
+{
+ auto d = QAbstractRayCasterPrivate::get(this);
+ if (d->m_position != position) {
+ d->m_position = position;
+ emit positionChanged(d->m_position);
+ }
+}
+
+void QScreenRayCaster::trigger()
+{
+ setEnabled(true);
+}
+
+void QScreenRayCaster::trigger(const QPoint &position)
+{
+ setPosition(position);
+ setEnabled(true);
+}
+
+} // Qt3DRender
+
+QT_END_NAMESPACE
diff --git a/src/render/picking/qscreenraycaster.h b/src/render/picking/qscreenraycaster.h
new file mode 100644
index 000000000..09ad94374
--- /dev/null
+++ b/src/render/picking/qscreenraycaster.h
@@ -0,0 +1,80 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 Klaralvdalens Datakonsult AB (KDAB).
+** 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$
+**
+****************************************************************************/
+
+#ifndef QT3DRENDER_QSCREENRAYCASTER_H
+#define QT3DRENDER_QSCREENRAYCASTER_H
+
+#include <Qt3DRender/qt3drender_global.h>
+#include <Qt3DRender/QAbstractRayCaster>
+
+#include <QtGui/QVector3D>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3DRender {
+
+class QT3DRENDERSHARED_EXPORT QScreenRayCaster : public QAbstractRayCaster
+{
+ Q_OBJECT
+
+ Q_PROPERTY(QPoint position READ position WRITE setPosition NOTIFY positionChanged)
+public:
+ explicit QScreenRayCaster(QNode *parent = nullptr);
+ ~QScreenRayCaster();
+
+ QPoint position() const;
+
+public Q_SLOTS:
+ void setPosition(const QPoint &position);
+
+ void trigger();
+ void trigger(const QPoint &position);
+
+Q_SIGNALS:
+ void positionChanged(const QPoint &position);
+
+protected:
+ explicit QScreenRayCaster(QAbstractRayCasterPrivate &dd, QNode *parent = nullptr);
+};
+
+} // Qt3D
+
+QT_END_NAMESPACE
+
+#endif // QT3DRENDER_QSCREENRAYCASTER_H
diff --git a/src/render/picking/raycaster.cpp b/src/render/picking/raycaster.cpp
index 38e69d7a5..f203a9d53 100644
--- a/src/render/picking/raycaster.cpp
+++ b/src/render/picking/raycaster.cpp
@@ -40,8 +40,8 @@
#include "raycaster_p.h"
#include "qpickevent.h"
#include "renderer_p.h"
-#include <Qt3DRender/qraycaster.h>
-#include <Qt3DRender/private/qraycaster_p.h>
+#include <Qt3DRender/qabstractraycaster.h>
+#include <Qt3DRender/private/qabstractraycaster_p.h>
#include <Qt3DRender/private/raycastingjob_p.h>
#include <Qt3DRender/qattribute.h>
#include <Qt3DCore/qpropertyupdatedchange.h>
@@ -62,7 +62,12 @@ RayCaster::~RayCaster()
notifyJob();
}
-QRayCaster::RunMode RayCaster::runMode() const
+QAbstractRayCasterPrivate::RayCasterType RayCaster::type() const
+{
+ return m_type;
+}
+
+QAbstractRayCaster::RunMode RayCaster::runMode() const
{
return m_runMode;
}
@@ -82,24 +87,33 @@ float RayCaster::length() const
return m_length;
}
+QPoint RayCaster::position() const
+{
+ return m_position;
+}
+
void RayCaster::cleanup()
{
BackendNode::setEnabled(false);
- m_runMode = QRayCaster::SingleShot;
+ m_type = QAbstractRayCasterPrivate::WorldSpaceRayCaster;
+ m_runMode = QAbstractRayCaster::SingleShot;
m_direction = QVector3D(0.f, 0.f, 1.f);
m_origin = {};
m_length = 0.f;
+ m_position = {};
notifyJob();
}
void RayCaster::initializeFromPeer(const Qt3DCore::QNodeCreatedChangeBasePtr &change)
{
- const auto typedChange = qSharedPointerCast<Qt3DCore::QNodeCreatedChange<QRayCasterData>>(change);
+ const auto typedChange = qSharedPointerCast<Qt3DCore::QNodeCreatedChange<QAbstractRayCasterData>>(change);
const auto &data = typedChange->data;
+ m_type = data.casterType;
m_runMode = data.runMode;
m_origin = data.origin;
m_direction = data.direction;
m_length = data.length;
+ m_position = data.position;
}
void RayCaster::sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e)
@@ -113,8 +127,10 @@ void RayCaster::sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e)
m_direction = propertyChange->value().value<QVector3D>();
} else if (propertyChange->propertyName() == QByteArrayLiteral("length")) {
m_length = propertyChange->value().toFloat();
+ } else if (propertyChange->propertyName() == QByteArrayLiteral("position")) {
+ m_position = propertyChange->value().toPoint();
} else if (propertyChange->propertyName() == QByteArrayLiteral("runMode")) {
- m_runMode = propertyChange->value().value<QRayCaster::RunMode>();
+ m_runMode = propertyChange->value().value<QAbstractRayCaster::RunMode>();
}
notifyJob();
@@ -124,7 +140,7 @@ void RayCaster::sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e)
BackendNode::sceneChangeEvent(e);
}
-void RayCaster::dispatchHits(const QRayCaster::Hits &hits)
+void RayCaster::dispatchHits(const QAbstractRayCaster::Hits &hits)
{
auto e = Qt3DCore::QPropertyUpdatedChangePtr::create(peerId());
e->setDeliveryFlags(Qt3DCore::QSceneChange::DeliverToAll);
@@ -132,7 +148,7 @@ void RayCaster::dispatchHits(const QRayCaster::Hits &hits)
e->setValue(QVariant::fromValue(hits));
notifyObservers(e);
- if (m_runMode == QRayCaster::SingleShot) {
+ if (m_runMode == QAbstractRayCaster::SingleShot) {
setEnabled(false);
auto e = Qt3DCore::QPropertyUpdatedChangePtr::create(peerId());
e->setDeliveryFlags(Qt3DCore::QSceneChange::DeliverToAll);
diff --git a/src/render/picking/raycaster_p.h b/src/render/picking/raycaster_p.h
index 1cefb5bea..ff577a565 100644
--- a/src/render/picking/raycaster_p.h
+++ b/src/render/picking/raycaster_p.h
@@ -52,7 +52,9 @@
//
#include <Qt3DRender/private/backendnode_p.h>
-#include <Qt3DRender/qraycaster.h>
+#include <Qt3DRender/qabstractraycaster.h>
+#include <Qt3DRender/private/qabstractraycaster_p.h>
+
QT_BEGIN_NAMESPACE
@@ -68,24 +70,28 @@ public:
RayCaster();
~RayCaster();
- QRayCaster::RunMode runMode() const;
+ QAbstractRayCasterPrivate::RayCasterType type() const;
+ QAbstractRayCaster::RunMode runMode() const;
QVector3D origin() const;
QVector3D direction() const;
float length() const;
+ QPoint position() const;
void cleanup();
void sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e) final;
- void dispatchHits(const QRayCaster::Hits &hits);
+ void dispatchHits(const QAbstractRayCaster::Hits &hits);
private:
void initializeFromPeer(const Qt3DCore::QNodeCreatedChangeBasePtr &change) final;
void notifyJob();
- QRayCaster::RunMode m_runMode = QRayCaster::SingleShot;
+ QAbstractRayCasterPrivate::RayCasterType m_type = QAbstractRayCasterPrivate::WorldSpaceRayCaster;
+ QAbstractRayCaster::RunMode m_runMode = QAbstractRayCaster::SingleShot;
QVector3D m_origin;
QVector3D m_direction = {0.f, 0.f, 1.f};
float m_length = 0.f;
+ QPoint m_position;
};
} // Render
diff --git a/tests/auto/render/raycasting/tst_raycasting.cpp b/tests/auto/render/raycasting/tst_raycasting.cpp
index 50e33e272..0f3d04962 100644
--- a/tests/auto/render/raycasting/tst_raycasting.cpp
+++ b/tests/auto/render/raycasting/tst_raycasting.cpp
@@ -31,7 +31,7 @@
#include <Qt3DRender/private/qraycastingservice_p.h>
#include <Qt3DRender/private/sphere_p.h>
#include <Qt3DRender/private/entity_p.h>
-#include <Qt3DRender/private/pickboundingvolumejob_p.h>
+#include <Qt3DRender/private/abstractpickingjob_p.h>
#include <Qt3DRender/private/qboundingvolumeprovider_p.h>
#include <Qt3DRender/private/qray3d_p.h>
#include <Qt3DRender/qcamera.h>
@@ -324,7 +324,7 @@ void tst_RayCasting::mousePicking()
const QRectF viewport(0.0f, 0.0f, 800.0f, 600.0f);
// Window center on near plane
- QRay3D ray = Qt3DRender::Render::PickBoundingVolumeJob::intersectionRay(viewport.center().toPoint(),
+ QRay3D ray = Qt3DRender::Render::AbstractPickingJob::intersectionRay(viewport.center().toPoint(),
camera.viewMatrix(),
camera.projectionMatrix(),
viewport.toRect());
@@ -337,7 +337,7 @@ void tst_RayCasting::mousePicking()
QVERIFY(intersects);
// WHEN
- ray = Qt3DRender::Render::PickBoundingVolumeJob::intersectionRay(viewport.topLeft().toPoint(),
+ ray = Qt3DRender::Render::AbstractPickingJob::intersectionRay(viewport.topLeft().toPoint(),
camera.viewMatrix(),
camera.projectionMatrix(),
viewport.toRect());
@@ -347,7 +347,7 @@ void tst_RayCasting::mousePicking()
QVERIFY(!intersects);
// WHEN
- ray = Qt3DRender::Render::PickBoundingVolumeJob::intersectionRay(viewport.topRight().toPoint(),
+ ray = Qt3DRender::Render::AbstractPickingJob::intersectionRay(viewport.topRight().toPoint(),
camera.viewMatrix(),
camera.projectionMatrix(),
viewport.toRect());
@@ -357,7 +357,7 @@ void tst_RayCasting::mousePicking()
QVERIFY(!intersects);
// WHEN
- ray = Qt3DRender::Render::PickBoundingVolumeJob::intersectionRay(viewport.bottomLeft().toPoint(),
+ ray = Qt3DRender::Render::AbstractPickingJob::intersectionRay(viewport.bottomLeft().toPoint(),
camera.viewMatrix(),
camera.projectionMatrix(),
viewport.toRect());
@@ -367,7 +367,7 @@ void tst_RayCasting::mousePicking()
QVERIFY(!intersects);
// WHEN
- ray = Qt3DRender::Render::PickBoundingVolumeJob::intersectionRay(viewport.bottomRight().toPoint(),
+ ray = Qt3DRender::Render::AbstractPickingJob::intersectionRay(viewport.bottomRight().toPoint(),
camera.viewMatrix(),
camera.projectionMatrix(),
viewport.toRect());