mirror of
https://github.com/AleziaKurdis/overte.git
synced 2025-04-19 08:18:05 +02:00
Remove some redundancy involving model texture URL resolution
This commit is contained in:
parent
60ed9e12a4
commit
53429f459e
3 changed files with 7 additions and 11 deletions
|
@ -43,7 +43,6 @@ private:
|
|||
void replaceMeshNodeWithDraco(FBXNode& meshNode, const QByteArray& dracoMeshBytes, const std::vector<hifi::ByteArray>& dracoMaterialList);
|
||||
|
||||
hfm::Model::Pointer _hfmModel;
|
||||
QHash<QUrl, QString> _remappedTexturePaths;
|
||||
|
||||
bool _pendingErrorEmission { false };
|
||||
};
|
||||
|
|
|
@ -408,7 +408,7 @@ QString ModelBaker::compressTexture(QString modelTextureFileName, image::Texture
|
|||
if (!modelTextureFileInfo.filePath().isEmpty()) {
|
||||
textureContent = _textureContentMap.value(modelTextureFileName.toLocal8Bit());
|
||||
}
|
||||
auto urlToTexture = getTextureURL(modelTextureFileInfo, modelTextureFileName, !textureContent.isNull());
|
||||
auto urlToTexture = getTextureURL(modelTextureFileInfo, !textureContent.isNull());
|
||||
|
||||
QString baseTextureFileName;
|
||||
if (_remappedTexturePaths.contains(urlToTexture)) {
|
||||
|
@ -559,14 +559,11 @@ void ModelBaker::handleAbortedTexture() {
|
|||
checkIfTexturesFinished();
|
||||
}
|
||||
|
||||
QUrl ModelBaker::getTextureURL(const QFileInfo& textureFileInfo, QString relativeFileName, bool isEmbedded) {
|
||||
QUrl ModelBaker::getTextureURL(const QFileInfo& textureFileInfo, bool isEmbedded) {
|
||||
QUrl urlToTexture;
|
||||
|
||||
// use QFileInfo to easily split up the existing texture filename into its components
|
||||
auto apparentRelativePath = QFileInfo(relativeFileName.replace("\\", "/"));
|
||||
|
||||
if (isEmbedded) {
|
||||
urlToTexture = _modelURL.toString() + "/" + apparentRelativePath.filePath();
|
||||
urlToTexture = _modelURL.toString() + "/" + textureFileInfo.filePath();
|
||||
} else {
|
||||
if (textureFileInfo.exists() && textureFileInfo.isFile()) {
|
||||
// set the texture URL to the local texture that we have confirmed exists
|
||||
|
@ -576,14 +573,14 @@ QUrl ModelBaker::getTextureURL(const QFileInfo& textureFileInfo, QString relativ
|
|||
|
||||
// this is a relative file path which will require different handling
|
||||
// depending on the location of the original model
|
||||
if (_modelURL.isLocalFile() && apparentRelativePath.exists() && apparentRelativePath.isFile()) {
|
||||
if (_modelURL.isLocalFile() && textureFileInfo.exists() && textureFileInfo.isFile()) {
|
||||
// the absolute path we ran into for the texture in the model exists on this machine
|
||||
// so use that file
|
||||
urlToTexture = QUrl::fromLocalFile(apparentRelativePath.absoluteFilePath());
|
||||
urlToTexture = QUrl::fromLocalFile(textureFileInfo.absoluteFilePath());
|
||||
} else {
|
||||
// we didn't find the texture on this machine at the absolute path
|
||||
// so assume that it is right beside the model to match the behaviour of interface
|
||||
urlToTexture = _modelURL.resolved(apparentRelativePath.fileName());
|
||||
urlToTexture = _modelURL.resolved(textureFileInfo.fileName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -98,7 +98,7 @@ private slots:
|
|||
void handleAbortedTexture();
|
||||
|
||||
private:
|
||||
QUrl getTextureURL(const QFileInfo& textureFileInfo, QString relativeFileName, bool isEmbedded = false);
|
||||
QUrl getTextureURL(const QFileInfo& textureFileInfo, bool isEmbedded = false);
|
||||
void bakeTexture(const QUrl & textureURL, image::TextureUsage::Type textureType, const QDir & outputDir,
|
||||
const QString & bakedFilename, const QByteArray & textureContent);
|
||||
QString texturePathRelativeToModel(QUrl modelURL, QUrl textureURL);
|
||||
|
|
Loading…
Reference in a new issue