1// Copyright (C) 2015 Klaralvdalens Datakonsult AB (KDAB).
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QT3DRENDER_QABSTRACTCOLLISIONQUERYSERVICE_P_H
5#define QT3DRENDER_QABSTRACTCOLLISIONQUERYSERVICE_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists for the convenience
12// of other Qt classes. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QList>
19
20#include <Qt3DRender/qt3drender_global.h>
21#include <Qt3DCore/private/qservicelocator_p.h>
22#include <Qt3DCore/qnodeid.h>
23#include <Qt3DCore/private/qabstractserviceprovider_p.h>
24#include <Qt3DRender/private/qcollisionqueryresult_p.h>
25
26QT_BEGIN_NAMESPACE
27
28namespace Qt3DRender {
29namespace RayCasting {
30
31class QRay3D;
32class QBoundingVolume;
33class QBoundingVolumeProvider;
34
35class QAbstractCollisionQueryServicePrivate : public Qt3DCore::QAbstractServiceProviderPrivate
36{
37public:
38 QAbstractCollisionQueryServicePrivate(const QString &description)
39 : QAbstractServiceProviderPrivate(Qt3DCore::QServiceLocator::CollisionService, description)
40 {}
41};
42
43class Q_3DRENDERSHARED_EXPORT QAbstractCollisionQueryService : public Qt3DCore::QAbstractServiceProvider
44{
45 Q_OBJECT
46public:
47 enum QueryMode {
48 FirstHit,
49 AllHits
50 };
51
52 virtual QQueryHandle query(const QRay3D &ray, QueryMode mode, QBoundingVolumeProvider *provider) = 0;
53 virtual QCollisionQueryResult::Hit query(const QRay3D &ray, const QBoundingVolume* volume) = 0;
54
55 virtual QCollisionQueryResult fetchResult(const QQueryHandle &handle) = 0;
56 virtual QList<QCollisionQueryResult> fetchAllResults() const = 0;
57
58protected:
59 QAbstractCollisionQueryService(const QString &description = QString());
60 QAbstractCollisionQueryService(QAbstractCollisionQueryServicePrivate &dd);
61
62 void setResultHandle(QCollisionQueryResult &result, const QQueryHandle &handle);
63 void addEntityHit(QCollisionQueryResult &result, Qt3DCore::QNodeId entity, const Vector3D &intersection,
64 float distance, const Vector3D &uvw);
65
66private:
67 Q_DECLARE_PRIVATE(QAbstractCollisionQueryService)
68};
69
70} // RayCasting
71} // Qt3DRender
72
73QT_END_NAMESPACE
74
75Q_DECLARE_METATYPE(Qt3DRender::RayCasting::QAbstractCollisionQueryService::QueryMode) // LCOV_EXCL_LINE
76
77#endif // QT3DRENDER_QABSTRACTCOLLISIONQUERYSERVICE_P_H
78

source code of qt3d/src/render/raycasting/qabstractcollisionqueryservice_p.h