1 /**************************************************************************** 2 ** 3 ** Copyright (C) 2008-2012 NVIDIA Corporation. 4 ** Copyright (C) 2019 The Qt Company Ltd. 5 ** Contact: https://www.qt.io/licensing/ 6 ** 7 ** This file is part of Qt Quick 3D. 8 ** 9 ** $QT_BEGIN_LICENSE:GPL$ 10 ** Commercial License Usage 11 ** Licensees holding valid commercial Qt licenses may use this file in 12 ** accordance with the commercial license agreement provided with the 13 ** Software or, alternatively, in accordance with the terms contained in 14 ** a written agreement between you and The Qt Company. For licensing terms 15 ** and conditions see https://www.qt.io/terms-conditions. For further 16 ** information use the contact form at https://www.qt.io/contact-us. 17 ** 18 ** GNU General Public License Usage 19 ** Alternatively, this file may be used under the terms of the GNU 20 ** General Public License version 3 or (at your option) any later version 21 ** approved by the KDE Free Qt Foundation. The licenses are as published by 22 ** the Free Software Foundation and appearing in the file LICENSE.GPL3 23 ** included in the packaging of this file. Please review the following 24 ** information to ensure the GNU General Public License requirements will 25 ** be met: https://www.gnu.org/licenses/gpl-3.0.html. 26 ** 27 ** $QT_END_LICENSE$ 28 ** 29 ****************************************************************************/ 30 31 #ifndef QSSG_RENDER_GRAPH_OBJECT_PICK_QUERY_H 32 #define QSSG_RENDER_GRAPH_OBJECT_PICK_QUERY_H 33 34 // 35 // W A R N I N G 36 // ------------- 37 // 38 // This file is not part of the Qt API. It exists purely as an 39 // implementation detail. This header file may change from version to 40 // version without notice, or even be removed. 41 // 42 // We mean it. 43 // 44 45 #include <QtGui/QVector2D> 46 #include <QtGui/QMatrix4x4> 47 48 #include <QtQuick3DUtils/private/qssgdataref_p.h> 49 50 #include <QtQuick3DRender/private/qssgrenderbasetypes_p.h> 51 52 #include <QtQuick3DRuntimeRender/private/qssgrendergraphobject_p.h> 53 54 #include <limits> 55 56 QT_BEGIN_NAMESPACE 57 58 struct QSSGRenderPickResult 59 { 60 const QSSGRenderGraphObject *m_hitObject = nullptr; 61 float m_cameraDistanceSq = std::numeric_limits<float>::max(); 62 // The local coordinates in X,Y UV space where the hit occured 63 QVector2D m_localUVCoords; 64 // The position in world coordinates 65 QVector3D m_scenePosition; 66 67 QSSGRenderPickResult(const QSSGRenderGraphObject &inHitObject, 68 float inCameraDistance, 69 const QVector2D &inLocalUVCoords, 70 const QVector3D &inScenePosition); 71 QSSGRenderPickResult() = default; 72 }; 73 74 Q_STATIC_ASSERT(std::is_trivially_destructible<QSSGRenderPickResult>::value); 75 76 class QSSGGraphObjectPickQueryInterface 77 { 78 protected: ~QSSGGraphObjectPickQueryInterface()79 virtual ~QSSGGraphObjectPickQueryInterface() {} 80 81 public: 82 // Implementors have the option of batching the results to allow fewer virtual calls 83 // or returning one item each pick. 84 // Results are guaranteed to be returned nearest to furthest 85 // If the return value has size of zero then we assume nothing more can be picked and the 86 // pick 87 // is finished. 88 virtual QSSGRenderPickResult pick(const QVector2D &inMouseCoords, 89 const QVector2D &inViewportDimensions, 90 bool inPickEverything) = 0; 91 }; 92 QT_END_NAMESPACE 93 #endif 94