mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-09 09:50:06 +02:00
Fix baked material JSONS using wrong texture paths
This commit is contained in:
parent
3016860bab
commit
20d0ca0073
4 changed files with 9 additions and 6 deletions
|
@ -27,11 +27,12 @@ std::function<QThread*()> MaterialBaker::_getNextOvenWorkerThreadOperator;
|
||||||
|
|
||||||
static int materialNum = 0;
|
static int materialNum = 0;
|
||||||
|
|
||||||
MaterialBaker::MaterialBaker(const QString& materialData, bool isURL, const QString& bakedOutputDir) :
|
MaterialBaker::MaterialBaker(const QString& materialData, bool isURL, const QString& bakedOutputDir, const QUrl& destinationPath) :
|
||||||
_materialData(materialData),
|
_materialData(materialData),
|
||||||
_isURL(isURL),
|
_isURL(isURL),
|
||||||
_bakedOutputDir(bakedOutputDir),
|
_bakedOutputDir(bakedOutputDir),
|
||||||
_textureOutputDir(bakedOutputDir + "/materialTextures/" + QString::number(materialNum++))
|
_textureOutputDir(bakedOutputDir + "/materialTextures/" + QString::number(materialNum++)),
|
||||||
|
_destinationPath(destinationPath)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -162,10 +163,11 @@ void MaterialBaker::handleFinishedTextureBaker() {
|
||||||
qCDebug(material_baking) << "Re-writing texture references to" << baker->getTextureURL();
|
qCDebug(material_baking) << "Re-writing texture references to" << baker->getTextureURL();
|
||||||
|
|
||||||
auto newURL = QUrl(_textureOutputDir).resolved(baker->getMetaTextureFileName());
|
auto newURL = QUrl(_textureOutputDir).resolved(baker->getMetaTextureFileName());
|
||||||
|
auto relativeURL = QDir(_bakedOutputDir).relativeFilePath(newURL.toString());
|
||||||
|
|
||||||
// Replace the old texture URLs
|
// Replace the old texture URLs
|
||||||
for (auto networkMaterial : _materialsNeedingRewrite.values(textureKey)) {
|
for (auto networkMaterial : _materialsNeedingRewrite.values(textureKey)) {
|
||||||
networkMaterial->getTextureMap(baker->getMapChannel())->getTextureSource()->setUrl(newURL);
|
networkMaterial->getTextureMap(baker->getMapChannel())->getTextureSource()->setUrl(_destinationPath.resolved(relativeURL));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// this texture failed to bake - this doesn't fail the entire bake but we need to add the errors from
|
// this texture failed to bake - this doesn't fail the entire bake but we need to add the errors from
|
||||||
|
|
|
@ -23,7 +23,7 @@ static const QString BAKED_MATERIAL_EXTENSION = ".baked.json";
|
||||||
class MaterialBaker : public Baker {
|
class MaterialBaker : public Baker {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
MaterialBaker(const QString& materialData, bool isURL, const QString& bakedOutputDir);
|
MaterialBaker(const QString& materialData, bool isURL, const QString& bakedOutputDir, const QUrl& destinationPath);
|
||||||
|
|
||||||
QString getMaterialData() const { return _materialData; }
|
QString getMaterialData() const { return _materialData; }
|
||||||
bool isURL() const { return _isURL; }
|
bool isURL() const { return _isURL; }
|
||||||
|
@ -56,6 +56,7 @@ private:
|
||||||
QString _bakedOutputDir;
|
QString _bakedOutputDir;
|
||||||
QString _textureOutputDir;
|
QString _textureOutputDir;
|
||||||
QString _bakedMaterialData;
|
QString _bakedMaterialData;
|
||||||
|
QUrl _destinationPath;
|
||||||
|
|
||||||
QScriptEngine _scriptEngine;
|
QScriptEngine _scriptEngine;
|
||||||
static std::function<QThread*()> _getNextOvenWorkerThreadOperator;
|
static std::function<QThread*()> _getNextOvenWorkerThreadOperator;
|
||||||
|
|
|
@ -61,7 +61,7 @@ void BakerCLI::bakeFile(QUrl inputUrl, const QString& outputPath, const QString&
|
||||||
_baker = std::unique_ptr<Baker> { new JSBaker(inputUrl, outputPath) };
|
_baker = std::unique_ptr<Baker> { new JSBaker(inputUrl, outputPath) };
|
||||||
_baker->moveToThread(Oven::instance().getNextWorkerThread());
|
_baker->moveToThread(Oven::instance().getNextWorkerThread());
|
||||||
} else if (type == MATERIAL_EXTENSION) {
|
} else if (type == MATERIAL_EXTENSION) {
|
||||||
_baker = std::unique_ptr<Baker> { new MaterialBaker(inputUrl.toDisplayString(), true, outputPath) };
|
_baker = std::unique_ptr<Baker> { new MaterialBaker(inputUrl.toDisplayString(), true, outputPath, QUrl(outputPath)) };
|
||||||
_baker->moveToThread(Oven::instance().getNextWorkerThread());
|
_baker->moveToThread(Oven::instance().getNextWorkerThread());
|
||||||
} else {
|
} else {
|
||||||
// If the type doesn't match the above, we assume we have a texture, and the type specified is the
|
// If the type doesn't match the above, we assume we have a texture, and the type specified is the
|
||||||
|
|
|
@ -271,7 +271,7 @@ void DomainBaker::addMaterialBaker(const QString& property, const QString& data,
|
||||||
|
|
||||||
// setup a baker for this material
|
// setup a baker for this material
|
||||||
QSharedPointer<MaterialBaker> materialBaker {
|
QSharedPointer<MaterialBaker> materialBaker {
|
||||||
new MaterialBaker(data, isURL, _contentOutputPath),
|
new MaterialBaker(data, isURL, _contentOutputPath, _destinationPath),
|
||||||
&MaterialBaker::deleteLater
|
&MaterialBaker::deleteLater
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue