50void QQuick3DLightmapBaker::bake()
53 if (m_currentlyBaking)
56 m_bakingRequested =
true;
57 m_bakingControl->reset();
59 m_windowCancelRequested =
false;
62 m_lmWindow =
new QQuickView();
63 m_lmWindow->setSource(QUrl::fromLocalFile(QStringLiteral(
":/qt-project.org/imports/QtQuick3D/LightmapperOutputWindow.qml")));
65 m_lmWindow->setProperty(
"width", 400);
66 m_lmWindow->setProperty(
"height", 400);
68 QObject *rootObject = m_lmWindow->rootObject();
69 QObject *cancelButton = rootObject->findChild<QObject *>(QStringLiteral(
"cancelButton"));
71 QObject::connect(cancelButton, SIGNAL(clicked()),
this, SLOT(onLmCancelButtonClicked()));
73 QObject::connect(m_lmWindow, &QQuickWindow::closing,
this, &QQuick3DLightmapBaker::onLmWindowClosing);
75 QObject *rootObject = m_lmWindow->rootObject();
76 QMetaObject::invokeMethod(rootObject,
"clearText");
79 m_callback = [
this] (
const QVariantMap &payload, BakingControl *bakingControl) {
80 if (m_windowCancelRequested && !bakingControl->isCancelled())
81 bakingControl->requestCancel();
83 const BakingStatus status =
static_cast<BakingStatus>(payload[QStringLiteral(
"status")].toInt());
85 QQuickWindow *window = m_view->window();
86 if (status == BakingStatus::Complete) {
87 m_currentlyBaking =
false;
88 QQuickWindowPrivate::get(window)->updatesEnabled =
true;
89 }
else if (status != BakingStatus::None) {
90 if (status == BakingStatus::Cancelled || status == BakingStatus::Failed) {
91 m_currentlyBaking =
false;
95 QObject *rootObject = m_lmWindow->rootObject();
98 if (payload.contains(QStringLiteral(
"message"))) {
99 msg = payload[QStringLiteral(
"message")].toString();
101 if (!msg.isEmpty()) {
102 if (status == BakingStatus::Warning)
103 msg.prepend(QStringLiteral(
"Warning: "));
104 else if (status == BakingStatus::Error)
105 msg.prepend(QStringLiteral(
"Error: "));
109 QMetaObject::invokeMethod(rootObject,
"update", Q_ARG(QVariant, payload));
114 m_currentlyBaking =
true;
134void QQuick3DLightmapBaker::denoise()
137 if (m_currentlyBaking)
139 m_denoisingRequested =
true;
140 m_bakingControl->reset();
142 m_windowCancelRequested =
false;
145 m_lmWindow =
new QQuickView();
146 m_lmWindow->setSource(QUrl::fromLocalFile(QStringLiteral(
":/qt-project.org/imports/QtQuick3D/LightmapperOutputWindow.qml")));
148 m_lmWindow->setProperty(
"width", 400);
149 m_lmWindow->setProperty(
"height", 400);
151 QObject *rootObject = m_lmWindow->rootObject();
152 QObject *cancelButton = rootObject->findChild<QObject *>(QStringLiteral(
"cancelButton"));
154 QObject::connect(cancelButton, SIGNAL(clicked()),
this, SLOT(onLmCancelButtonClicked()));
156 QObject::connect(m_lmWindow, &QQuickWindow::closing,
this, &QQuick3DLightmapBaker::onLmWindowClosing);
158 QObject *rootObject = m_lmWindow->rootObject();
159 QMetaObject::invokeMethod(rootObject,
"clearText");
162 m_callback = [
this] (
const QVariantMap &payload, BakingControl *bakingControl) {
163 if (m_windowCancelRequested && !bakingControl->isCancelled())
164 bakingControl->requestCancel();
166 const BakingStatus status =
static_cast<BakingStatus>(payload[QStringLiteral(
"status")].toInt());
168 QQuickWindow *window = m_view->window();
169 if (status == BakingStatus::Complete) {
170 QMetaObject::invokeMethod(window,
"releaseResources", Qt::QueuedConnection);
172 m_currentlyBaking =
false;
173 QQuickWindowPrivate::get(window)->updatesEnabled =
true;
174 }
else if (status != BakingStatus::None) {
175 if (status == BakingStatus::Cancelled || status == BakingStatus::Failed)
176 m_currentlyBaking =
false;
179 QObject *rootObject = m_lmWindow->rootObject();
182 if (payload.contains(QStringLiteral(
"message"))) {
183 msg = payload[QStringLiteral(
"message")].toString();
185 if (!msg.isEmpty()) {
186 if (status == BakingStatus::Warning)
187 msg.prepend(QStringLiteral(
"Warning: "));
188 else if (status == BakingStatus::Error)
189 msg.prepend(QStringLiteral(
"Error: "));
193 QMetaObject::invokeMethod(rootObject,
"update", Q_ARG(QVariant, payload));
198 m_currentlyBaking =
true;