1 | // Copyright (C) 2023 The Qt Company Ltd. |
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only |
3 | |
4 | #ifndef QQUICK3DLIGHTMAPBAKER_P_H |
5 | #define QQUICK3DLIGHTMAPBAKER_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/qtquick3dglobal.h> |
19 | #include <QtQuick/private/qquickview_p.h> |
20 | |
21 | QT_BEGIN_NAMESPACE |
22 | |
23 | class QQuick3DViewport; |
24 | |
25 | class Q_QUICK3D_EXPORT QQuick3DLightmapBaker : public QObject |
26 | { |
27 | Q_OBJECT |
28 | public: |
29 | enum class BakingStatus { |
30 | None, |
31 | Progress, |
32 | Warning, |
33 | Error, |
34 | Cancelled, |
35 | Complete |
36 | }; |
37 | |
38 | struct BakingControl { |
39 | void reset(); |
40 | void requestCancel(); |
41 | bool isCancelled() const; |
42 | |
43 | private: |
44 | std::atomic_int cancelFlag = 0; |
45 | }; |
46 | |
47 | typedef std::function<void(BakingStatus, std::optional<QString>, BakingControl*)> Callback; |
48 | |
49 | explicit QQuick3DLightmapBaker(QQuick3DViewport *view); |
50 | ~QQuick3DLightmapBaker(); |
51 | |
52 | void bake(Callback callback); |
53 | void bake(); |
54 | |
55 | private slots: |
56 | void onLmCancelButtonClicked(); |
57 | void onLmWindowClosing(QQuickCloseEvent *event); |
58 | |
59 | private: |
60 | void updateView(); |
61 | |
62 | bool m_bakingRequested = false; |
63 | BakingControl *m_bakingControl; |
64 | QQuick3DViewport *m_view = nullptr; |
65 | Callback m_callback; |
66 | |
67 | // For the internal status/control provided by the default impl through DebugView |
68 | QQuickView *m_lmWindow = nullptr; |
69 | bool m_windowCancelRequested = false; |
70 | |
71 | friend class QQuick3DSceneRenderer; |
72 | }; |
73 | |
74 | QT_END_NAMESPACE |
75 | |
76 | |
77 | #endif // QQUICK3DLIGHTMAPBAKER_P_H |
78 | ; |
79 | |