| 1 | // Copyright (C) 2019 The Qt Company Ltd. |
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only |
| 3 | |
| 4 | #ifndef QQUICK3DPICKRESULT_P_H |
| 5 | #define QQUICK3DPICKRESULT_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 purely as an |
| 12 | // implementation detail. 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 <QtQuick3D/qquick3dobject.h> |
| 19 | #include <QObject> |
| 20 | #include <QtGui/QVector2D> |
| 21 | #include <QtGui/QVector3D> |
| 22 | #include "qquick3dmodel_p.h" |
| 23 | |
| 24 | QT_BEGIN_NAMESPACE |
| 25 | class QQuick3DModel; |
| 26 | |
| 27 | namespace QQuick3DPickResultEnums |
| 28 | { |
| 29 | Q_NAMESPACE_EXPORT(Q_QUICK3D_EXPORT) |
| 30 | |
| 31 | QML_NAMED_ELEMENT(PickResult) |
| 32 | QML_ADDED_IN_VERSION(6, 8) |
| 33 | |
| 34 | enum HitType { |
| 35 | Null, |
| 36 | Model, |
| 37 | Item, |
| 38 | }; |
| 39 | Q_ENUM_NS(HitType) |
| 40 | |
| 41 | }; |
| 42 | |
| 43 | |
| 44 | class Q_QUICK3D_EXPORT QQuick3DPickResult |
| 45 | { |
| 46 | Q_GADGET |
| 47 | Q_PROPERTY(QQuick3DModel* objectHit READ objectHit CONSTANT) |
| 48 | Q_PROPERTY(float distance READ distance CONSTANT) |
| 49 | Q_PROPERTY(QVector2D uvPosition READ uvPosition CONSTANT) |
| 50 | Q_PROPERTY(QVector3D scenePosition READ scenePosition CONSTANT) |
| 51 | Q_PROPERTY(QVector3D position READ position CONSTANT) |
| 52 | Q_PROPERTY(QVector3D normal READ normal CONSTANT) |
| 53 | Q_PROPERTY(QVector3D sceneNormal READ sceneNormal CONSTANT) |
| 54 | Q_PROPERTY(int instanceIndex READ instanceIndex CONSTANT) |
| 55 | Q_PROPERTY(QQuickItem *itemHit READ itemHit CONSTANT REVISION(6, 8)) |
| 56 | Q_PROPERTY(QQuick3DPickResultEnums::HitType hitType READ hitType CONSTANT REVISION(6, 8)) |
| 57 | QML_VALUE_TYPE(pickResult) |
| 58 | public: |
| 59 | |
| 60 | QQuick3DPickResult(); |
| 61 | explicit QQuick3DPickResult(QQuick3DModel *hitObject, |
| 62 | float distanceFromCamera, |
| 63 | const QVector2D &uvPosition, |
| 64 | const QVector3D &scenePosition, |
| 65 | const QVector3D &position, |
| 66 | const QVector3D &normal, |
| 67 | int instanceIndex); |
| 68 | explicit QQuick3DPickResult(QQuickItem *itemHit, |
| 69 | float distanceFromCamera, |
| 70 | const QVector2D &uvPosition, |
| 71 | const QVector3D &scenePosition, |
| 72 | const QVector3D &position, |
| 73 | const QVector3D &sceneNormal); |
| 74 | QQuick3DModel *objectHit() const; |
| 75 | float distance() const; |
| 76 | QVector2D uvPosition() const; |
| 77 | QVector3D scenePosition() const; |
| 78 | QVector3D position() const; |
| 79 | QVector3D normal() const; |
| 80 | QVector3D sceneNormal() const; |
| 81 | int instanceIndex() const; |
| 82 | Q_REVISION(6, 8) QQuickItem *itemHit() const; |
| 83 | Q_REVISION(6, 8) QQuick3DPickResultEnums::HitType hitType() const; |
| 84 | |
| 85 | private: |
| 86 | QQuick3DModel *m_objectHit; |
| 87 | float m_distance; |
| 88 | QVector2D m_uvPosition; |
| 89 | QVector3D m_scenePosition; |
| 90 | QVector3D m_position; |
| 91 | QVector3D m_normal; |
| 92 | int m_instanceIndex; |
| 93 | QQuickItem *m_itemHit; |
| 94 | QQuick3DPickResultEnums::HitType m_hitType; |
| 95 | }; |
| 96 | |
| 97 | QT_END_NAMESPACE |
| 98 | |
| 99 | Q_DECLARE_METATYPE(QQuick3DPickResult) |
| 100 | |
| 101 | #endif // QQUICK3DPICKRESULT_P_H |
| 102 | |