1// Copyright (C) 2018 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_QRAYCASTERHIT_H
5#define QT3DRENDER_QRAYCASTERHIT_H
6
7#include <Qt3DCore/qcomponent.h>
8#include <Qt3DCore/qentity.h>
9#include <Qt3DRender/qt3drender_global.h>
10
11#include <QtCore/QSharedData>
12#include <QtGui/QVector3D>
13
14QT_BEGIN_NAMESPACE
15
16namespace Qt3DRender {
17
18class QRayCasterHitData;
19class QAbstractRayCasterPrivate;
20
21class Q_3DRENDERSHARED_EXPORT QRayCasterHit
22{
23 Q_GADGET
24 Q_PROPERTY(QRayCasterHit::HitType type READ type CONSTANT)
25 Q_PROPERTY(Qt3DCore::QNodeId entityId READ entityId CONSTANT)
26 Q_PROPERTY(Qt3DCore::QEntity *entity READ entity CONSTANT)
27 Q_PROPERTY(float distance READ distance CONSTANT)
28 Q_PROPERTY(QVector3D localIntersection READ localIntersection CONSTANT)
29 Q_PROPERTY(QVector3D worldIntersection READ worldIntersection CONSTANT)
30 Q_PROPERTY(uint primitiveIndex READ primitiveIndex CONSTANT)
31 Q_PROPERTY(uint vertex1Index READ vertex1Index CONSTANT)
32 Q_PROPERTY(uint vertex2Index READ vertex2Index CONSTANT)
33 Q_PROPERTY(uint vertex3Index READ vertex3Index CONSTANT)
34public:
35 enum HitType {
36 TriangleHit,
37 LineHit,
38 PointHit,
39 EntityHit
40 };
41 Q_ENUM(HitType)
42
43 QRayCasterHit();
44 explicit QRayCasterHit(QRayCasterHit::HitType type, Qt3DCore::QNodeId id, float distance,
45 const QVector3D &localIntersect, const QVector3D &worldIntersect,
46 uint primitiveIndex, uint v1, uint v2, uint v3);
47 QRayCasterHit(const QRayCasterHit &other);
48 ~QRayCasterHit();
49
50 QRayCasterHit &operator =(const QRayCasterHit &other);
51
52 HitType type() const;
53 Qt3DCore::QNodeId entityId() const;
54 Qt3DCore::QEntity *entity() const;
55 float distance() const;
56 QVector3D localIntersection() const;
57 QVector3D worldIntersection() const;
58 uint primitiveIndex() const;
59 uint vertex1Index() const;
60 uint vertex2Index() const;
61 uint vertex3Index() const;
62
63 Q_INVOKABLE QString toString();
64
65private:
66 friend class QAbstractRayCasterPrivate;
67 void setEntity(Qt3DCore::QEntity *entity) const;
68
69 QSharedDataPointer<QRayCasterHitData> d;
70};
71
72} // Qt3D
73
74QT_END_NAMESPACE
75
76#endif // QT3DRENDER_QRAYCASTERHIT_H
77

source code of qt3d/src/render/picking/qraycasterhit.h