| 1 | // Copyright (C) 2025 The Qt Company Ltd. |
|---|---|
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 |
| 3 | |
| 4 | #include "lightmapfile.h" |
| 5 | |
| 6 | #include <QFile> |
| 7 | #include <QTextStream> |
| 8 | #include <QtQuick3DRuntimeRender/private/qssglightmapio_p.h> |
| 9 | #include "lightmapviewerhelpers.h" |
| 10 | |
| 11 | LightmapFile::LightmapFile(QObject *parent) : QObject { parent } { } |
| 12 | |
| 13 | QStringList LightmapFile::dataList() const |
| 14 | { |
| 15 | return m_dataList; |
| 16 | } |
| 17 | |
| 18 | void LightmapFile::loadData() |
| 19 | { |
| 20 | QSharedPointer<QSSGLightmapLoader> loader = QSSGLightmapLoader::open(path: m_source.toLocalFile()); |
| 21 | auto keys = loader ? loader->getKeys() : QList<std::pair<QString, QSSGLightmapIODataTag>>(); |
| 22 | m_dataList.clear(); |
| 23 | m_dataList.reserve(asize: keys.size()); |
| 24 | for (const auto &[key, tag] : std::as_const(t&: keys)) { |
| 25 | QString tagString = LightmapViewerHelpers::lightmapTagToString(tag); |
| 26 | m_dataList.push_back(t: key + QStringLiteral("$") + tagString); |
| 27 | } |
| 28 | emit dataListChanged(); |
| 29 | } |
| 30 | |
| 31 | QUrl LightmapFile::source() const |
| 32 | { |
| 33 | return m_source; |
| 34 | } |
| 35 | |
| 36 | void LightmapFile::setSource(const QUrl &newSource) |
| 37 | { |
| 38 | if (m_source == newSource) |
| 39 | return; |
| 40 | m_source = newSource; |
| 41 | emit sourceChanged(); |
| 42 | } |
| 43 |
