54void QQuick3DLightmapBaker::bake()
57 if (m_currentlyBaking)
60 m_bakingRequested =
true;
61 m_bakingControl->reset();
63 m_windowCancelRequested =
false;
66 m_lmWindow =
new QQuickView();
67 m_lmWindow->setSource(QUrl::fromLocalFile(QStringLiteral(
":/qt-project.org/imports/QtQuick3D/LightmapperOutputWindow.qml")));
69 m_lmWindow->setProperty(
"width", 400);
70 m_lmWindow->setProperty(
"height", 400);
72 QObject *rootObject = m_lmWindow->rootObject();
73 QObject *cancelButton = rootObject->findChild<QObject *>(QStringLiteral(
"cancelButton"));
75 QObject::connect(cancelButton, SIGNAL(clicked()),
this, SLOT(onLmCancelButtonClicked()));
77 QObject::connect(m_lmWindow, &QQuickWindow::closing,
this, &QQuick3DLightmapBaker::onLmWindowClosing);
79 QObject *rootObject = m_lmWindow->rootObject();
80 QMetaObject::invokeMethod(rootObject,
"clearText");
83 m_callback = [
this] (
const QVariantMap &payload, BakingControl *bakingControl) {
84 if (m_windowCancelRequested && !bakingControl->isCancelled())
85 bakingControl->requestCancel();
87 const BakingStatus status =
static_cast<BakingStatus>(payload[QStringLiteral(
"status")].toInt());
89 QQuickWindow *window = m_view->window();
90 if (status == BakingStatus::Complete) {
91 m_currentlyBaking =
false;
92 QQuickWindowPrivate::get(window)->updatesEnabled =
true;
93 }
else if (status != BakingStatus::None) {
94 if (status == BakingStatus::Cancelled || status == BakingStatus::Failed) {
95 m_currentlyBaking =
false;
99 QObject *rootObject = m_lmWindow->rootObject();
102 if (payload.contains(QStringLiteral(
"message"))) {
103 msg = payload[QStringLiteral(
"message")].toString();
105 if (!msg.isEmpty()) {
106 if (status == BakingStatus::Warning)
107 msg.prepend(QStringLiteral(
"Warning: "));
108 else if (status == BakingStatus::Error)
109 msg.prepend(QStringLiteral(
"Error: "));
113 QMetaObject::invokeMethod(rootObject,
"update", Q_ARG(QVariant, payload));
118 m_currentlyBaking =
true;
140void QQuick3DLightmapBaker::denoise()
143 if (m_currentlyBaking)
145 m_denoisingRequested =
true;
146 m_bakingControl->reset();
148 m_windowCancelRequested =
false;
151 m_lmWindow =
new QQuickView();
152 m_lmWindow->setSource(QUrl::fromLocalFile(QStringLiteral(
":/qt-project.org/imports/QtQuick3D/LightmapperOutputWindow.qml")));
154 m_lmWindow->setProperty(
"width", 400);
155 m_lmWindow->setProperty(
"height", 400);
157 QObject *rootObject = m_lmWindow->rootObject();
158 QObject *cancelButton = rootObject->findChild<QObject *>(QStringLiteral(
"cancelButton"));
160 QObject::connect(cancelButton, SIGNAL(clicked()),
this, SLOT(onLmCancelButtonClicked()));
162 QObject::connect(m_lmWindow, &QQuickWindow::closing,
this, &QQuick3DLightmapBaker::onLmWindowClosing);
164 QObject *rootObject = m_lmWindow->rootObject();
165 QMetaObject::invokeMethod(rootObject,
"clearText");
168 m_callback = [
this] (
const QVariantMap &payload, BakingControl *bakingControl) {
169 if (m_windowCancelRequested && !bakingControl->isCancelled())
170 bakingControl->requestCancel();
172 const BakingStatus status =
static_cast<BakingStatus>(payload[QStringLiteral(
"status")].toInt());
174 QQuickWindow *window = m_view->window();
175 if (status == BakingStatus::Complete) {
176 QMetaObject::invokeMethod(window,
"releaseResources", Qt::QueuedConnection);
178 m_currentlyBaking =
false;
179 QQuickWindowPrivate::get(window)->updatesEnabled =
true;
180 }
else if (status != BakingStatus::None) {
181 if (status == BakingStatus::Cancelled || status == BakingStatus::Failed)
182 m_currentlyBaking =
false;
185 QObject *rootObject = m_lmWindow->rootObject();
188 if (payload.contains(QStringLiteral(
"message"))) {
189 msg = payload[QStringLiteral(
"message")].toString();
191 if (!msg.isEmpty()) {
192 if (status == BakingStatus::Warning)
193 msg.prepend(QStringLiteral(
"Warning: "));
194 else if (status == BakingStatus::Error)
195 msg.prepend(QStringLiteral(
"Error: "));
199 QMetaObject::invokeMethod(rootObject,
"update", Q_ARG(QVariant, payload));
204 m_currentlyBaking =
true;