52void QQuick3DLightmapBaker::bake()
55 if (m_currentlyBaking)
58 m_bakingRequested =
true;
59 m_bakingControl->reset();
61 m_windowCancelRequested =
false;
64 m_lmWindow =
new QQuickView();
65 m_lmWindow->setSource(QUrl::fromLocalFile(QStringLiteral(
":/qt-project.org/imports/QtQuick3D/LightmapperOutputWindow.qml")));
67 m_lmWindow->setProperty(
"width", 400);
68 m_lmWindow->setProperty(
"height", 400);
70 QObject *rootObject = m_lmWindow->rootObject();
71 QObject *cancelButton = rootObject->findChild<QObject *>(QStringLiteral(
"cancelButton"));
73 QObject::connect(cancelButton, SIGNAL(clicked()),
this, SLOT(onLmCancelButtonClicked()));
75 QObject::connect(m_lmWindow, &QQuickWindow::closing,
this, &QQuick3DLightmapBaker::onLmWindowClosing);
77 QObject *rootObject = m_lmWindow->rootObject();
78 QMetaObject::invokeMethod(rootObject,
"clearText");
81 m_callback = [
this] (
const QVariantMap &payload, BakingControl *bakingControl) {
82 if (m_windowCancelRequested && !bakingControl->isCancelled())
83 bakingControl->requestCancel();
85 const BakingStatus status =
static_cast<BakingStatus>(payload[QStringLiteral(
"status")].toInt());
87 QQuickWindow *window = m_view->window();
88 if (status == BakingStatus::Complete) {
89 m_currentlyBaking =
false;
90 QQuickWindowPrivate::get(window)->updatesEnabled =
true;
91 }
else if (status != BakingStatus::None) {
92 if (status == BakingStatus::Cancelled || status == BakingStatus::Failed) {
93 m_currentlyBaking =
false;
97 QObject *rootObject = m_lmWindow->rootObject();
100 if (payload.contains(QStringLiteral(
"message"))) {
101 msg = payload[QStringLiteral(
"message")].toString();
103 if (!msg.isEmpty()) {
104 if (status == BakingStatus::Warning)
105 msg.prepend(QStringLiteral(
"Warning: "));
106 else if (status == BakingStatus::Error)
107 msg.prepend(QStringLiteral(
"Error: "));
111 QMetaObject::invokeMethod(rootObject,
"update", Q_ARG(QVariant, payload));
116 m_currentlyBaking =
true;
136void QQuick3DLightmapBaker::denoise()
139 if (m_currentlyBaking)
141 m_denoisingRequested =
true;
142 m_bakingControl->reset();
144 m_windowCancelRequested =
false;
147 m_lmWindow =
new QQuickView();
148 m_lmWindow->setSource(QUrl::fromLocalFile(QStringLiteral(
":/qt-project.org/imports/QtQuick3D/LightmapperOutputWindow.qml")));
150 m_lmWindow->setProperty(
"width", 400);
151 m_lmWindow->setProperty(
"height", 400);
153 QObject *rootObject = m_lmWindow->rootObject();
154 QObject *cancelButton = rootObject->findChild<QObject *>(QStringLiteral(
"cancelButton"));
156 QObject::connect(cancelButton, SIGNAL(clicked()),
this, SLOT(onLmCancelButtonClicked()));
158 QObject::connect(m_lmWindow, &QQuickWindow::closing,
this, &QQuick3DLightmapBaker::onLmWindowClosing);
160 QObject *rootObject = m_lmWindow->rootObject();
161 QMetaObject::invokeMethod(rootObject,
"clearText");
164 m_callback = [
this] (
const QVariantMap &payload, BakingControl *bakingControl) {
165 if (m_windowCancelRequested && !bakingControl->isCancelled())
166 bakingControl->requestCancel();
168 const BakingStatus status =
static_cast<BakingStatus>(payload[QStringLiteral(
"status")].toInt());
170 QQuickWindow *window = m_view->window();
171 if (status == BakingStatus::Complete) {
172 QMetaObject::invokeMethod(window,
"releaseResources", Qt::QueuedConnection);
174 m_currentlyBaking =
false;
175 QQuickWindowPrivate::get(window)->updatesEnabled =
true;
176 }
else if (status != BakingStatus::None) {
177 if (status == BakingStatus::Cancelled || status == BakingStatus::Failed)
178 m_currentlyBaking =
false;
181 QObject *rootObject = m_lmWindow->rootObject();
184 if (payload.contains(QStringLiteral(
"message"))) {
185 msg = payload[QStringLiteral(
"message")].toString();
187 if (!msg.isEmpty()) {
188 if (status == BakingStatus::Warning)
189 msg.prepend(QStringLiteral(
"Warning: "));
190 else if (status == BakingStatus::Error)
191 msg.prepend(QStringLiteral(
"Error: "));
195 QMetaObject::invokeMethod(rootObject,
"update", Q_ARG(QVariant, payload));
200 m_currentlyBaking =
true;