mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 15:38:00 +02:00
Move outputFiles from FBXBaker to Baker
This commit is contained in:
parent
39f04adc8d
commit
7d08a5788f
4 changed files with 24 additions and 24 deletions
|
@ -61,28 +61,24 @@ void BakeAssetTask::run() {
|
||||||
qRegisterMetaType<QVector<QString> >("QVector<QString>");
|
qRegisterMetaType<QVector<QString> >("QVector<QString>");
|
||||||
TextureBakerThreadGetter fn = []() -> QThread* { return QThread::currentThread(); };
|
TextureBakerThreadGetter fn = []() -> QThread* { return QThread::currentThread(); };
|
||||||
|
|
||||||
if (_filePath.endsWith(".fbx")) {
|
std::unique_ptr<Baker> baker;
|
||||||
FBXBaker baker(QUrl("file:///" + _filePath), fn, PathUtils::generateTemporaryDir());
|
|
||||||
|
|
||||||
QEventLoop loop;
|
if (_assetPath.endsWith(".fbx")) {
|
||||||
connect(&baker, &Baker::finished, &loop, &QEventLoop::quit);
|
baker = std::make_unique<FBXBaker>(QUrl("file:///" + _filePath), fn, PathUtils::generateTemporaryDir());
|
||||||
QMetaObject::invokeMethod(&baker, "bake", Qt::QueuedConnection);
|
|
||||||
qDebug() << "Running the bake!";
|
|
||||||
loop.exec();
|
|
||||||
|
|
||||||
qDebug() << "Finished baking: " << _assetHash << _assetPath << baker.getOutputFiles();
|
|
||||||
emit bakeComplete(_assetHash, _assetPath, QVector<QString>::fromStdVector(baker.getOutputFiles()));
|
|
||||||
} else {
|
} else {
|
||||||
TextureBaker baker(QUrl("file:///" + _filePath), image::TextureUsage::CUBE_TEXTURE, PathUtils::generateTemporaryDir());
|
baker = std::make_unique<TextureBaker>(QUrl("file:///" + _filePath), image::TextureUsage::CUBE_TEXTURE, PathUtils::generateTemporaryDir());
|
||||||
|
}
|
||||||
|
|
||||||
QEventLoop loop;
|
QEventLoop loop;
|
||||||
connect(&baker, &Baker::finished, &loop, &QEventLoop::quit);
|
connect(baker.get(), &Baker::finished, &loop, &QEventLoop::quit);
|
||||||
QMetaObject::invokeMethod(&baker, "bake", Qt::QueuedConnection);
|
QMetaObject::invokeMethod(baker.get(), "bake", Qt::QueuedConnection);
|
||||||
qDebug() << "Running the bake!";
|
loop.exec();
|
||||||
loop.exec();
|
|
||||||
|
|
||||||
qDebug() << "Finished baking: " << _assetHash << _assetPath << baker.getBakedTextureFileName();
|
if (baker->hasErrors()) {
|
||||||
emit bakeComplete(_assetHash, _assetPath, { baker.getDestinationFilePath() });
|
qDebug() << "Failed to bake: " << _assetHash << _assetPath;
|
||||||
|
} else {
|
||||||
|
qDebug() << "Finished baking: " << _assetHash << _assetPath << baker->getOutputFiles();
|
||||||
|
emit bakeComplete(_assetHash, _assetPath, QVector<QString>::fromStdVector(baker->getOutputFiles()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -454,7 +450,6 @@ void AssetServer::handleGetMappingOperation(ReceivedMessage& message, SharedNode
|
||||||
replyPacket.write(QByteArray::fromHex(originalAssetHash.toUtf8()));
|
replyPacket.write(QByteArray::fromHex(originalAssetHash.toUtf8()));
|
||||||
replyPacket.writePrimitive(wasRedirected);
|
replyPacket.writePrimitive(wasRedirected);
|
||||||
|
|
||||||
|
|
||||||
auto query = QUrlQuery(url.query());
|
auto query = QUrlQuery(url.query());
|
||||||
bool isSkybox = query.hasQueryItem("skybox");
|
bool isSkybox = query.hasQueryItem("skybox");
|
||||||
qDebug() << "Is skybox? " << isSkybox;
|
qDebug() << "Is skybox? " << isSkybox;
|
||||||
|
|
|
@ -24,6 +24,8 @@ public:
|
||||||
bool hasWarnings() const { return !_warningList.isEmpty(); }
|
bool hasWarnings() const { return !_warningList.isEmpty(); }
|
||||||
QStringList getWarnings() const { return _warningList; }
|
QStringList getWarnings() const { return _warningList; }
|
||||||
|
|
||||||
|
std::vector<QString> getOutputFiles() const { return _outputFiles; }
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
virtual void bake() = 0;
|
virtual void bake() = 0;
|
||||||
|
|
||||||
|
@ -36,6 +38,10 @@ protected:
|
||||||
|
|
||||||
void handleErrors(const QStringList& errors);
|
void handleErrors(const QStringList& errors);
|
||||||
|
|
||||||
|
// List of baked output files. For instance, for an FBX this would
|
||||||
|
// include the .fbx and all of its texture files.
|
||||||
|
std::vector<QString> _outputFiles;
|
||||||
|
|
||||||
QStringList _errorList;
|
QStringList _errorList;
|
||||||
QStringList _warningList;
|
QStringList _warningList;
|
||||||
};
|
};
|
||||||
|
|
|
@ -44,7 +44,6 @@ public:
|
||||||
|
|
||||||
QUrl getFBXUrl() const { return _fbxURL; }
|
QUrl getFBXUrl() const { return _fbxURL; }
|
||||||
QString getBakedFBXFilePath() const { return _bakedFBXFilePath; }
|
QString getBakedFBXFilePath() const { return _bakedFBXFilePath; }
|
||||||
std::vector<QString> getOutputFiles() const { return _outputFiles; }
|
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
// all calls to FBXBaker::bake for FBXBaker instances must be from the same thread
|
// all calls to FBXBaker::bake for FBXBaker instances must be from the same thread
|
||||||
|
@ -88,9 +87,6 @@ private:
|
||||||
QDir _tempDir;
|
QDir _tempDir;
|
||||||
QString _originalFBXFilePath;
|
QString _originalFBXFilePath;
|
||||||
|
|
||||||
// List of baked output files, includes the FBX and textures
|
|
||||||
std::vector<QString> _outputFiles;
|
|
||||||
|
|
||||||
static FBXSDKManagerUniquePointer _sdkManager;
|
static FBXSDKManagerUniquePointer _sdkManager;
|
||||||
fbxsdk::FbxScene* _scene { nullptr };
|
fbxsdk::FbxScene* _scene { nullptr };
|
||||||
|
|
||||||
|
|
|
@ -120,10 +120,13 @@ void TextureBaker::processTexture() {
|
||||||
const size_t length = memKTX->_storage->size();
|
const size_t length = memKTX->_storage->size();
|
||||||
|
|
||||||
// attempt to write the baked texture to the destination file path
|
// attempt to write the baked texture to the destination file path
|
||||||
QFile bakedTextureFile { _outputDirectory.absoluteFilePath(_bakedTextureFileName) };
|
auto filePath = _outputDirectory.absoluteFilePath(_bakedTextureFileName);
|
||||||
|
QFile bakedTextureFile { filePath };
|
||||||
|
|
||||||
if (!bakedTextureFile.open(QIODevice::WriteOnly) || bakedTextureFile.write(data, length) == -1) {
|
if (!bakedTextureFile.open(QIODevice::WriteOnly) || bakedTextureFile.write(data, length) == -1) {
|
||||||
handleError("Could not write baked texture for " + _textureURL.toString());
|
handleError("Could not write baked texture for " + _textureURL.toString());
|
||||||
|
} else {
|
||||||
|
_outputFiles.push_back(filePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
qCDebug(model_baking) << "Baked texture" << _textureURL;
|
qCDebug(model_baking) << "Baked texture" << _textureURL;
|
||||||
|
|
Loading…
Reference in a new issue