| 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_RENDER_TRIANGLEBOUNDINGVOLUME_P_H |
| 5 | #define QT3DRENDER_RENDER_TRIANGLEBOUNDINGVOLUME_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 <Qt3DRender/private/qboundingvolume_p.h> |
| 19 | #include <Qt3DCore/qnodeid.h> |
| 20 | #include <Qt3DCore/private/matrix4x4_p.h> |
| 21 | #include <QVector3D> |
| 22 | |
| 23 | QT_BEGIN_NAMESPACE |
| 24 | |
| 25 | namespace Qt3DRender { |
| 26 | |
| 27 | namespace Render { |
| 28 | |
| 29 | Q_AUTOTEST_EXPORT bool intersectsSegmentTriangle(const RayCasting::QRay3D &ray, |
| 30 | const Vector3D &a, |
| 31 | const Vector3D &b, |
| 32 | const Vector3D &c, |
| 33 | Vector3D &uvw, |
| 34 | float &t); |
| 35 | |
| 36 | class Q_AUTOTEST_EXPORT TriangleBoundingVolume : public RayCasting::QBoundingVolume |
| 37 | { |
| 38 | public: |
| 39 | TriangleBoundingVolume(); |
| 40 | explicit TriangleBoundingVolume(Qt3DCore::QNodeId id, |
| 41 | const Vector3D &a, |
| 42 | const Vector3D &b, |
| 43 | const Vector3D &c); |
| 44 | |
| 45 | Qt3DCore::QNodeId id() const final; |
| 46 | bool intersects(const RayCasting::QRay3D &ray, Vector3D *q, Vector3D *uvw) const final; |
| 47 | Type type() const final; |
| 48 | |
| 49 | Vector3D a() const; |
| 50 | Vector3D b() const; |
| 51 | Vector3D c() const; |
| 52 | |
| 53 | void setA(const Vector3D &a); |
| 54 | void setB(const Vector3D &b); |
| 55 | void setC(const Vector3D &c); |
| 56 | |
| 57 | TriangleBoundingVolume transformed(const Matrix4x4 &mat) const; |
| 58 | |
| 59 | inline TriangleBoundingVolume &transform(const Matrix4x4 &mat) |
| 60 | { |
| 61 | *this = transformed(mat); |
| 62 | return *this; |
| 63 | } |
| 64 | |
| 65 | private: |
| 66 | Qt3DCore::QNodeId m_id; |
| 67 | Vector3D m_a, m_b, m_c; |
| 68 | }; |
| 69 | |
| 70 | } // namespace Render |
| 71 | |
| 72 | } // namespace Qt3DRender |
| 73 | |
| 74 | QT_END_NAMESPACE |
| 75 | |
| 76 | Q_DECLARE_METATYPE(Qt3DRender::Render::TriangleBoundingVolume*) // LCOV_EXCL_LINE |
| 77 | |
| 78 | #endif // QT3DRENDER_RENDER_TRIANGLEBOUNDINGVOLUME_P_H |
| 79 | |