mirror of
https://github.com/overte-org/overte.git
synced 2025-04-12 14:42:11 +02:00
Merge pull request #14913 from SamGondelman/pal
Case 21147, Case 20944: Fix setTextures (pal, etc.)
This commit is contained in:
commit
efe2767f3f
7 changed files with 25 additions and 12 deletions
|
@ -61,7 +61,8 @@ class Sound : public Resource {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Sound(const QUrl& url, bool isStereo = false, bool isAmbisonic = false);
|
Sound(const QUrl& url, bool isStereo = false, bool isAmbisonic = false);
|
||||||
|
Sound(const Sound& other) : Resource(other), _audioData(other._audioData), _numChannels(other._numChannels) {}
|
||||||
|
|
||||||
bool isReady() const { return (bool)_audioData; }
|
bool isReady() const { return (bool)_audioData; }
|
||||||
|
|
||||||
bool isStereo() const { return _audioData ? _audioData->isStereo() : false; }
|
bool isStereo() const { return _audioData ? _audioData->isStereo() : false; }
|
||||||
|
|
|
@ -397,8 +397,6 @@ public:
|
||||||
bool isDefined() const { return _defined; }
|
bool isDefined() const { return _defined; }
|
||||||
|
|
||||||
Texture(TextureUsageType usageType);
|
Texture(TextureUsageType usageType);
|
||||||
Texture(const Texture& buf); // deep copy of the sysmem texture
|
|
||||||
Texture& operator=(const Texture& buf); // deep copy of the sysmem texture
|
|
||||||
~Texture();
|
~Texture();
|
||||||
|
|
||||||
Stamp getStamp() const { return _stamp; }
|
Stamp getStamp() const { return _stamp; }
|
||||||
|
@ -693,8 +691,10 @@ class TextureSource {
|
||||||
public:
|
public:
|
||||||
TextureSource(const QUrl& url, int type = 0) : _imageUrl(url), _type(type) {}
|
TextureSource(const QUrl& url, int type = 0) : _imageUrl(url), _type(type) {}
|
||||||
|
|
||||||
|
void setUrl(const QUrl& url) { _imageUrl = url; }
|
||||||
const QUrl& getUrl() const { return _imageUrl; }
|
const QUrl& getUrl() const { return _imageUrl; }
|
||||||
const gpu::TexturePointer getGPUTexture() const { return _gpuTexture; }
|
const gpu::TexturePointer getGPUTexture() const { return _gpuTexture; }
|
||||||
|
void setType(int type) { _type = type; }
|
||||||
int getType() const { return _type; }
|
int getType() const { return _type; }
|
||||||
|
|
||||||
void resetTexture(gpu::TexturePointer texture);
|
void resetTexture(gpu::TexturePointer texture);
|
||||||
|
|
|
@ -121,6 +121,7 @@ public:
|
||||||
/// A texture map.
|
/// A texture map.
|
||||||
class Texture {
|
class Texture {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
QString id;
|
QString id;
|
||||||
QString name;
|
QString name;
|
||||||
QByteArray filename;
|
QByteArray filename;
|
||||||
|
|
|
@ -322,7 +322,7 @@ private:
|
||||||
void GeometryDefinitionResource::setExtra(void* extra) {
|
void GeometryDefinitionResource::setExtra(void* extra) {
|
||||||
const GeometryExtra* geometryExtra = static_cast<const GeometryExtra*>(extra);
|
const GeometryExtra* geometryExtra = static_cast<const GeometryExtra*>(extra);
|
||||||
_mapping = geometryExtra ? geometryExtra->mapping : QVariantHash();
|
_mapping = geometryExtra ? geometryExtra->mapping : QVariantHash();
|
||||||
_textureBaseUrl = resolveTextureBaseUrl(_url, geometryExtra ? geometryExtra->textureBaseUrl : QUrl());
|
_textureBaseUrl = geometryExtra ? resolveTextureBaseUrl(_url, geometryExtra->textureBaseUrl) : QUrl();
|
||||||
_combineParts = geometryExtra ? geometryExtra->combineParts : true;
|
_combineParts = geometryExtra ? geometryExtra->combineParts : true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -336,6 +336,7 @@ int networkTexturePointerMetaTypeId = qRegisterMetaType<QWeakPointer<NetworkText
|
||||||
|
|
||||||
NetworkTexture::NetworkTexture(const QUrl& url, bool resourceTexture) :
|
NetworkTexture::NetworkTexture(const QUrl& url, bool resourceTexture) :
|
||||||
Resource(url),
|
Resource(url),
|
||||||
|
Texture(),
|
||||||
_maxNumPixels(100)
|
_maxNumPixels(100)
|
||||||
{
|
{
|
||||||
if (resourceTexture) {
|
if (resourceTexture) {
|
||||||
|
@ -346,6 +347,7 @@ NetworkTexture::NetworkTexture(const QUrl& url, bool resourceTexture) :
|
||||||
|
|
||||||
NetworkTexture::NetworkTexture(const NetworkTexture& other) :
|
NetworkTexture::NetworkTexture(const NetworkTexture& other) :
|
||||||
Resource(other),
|
Resource(other),
|
||||||
|
Texture(other),
|
||||||
_type(other._type),
|
_type(other._type),
|
||||||
_sourceChannel(other._sourceChannel),
|
_sourceChannel(other._sourceChannel),
|
||||||
_currentlyLoadingResourceType(other._currentlyLoadingResourceType),
|
_currentlyLoadingResourceType(other._currentlyLoadingResourceType),
|
||||||
|
@ -373,7 +375,12 @@ void NetworkTexture::setExtra(void* extra) {
|
||||||
_maxNumPixels = textureExtra ? textureExtra->maxNumPixels : ABSOLUTE_MAX_TEXTURE_NUM_PIXELS;
|
_maxNumPixels = textureExtra ? textureExtra->maxNumPixels : ABSOLUTE_MAX_TEXTURE_NUM_PIXELS;
|
||||||
_sourceChannel = textureExtra ? textureExtra->sourceChannel : image::ColorChannel::NONE;
|
_sourceChannel = textureExtra ? textureExtra->sourceChannel : image::ColorChannel::NONE;
|
||||||
|
|
||||||
_textureSource = std::make_shared<gpu::TextureSource>(_url, (int)_type);
|
if (_textureSource) {
|
||||||
|
_textureSource->setUrl(_url);
|
||||||
|
_textureSource->setType((int)_type);
|
||||||
|
} else {
|
||||||
|
_textureSource = std::make_shared<gpu::TextureSource>(_url, (int)_type);
|
||||||
|
}
|
||||||
_lowestRequestedMipLevel = 0;
|
_lowestRequestedMipLevel = 0;
|
||||||
|
|
||||||
auto fileNameLowercase = _url.fileName().toLower();
|
auto fileNameLowercase = _url.fileName().toLower();
|
||||||
|
|
|
@ -362,7 +362,6 @@ QSharedPointer<Resource> ResourceCache::getResource(const QUrl& url, const QUrl&
|
||||||
resource->moveToThread(qApp->thread());
|
resource->moveToThread(qApp->thread());
|
||||||
connect(resource.data(), &Resource::updateSize, this, &ResourceCache::updateTotalSize);
|
connect(resource.data(), &Resource::updateSize, this, &ResourceCache::updateTotalSize);
|
||||||
resourcesWithExtraHash.insert(extraHash, resource);
|
resourcesWithExtraHash.insert(extraHash, resource);
|
||||||
removeUnusedResource(resource);
|
|
||||||
resource->ensureLoading();
|
resource->ensureLoading();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -404,7 +403,7 @@ void ResourceCache::addUnusedResource(const QSharedPointer<Resource>& resource)
|
||||||
// If it doesn't fit or its size is unknown, remove it from the cache.
|
// If it doesn't fit or its size is unknown, remove it from the cache.
|
||||||
if (resource->getBytes() == 0 || resource->getBytes() > _unusedResourcesMaxSize) {
|
if (resource->getBytes() == 0 || resource->getBytes() > _unusedResourcesMaxSize) {
|
||||||
resource->setCache(nullptr);
|
resource->setCache(nullptr);
|
||||||
removeResource(resource->getURL(), resource->getBytes());
|
removeResource(resource->getURL(), resource->getExtraHash(), resource->getBytes());
|
||||||
resetTotalResourceCounter();
|
resetTotalResourceCounter();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -443,7 +442,7 @@ void ResourceCache::reserveUnusedResource(qint64 resourceSize) {
|
||||||
auto size = it.value()->getBytes();
|
auto size = it.value()->getBytes();
|
||||||
|
|
||||||
locker.unlock();
|
locker.unlock();
|
||||||
removeResource(it.value()->getURL(), size);
|
removeResource(it.value()->getURL(), it.value()->getExtraHash(), size);
|
||||||
locker.relock();
|
locker.relock();
|
||||||
|
|
||||||
_unusedResourcesSize -= size;
|
_unusedResourcesSize -= size;
|
||||||
|
@ -489,9 +488,13 @@ void ResourceCache::resetResourceCounters() {
|
||||||
emit dirty();
|
emit dirty();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ResourceCache::removeResource(const QUrl& url, qint64 size) {
|
void ResourceCache::removeResource(const QUrl& url, size_t extraHash, qint64 size) {
|
||||||
QWriteLocker locker(&_resourcesLock);
|
QWriteLocker locker(&_resourcesLock);
|
||||||
_resources.remove(url);
|
auto& resources = _resources[url];
|
||||||
|
resources.remove(extraHash);
|
||||||
|
if (resources.size() == 0) {
|
||||||
|
_resources.remove(url);
|
||||||
|
}
|
||||||
_totalResourcesSize -= size;
|
_totalResourcesSize -= size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -664,7 +667,7 @@ void Resource::allReferencesCleared() {
|
||||||
} else {
|
} else {
|
||||||
if (_cache) {
|
if (_cache) {
|
||||||
// remove from the cache
|
// remove from the cache
|
||||||
_cache->removeResource(getURL(), getBytes());
|
_cache->removeResource(getURL(), getExtraHash(), getBytes());
|
||||||
_cache->resetTotalResourceCounter();
|
_cache->resetTotalResourceCounter();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -272,7 +272,7 @@ private:
|
||||||
friend class ScriptableResourceCache;
|
friend class ScriptableResourceCache;
|
||||||
|
|
||||||
void reserveUnusedResource(qint64 resourceSize);
|
void reserveUnusedResource(qint64 resourceSize);
|
||||||
void removeResource(const QUrl& url, qint64 size = 0);
|
void removeResource(const QUrl& url, size_t extraHash, qint64 size = 0);
|
||||||
|
|
||||||
void resetTotalResourceCounter();
|
void resetTotalResourceCounter();
|
||||||
void resetUnusedResourceCounter();
|
void resetUnusedResourceCounter();
|
||||||
|
@ -419,6 +419,7 @@ public:
|
||||||
|
|
||||||
virtual void setExtra(void* extra) {};
|
virtual void setExtra(void* extra) {};
|
||||||
void setExtraHash(size_t extraHash) { _extraHash = extraHash; }
|
void setExtraHash(size_t extraHash) { _extraHash = extraHash; }
|
||||||
|
size_t getExtraHash() const { return _extraHash; }
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
/// Fired when the resource begins downloading.
|
/// Fired when the resource begins downloading.
|
||||||
|
|
Loading…
Reference in a new issue