| 1 | // Copyright (C) 2008-2012 NVIDIA Corporation. |
|---|---|
| 2 | // Copyright (C) 2019 The Qt Company Ltd. |
| 3 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only |
| 4 | |
| 5 | #ifndef QSSG_RENDER_MESH_H |
| 6 | #define QSSG_RENDER_MESH_H |
| 7 | |
| 8 | // |
| 9 | // W A R N I N G |
| 10 | // ------------- |
| 11 | // |
| 12 | // This file is not part of the Qt API. It exists purely as an |
| 13 | // implementation detail. This header file may change from version to |
| 14 | // version without notice, or even be removed. |
| 15 | // |
| 16 | // We mean it. |
| 17 | // |
| 18 | |
| 19 | #include <QtQuick3DRuntimeRender/private/qssgrhicontext_p.h> |
| 20 | |
| 21 | #include <QtQuick3DUtils/private/qssgbounds3_p.h> |
| 22 | #include <QtQuick3DUtils/private/qssgmeshbvh_p.h> |
| 23 | |
| 24 | QT_BEGIN_NAMESPACE |
| 25 | |
| 26 | struct QSSGRenderSubset |
| 27 | { |
| 28 | quint32 count; |
| 29 | quint32 offset; |
| 30 | QSSGBounds3 bounds; // Vertex buffer bounds |
| 31 | QSSGMeshBVHNode::Handle bvhRoot; |
| 32 | struct { |
| 33 | QSSGRhiBufferPtr vertexBuffer; |
| 34 | QSSGRhiBufferPtr indexBuffer; |
| 35 | QSSGRhiInputAssemblerState ia; |
| 36 | QRhiTexture *targetsTexture = nullptr; |
| 37 | } rhi; |
| 38 | |
| 39 | struct Lod { |
| 40 | quint32 count = 0; |
| 41 | quint32 offset = 0; |
| 42 | float distance = 0.0f; |
| 43 | }; |
| 44 | QVector<Lod> lods; |
| 45 | |
| 46 | QSSGRenderSubset() = default; |
| 47 | QSSGRenderSubset(const QSSGRenderSubset &inOther) |
| 48 | : count(inOther.count) |
| 49 | , offset(inOther.offset) |
| 50 | , bounds(inOther.bounds) |
| 51 | , bvhRoot(inOther.bvhRoot) |
| 52 | , rhi(inOther.rhi) |
| 53 | , lods(inOther.lods) |
| 54 | { |
| 55 | } |
| 56 | QSSGRenderSubset &operator=(const QSSGRenderSubset &inOther) |
| 57 | { |
| 58 | if (this != &inOther) { |
| 59 | count = inOther.count; |
| 60 | offset = inOther.offset; |
| 61 | bounds = inOther.bounds; |
| 62 | bvhRoot = inOther.bvhRoot; |
| 63 | rhi = inOther.rhi; |
| 64 | lods = inOther.lods; |
| 65 | } |
| 66 | return *this; |
| 67 | } |
| 68 | |
| 69 | quint32 lodCount(int lodLevel) const { |
| 70 | if (lodLevel == 0 || lods.isEmpty()) |
| 71 | return count; |
| 72 | if (lodLevel > lods.count()) |
| 73 | lodLevel = lods.count() - 1; |
| 74 | else |
| 75 | lodLevel -= 1; |
| 76 | |
| 77 | return lods[lodLevel].count; |
| 78 | } |
| 79 | |
| 80 | quint32 lodOffset(int lodLevel) const { |
| 81 | if (lodLevel == 0 || lods.isEmpty()) |
| 82 | return offset; |
| 83 | if (lodLevel > lods.count()) |
| 84 | lodLevel = lods.count() - 1; |
| 85 | else |
| 86 | lodLevel -= 1; |
| 87 | |
| 88 | return lods[lodLevel].offset; |
| 89 | } |
| 90 | |
| 91 | }; |
| 92 | |
| 93 | struct QSSGRenderMesh |
| 94 | { |
| 95 | Q_DISABLE_COPY(QSSGRenderMesh) |
| 96 | |
| 97 | QVector<QSSGRenderSubset> subsets; |
| 98 | QSSGRenderDrawMode drawMode; |
| 99 | QSSGRenderWinding winding; |
| 100 | std::unique_ptr<QSSGMeshBVH> bvh; |
| 101 | QSize lightmapSizeHint; |
| 102 | |
| 103 | QSSGRenderMesh(QSSGRenderDrawMode inDrawMode, QSSGRenderWinding inWinding) |
| 104 | : drawMode(inDrawMode), winding(inWinding) |
| 105 | { |
| 106 | } |
| 107 | }; |
| 108 | QT_END_NAMESPACE |
| 109 | |
| 110 | #endif |
| 111 |
