Cleanup meta texture related changes

This commit is contained in:
Ryan Huffman 2018-05-02 13:31:32 -07:00
parent 12d4cf12cf
commit 697fde4a1a
7 changed files with 6 additions and 82 deletions

View file

@ -74,62 +74,6 @@ void FBXBaker::bakeSourceCopy() {
checkIfTexturesFinished();
}
void FBXBaker::embedTextureMetaData() {
std::vector<FBXNode> embeddedTextureNodes;
for (FBXNode& rootChild : _rootNode.children) {
if (rootChild.name == "Objects") {
qlonglong maxId = 0;
for (auto &child : rootChild.children) {
if (child.properties.length() == 3) {
maxId = std::max(maxId, child.properties[0].toLongLong());
}
}
for (auto& object : rootChild.children) {
if (object.name == "Texture") {
QVariant relativeFilename;
for (auto& child : object.children) {
if (child.name == "RelativeFilename") {
relativeFilename = child.properties[0];
break;
}
}
if (relativeFilename.isNull() || !relativeFilename.toString().endsWith(BAKED_META_TEXTURE_SUFFIX)) {
continue;
}
FBXNode videoNode;
videoNode.name = "Video";
videoNode.properties.append(++maxId);
videoNode.properties.append(object.properties[1]);
videoNode.properties.append("Clip");
QString bakedTextureFilePath {
_bakedOutputDir + "/" + relativeFilename.toString()
};
qDebug() << "Location of texture: " << bakedTextureFilePath;
QFile textureFile { bakedTextureFilePath };
if (!textureFile.open(QIODevice::ReadOnly)) {
qWarning() << "Failed to open: " << bakedTextureFilePath;
continue;
}
videoNode.children.append({ "RelativeFilename", { relativeFilename }, { } });
videoNode.children.append({ "Content", { textureFile.readAll() }, { } });
rootChild.children.append(videoNode);
textureFile.close();
}
}
}
}
}
void FBXBaker::setupOutputFolder() {
// make sure there isn't already an output directory using the same name
if (QDir(_bakedOutputDir).exists()) {

View file

@ -537,8 +537,6 @@ void ModelBaker::embedTextureMetaData() {
}
}
qDebug() << "Max id found was: " << maxId;
for (auto& object : rootChild.children) {
if (object.name == "Texture") {
QVariant relativeFilename;
@ -567,7 +565,6 @@ void ModelBaker::embedTextureMetaData() {
QString bakedTextureFilePath {
_bakedOutputDir + "/" + relativeFilename.toString()
};
qDebug() << "Location of texture: " << bakedTextureFilePath;
QFile textureFile { bakedTextureFilePath };
if (!textureFile.open(QIODevice::ReadOnly)) {
@ -585,7 +582,6 @@ void ModelBaker::embedTextureMetaData() {
}
}
}
}
void ModelBaker::exportScene() {

View file

@ -128,11 +128,11 @@ void TextureBaker::processTexture() {
auto filePath = _outputDirectory.absoluteFilePath(_textureURL.fileName());
QFile file { filePath };
if (!file.open(QIODevice::WriteOnly) || file.write(_originalTexture) == -1) {
handleError("Could not write meta texture for " + _textureURL.toString());
handleError("Could not write original texture for " + _textureURL.toString());
return;
}
_outputFiles.push_back(filePath);
meta.original =_metaTexturePathPrefix +_textureURL.fileName();
meta.original = _metaTexturePathPrefix +_textureURL.fileName();
}
// IMPORTANT: _originalTexture is empty past this point
@ -157,18 +157,17 @@ void TextureBaker::processTexture() {
return;
}
const char* data = reinterpret_cast<const char*>(memKTX->_storage->data());
const size_t length = memKTX->_storage->size();
const char* name = khronos::gl::texture::toString(memKTX->_header.getGLInternaFormat());
if (name == nullptr) {
handleError("Could not determine internal format for compressed KTX: " + _textureURL.toString());
return;
}
qDebug() << "Found type: " << name;
// attempt to write the baked texture to the destination file path
{
const char* data = reinterpret_cast<const char*>(memKTX->_storage->data());
const size_t length = memKTX->_storage->size();
auto fileName = _baseFilename + BAKED_TEXTURE_BCN_SUFFIX;
auto filePath = _outputDirectory.absoluteFilePath(fileName);
QFile bakedTextureFile { filePath };

View file

@ -1101,7 +1101,6 @@ FBXGeometry* FBXReader::extractFBXGeometry(const QVariantHash& mapping, const QS
}
if (!content.isEmpty()) {
_textureContent.insert(filepath, content);
qDebug() << "Adding content: " << filepath << content.length();
}
} else if (object.name == "Material") {
FBXMaterial material;

View file

@ -85,16 +85,12 @@ FBXTexture FBXReader::getTexture(const QString& textureID) {
FBXTexture texture;
const QByteArray& filepath = _textureFilepaths.value(textureID);
texture.content = _textureContent.value(filepath);
qDebug() << "Getting texture: " << textureID << filepath << texture.content.length();
if (texture.content.isEmpty()) { // the content is not inlined
qDebug() << "Texture is not inlined";
texture.filename = _textureFilenames.value(textureID);
} else { // use supplied filepath for inlined content
qDebug() << "Texture is inlined";
texture.filename = filepath;
}
qDebug() << "Path: " << texture.filename;
texture.id = textureID;
texture.name = _textureNames.value(textureID);

View file

@ -315,7 +315,6 @@ NetworkTexture::NetworkTexture(const QUrl& url, image::TextureUsage::Type type,
_textureSource = std::make_shared<gpu::TextureSource>(url, (int)type);
_lowestRequestedMipLevel = 0;
qDebug() << "Creating networktexture: " << url;
if (url.fileName().endsWith(TEXTURE_META_EXTENSION)) {
_currentlyLoadingResourceType = ResourceType::META;
} else if (url.fileName().endsWith(".ktx")) {
@ -402,7 +401,6 @@ NetworkTexture::~NetworkTexture() {
const uint16_t NetworkTexture::NULL_MIP_LEVEL = std::numeric_limits<uint16_t>::max();
void NetworkTexture::makeRequest() {
qDebug() << "In makeRequest for " << _activeUrl << (int)_currentlyLoadingResourceType;
if (_currentlyLoadingResourceType != ResourceType::KTX) {
Resource::makeRequest();
return;
@ -454,7 +452,6 @@ void NetworkTexture::makeRequest() {
_ktxHeaderRequest->send();
qDebug() << "Starting mip range request";
startMipRangeRequest(NULL_MIP_LEVEL, NULL_MIP_LEVEL);
} else if (_ktxResourceState == PENDING_MIP_REQUEST) {
if (_lowestKnownPopulatedMip > 0) {
@ -594,7 +591,6 @@ void NetworkTexture::startMipRangeRequest(uint16_t low, uint16_t high) {
bool isHighMipRequest = low == NULL_MIP_LEVEL && high == NULL_MIP_LEVEL;
qDebug() << "Making ktx mip request to: " << _activeUrl;
_ktxMipRequest = DependencyManager::get<ResourceManager>()->createResourceRequest(this, _activeUrl);
if (!_ktxMipRequest) {
@ -944,9 +940,7 @@ void NetworkTexture::handleFinishedInitialLoad() {
}
void NetworkTexture::downloadFinished(const QByteArray& data) {
qDebug() << "Loading content: " << _activeUrl;
if (_currentlyLoadingResourceType == ResourceType::META) {
qDebug() << "Loading meta content: " << _activeUrl;
loadMetaContent(data);
} else if (_currentlyLoadingResourceType == ResourceType::ORIGINAL) {
loadTextureContent(data);
@ -984,7 +978,6 @@ void NetworkTexture::loadMetaContent(const QByteArray& content) {
_currentlyLoadingResourceType = ResourceType::KTX;
_activeUrl = _activeUrl.resolved(url);
qDebug() << "Active url is now: " << _activeUrl;
auto textureCache = DependencyManager::get<TextureCache>();
auto self = _self.lock();
if (!self) {
@ -1010,13 +1003,12 @@ void NetworkTexture::loadMetaContent(const QByteArray& content) {
}
qWarning() << "Failed to find supported texture type in " << _activeUrl;
//TextureCache::requestCompleted(_self);
Resource::handleFailedRequest(ResourceRequest::NotFound);
}
void NetworkTexture::loadTextureContent(const QByteArray& content) {
if (_currentlyLoadingResourceType != ResourceType::ORIGINAL) {
qWarning() << "Trying to load texture content when currentl resource type is not ORIGINAL";
qWarning() << "Trying to load texture content when current resource type is not ORIGINAL";
assert(false);
return;
}

View file

@ -619,7 +619,6 @@ void Resource::init(bool resetLoaded) {
_loaded = false;
}
_attempts = 0;
qDebug() << "Initting resource: " << _url;
if (_url.isEmpty()) {
_startedLoading = _loaded = true;
@ -672,7 +671,6 @@ void Resource::makeRequest() {
PROFILE_ASYNC_BEGIN(resource, "Resource:" + getType(), QString::number(_requestID), { { "url", _url.toString() }, { "activeURL", _activeUrl.toString() } });
qDebug() << "Making request to " << _activeUrl;
_request = DependencyManager::get<ResourceManager>()->createResourceRequest(this, _activeUrl);
if (!_request) {