mirror of
https://github.com/overte-org/overte.git
synced 2025-08-10 01:57:43 +02:00
fix skybox loading I think and pull in sabrina's ktx caching fix
This commit is contained in:
parent
9193704173
commit
20841a0eea
1 changed files with 7 additions and 8 deletions
|
@ -335,12 +335,8 @@ int networkTexturePointerMetaTypeId = qRegisterMetaType<QWeakPointer<NetworkText
|
||||||
|
|
||||||
NetworkTexture::NetworkTexture(const QUrl& url) :
|
NetworkTexture::NetworkTexture(const QUrl& url) :
|
||||||
Resource(url),
|
Resource(url),
|
||||||
_type(),
|
|
||||||
_maxNumPixels(100)
|
_maxNumPixels(100)
|
||||||
{
|
{
|
||||||
_textureSource = std::make_shared<gpu::TextureSource>(url);
|
|
||||||
_lowestRequestedMipLevel = 0;
|
|
||||||
_loaded = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NetworkTexture::NetworkTexture(const NetworkTexture& other) :
|
NetworkTexture::NetworkTexture(const NetworkTexture& other) :
|
||||||
|
@ -425,7 +421,7 @@ gpu::TexturePointer NetworkTexture::getFallbackTexture() const {
|
||||||
class ImageReader : public QRunnable {
|
class ImageReader : public QRunnable {
|
||||||
public:
|
public:
|
||||||
ImageReader(const QWeakPointer<Resource>& resource, const QUrl& url,
|
ImageReader(const QWeakPointer<Resource>& resource, const QUrl& url,
|
||||||
const QByteArray& data, int maxNumPixels);
|
const QByteArray& data, size_t extraHash, int maxNumPixels);
|
||||||
void run() override final;
|
void run() override final;
|
||||||
void read();
|
void read();
|
||||||
|
|
||||||
|
@ -435,6 +431,7 @@ private:
|
||||||
QWeakPointer<Resource> _resource;
|
QWeakPointer<Resource> _resource;
|
||||||
QUrl _url;
|
QUrl _url;
|
||||||
QByteArray _content;
|
QByteArray _content;
|
||||||
|
size_t _extraHash;
|
||||||
int _maxNumPixels;
|
int _maxNumPixels;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1068,7 +1065,7 @@ void NetworkTexture::loadTextureContent(const QByteArray& content) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QThreadPool::globalInstance()->start(new ImageReader(_self, _url, content, _maxNumPixels));
|
QThreadPool::globalInstance()->start(new ImageReader(_self, _url, content, _extraHash, _maxNumPixels));
|
||||||
}
|
}
|
||||||
|
|
||||||
void NetworkTexture::refresh() {
|
void NetworkTexture::refresh() {
|
||||||
|
@ -1093,10 +1090,11 @@ void NetworkTexture::refresh() {
|
||||||
Resource::refresh();
|
Resource::refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
ImageReader::ImageReader(const QWeakPointer<Resource>& resource, const QUrl& url, const QByteArray& data, int maxNumPixels) :
|
ImageReader::ImageReader(const QWeakPointer<Resource>& resource, const QUrl& url, const QByteArray& data, size_t extraHash, int maxNumPixels) :
|
||||||
_resource(resource),
|
_resource(resource),
|
||||||
_url(url),
|
_url(url),
|
||||||
_content(data),
|
_content(data),
|
||||||
|
_extraHash(extraHash),
|
||||||
_maxNumPixels(maxNumPixels)
|
_maxNumPixels(maxNumPixels)
|
||||||
{
|
{
|
||||||
DependencyManager::get<StatTracker>()->incrementStat("PendingProcessing");
|
DependencyManager::get<StatTracker>()->incrementStat("PendingProcessing");
|
||||||
|
@ -1152,11 +1150,12 @@ void ImageReader::read() {
|
||||||
}
|
}
|
||||||
auto networkTexture = resource.staticCast<NetworkTexture>();
|
auto networkTexture = resource.staticCast<NetworkTexture>();
|
||||||
|
|
||||||
// Hash the source image to for KTX caching
|
// Hash the source image and extraHash for KTX caching
|
||||||
std::string hash;
|
std::string hash;
|
||||||
{
|
{
|
||||||
QCryptographicHash hasher(QCryptographicHash::Md5);
|
QCryptographicHash hasher(QCryptographicHash::Md5);
|
||||||
hasher.addData(_content);
|
hasher.addData(_content);
|
||||||
|
hasher.addData(std::to_string(_extraHash).c_str());
|
||||||
hash = hasher.result().toHex().toStdString();
|
hash = hasher.result().toHex().toStdString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue