mirror of
https://github.com/overte-org/overte.git
synced 2025-04-14 07:47:30 +02:00
WE DID IT FOLKS
This commit is contained in:
parent
2986ca20c5
commit
44e70db4cd
7 changed files with 39 additions and 19 deletions
|
@ -354,7 +354,8 @@ NetworkTexture::NetworkTexture(const NetworkTexture& other) :
|
||||||
_originalHeight(other._originalHeight),
|
_originalHeight(other._originalHeight),
|
||||||
_width(other._width),
|
_width(other._width),
|
||||||
_height(other._height),
|
_height(other._height),
|
||||||
_maxNumPixels(other._maxNumPixels)
|
_maxNumPixels(other._maxNumPixels),
|
||||||
|
_content(other._content)
|
||||||
{
|
{
|
||||||
if (_width == 0 || _height == 0 ||
|
if (_width == 0 || _height == 0 ||
|
||||||
other._currentlyLoadingResourceType == ResourceType::META ||
|
other._currentlyLoadingResourceType == ResourceType::META ||
|
||||||
|
@ -368,17 +369,30 @@ static bool isLocalUrl(const QUrl& url) {
|
||||||
return (scheme == HIFI_URL_SCHEME_FILE || scheme == URL_SCHEME_QRC || scheme == RESOURCE_SCHEME);
|
return (scheme == HIFI_URL_SCHEME_FILE || scheme == URL_SCHEME_QRC || scheme == RESOURCE_SCHEME);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NetworkTexture::setExtra(void* extra, bool isNewExtra) {
|
void NetworkTexture::setExtra(void* extra) {
|
||||||
const TextureExtra* textureExtra = static_cast<const TextureExtra*>(extra);
|
const TextureExtra* textureExtra = static_cast<const TextureExtra*>(extra);
|
||||||
_type = textureExtra ? textureExtra->type : image::TextureUsage::DEFAULT_TEXTURE;
|
|
||||||
_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;
|
|
||||||
|
|
||||||
if (isNewExtra && !_loaded) {
|
bool needsNewTextureSource = false;
|
||||||
|
auto type = textureExtra ? textureExtra->type : image::TextureUsage::DEFAULT_TEXTURE;
|
||||||
|
auto sourceChannel = textureExtra ? textureExtra->sourceChannel : image::ColorChannel::NONE;
|
||||||
|
if (type != _type || sourceChannel != _sourceChannel) {
|
||||||
|
needsNewTextureSource = true;
|
||||||
|
}
|
||||||
|
_type = type;
|
||||||
|
_sourceChannel = sourceChannel;
|
||||||
|
|
||||||
|
auto content = textureExtra ? textureExtra->content : QByteArray();
|
||||||
|
if (_content.isEmpty() && !content.isEmpty()) {
|
||||||
|
_content = content;
|
||||||
|
needsNewTextureSource = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (needsNewTextureSource) {
|
||||||
_startedLoading = false;
|
_startedLoading = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_textureSource || isNewExtra) {
|
if (!_textureSource || needsNewTextureSource) {
|
||||||
_textureSource = std::make_shared<gpu::TextureSource>(_url, (int)_type);
|
_textureSource = std::make_shared<gpu::TextureSource>(_url, (int)_type);
|
||||||
}
|
}
|
||||||
_lowestRequestedMipLevel = 0;
|
_lowestRequestedMipLevel = 0;
|
||||||
|
@ -405,10 +419,9 @@ void NetworkTexture::setExtra(void* extra, bool isNewExtra) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// if we have content, load it after we have our self pointer
|
// if we have content, load it after we have our self pointer
|
||||||
auto content = textureExtra ? textureExtra->content : QByteArray();
|
if (!_content.isEmpty()) {
|
||||||
if (!content.isEmpty()) {
|
|
||||||
_startedLoading = true;
|
_startedLoading = true;
|
||||||
QMetaObject::invokeMethod(this, "downloadFinished", Qt::QueuedConnection, Q_ARG(const QByteArray&, content));
|
QMetaObject::invokeMethod(this, "downloadFinished", Qt::QueuedConnection, Q_ARG(const QByteArray&, _content));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -64,7 +64,7 @@ public:
|
||||||
|
|
||||||
Q_INVOKABLE void setOriginalDescriptor(ktx::KTXDescriptor* descriptor) { _originalKtxDescriptor.reset(descriptor); }
|
Q_INVOKABLE void setOriginalDescriptor(ktx::KTXDescriptor* descriptor) { _originalKtxDescriptor.reset(descriptor); }
|
||||||
|
|
||||||
void setExtra(void* extra, bool isNewExtra) override;
|
void setExtra(void* extra) override;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void networkTextureCreated(const QWeakPointer<NetworkTexture>& self);
|
void networkTextureCreated(const QWeakPointer<NetworkTexture>& self);
|
||||||
|
@ -136,12 +136,12 @@ private:
|
||||||
// mip offsets to change.
|
// mip offsets to change.
|
||||||
ktx::KTXDescriptorPointer _originalKtxDescriptor;
|
ktx::KTXDescriptorPointer _originalKtxDescriptor;
|
||||||
|
|
||||||
|
|
||||||
int _originalWidth { 0 };
|
int _originalWidth { 0 };
|
||||||
int _originalHeight { 0 };
|
int _originalHeight { 0 };
|
||||||
int _width { 0 };
|
int _width { 0 };
|
||||||
int _height { 0 };
|
int _height { 0 };
|
||||||
int _maxNumPixels { ABSOLUTE_MAX_TEXTURE_NUM_PIXELS };
|
int _maxNumPixels { ABSOLUTE_MAX_TEXTURE_NUM_PIXELS };
|
||||||
|
QByteArray _content;
|
||||||
|
|
||||||
friend class TextureCache;
|
friend class TextureCache;
|
||||||
};
|
};
|
||||||
|
|
|
@ -309,7 +309,7 @@ public:
|
||||||
|
|
||||||
virtual void downloadFinished(const QByteArray& data) override;
|
virtual void downloadFinished(const QByteArray& data) override;
|
||||||
|
|
||||||
void setExtra(void* extra, bool isNewExtra) override;
|
void setExtra(void* extra) override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Q_INVOKABLE void setGeometryDefinition(HFMModel::Pointer hfmModel, QVariantHash mapping);
|
Q_INVOKABLE void setGeometryDefinition(HFMModel::Pointer hfmModel, QVariantHash mapping);
|
||||||
|
@ -320,7 +320,7 @@ private:
|
||||||
bool _combineParts;
|
bool _combineParts;
|
||||||
};
|
};
|
||||||
|
|
||||||
void GeometryDefinitionResource::setExtra(void* extra, bool isNewExtra) {
|
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 = geometryExtra ? resolveTextureBaseUrl(_url, geometryExtra->textureBaseUrl) : QUrl();
|
_textureBaseUrl = geometryExtra ? resolveTextureBaseUrl(_url, geometryExtra->textureBaseUrl) : QUrl();
|
||||||
|
|
|
@ -355,7 +355,7 @@ QSharedPointer<Resource> ResourceCache::getResource(const QUrl& url, const QUrl&
|
||||||
} else if (resourcesWithExtraHash.size() > 0.0f) {
|
} else if (resourcesWithExtraHash.size() > 0.0f) {
|
||||||
// We haven't seen this extra info before, but we've already downloaded the resource. We need a new copy of this object (with any old hash).
|
// We haven't seen this extra info before, but we've already downloaded the resource. We need a new copy of this object (with any old hash).
|
||||||
resource = createResourceCopy(resourcesWithExtraHash.begin().value().lock());
|
resource = createResourceCopy(resourcesWithExtraHash.begin().value().lock());
|
||||||
resource->setExtra(extra, true);
|
resource->setExtra(extra);
|
||||||
resource->setExtraHash(extraHash);
|
resource->setExtraHash(extraHash);
|
||||||
resource->setSelf(resource);
|
resource->setSelf(resource);
|
||||||
resource->setCache(this);
|
resource->setCache(this);
|
||||||
|
@ -375,7 +375,7 @@ QSharedPointer<Resource> ResourceCache::getResource(const QUrl& url, const QUrl&
|
||||||
|
|
||||||
if (!resource) {
|
if (!resource) {
|
||||||
resource = createResource(url);
|
resource = createResource(url);
|
||||||
resource->setExtra(extra, false);
|
resource->setExtra(extra);
|
||||||
resource->setExtraHash(extraHash);
|
resource->setExtraHash(extraHash);
|
||||||
resource->setSelf(resource);
|
resource->setSelf(resource);
|
||||||
resource->setCache(this);
|
resource->setCache(this);
|
||||||
|
|
|
@ -417,7 +417,7 @@ public:
|
||||||
unsigned int getDownloadAttempts() { return _attempts; }
|
unsigned int getDownloadAttempts() { return _attempts; }
|
||||||
unsigned int getDownloadAttemptsRemaining() { return _attemptsRemaining; }
|
unsigned int getDownloadAttemptsRemaining() { return _attemptsRemaining; }
|
||||||
|
|
||||||
virtual void setExtra(void* extra, bool isNewExtra) {};
|
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; }
|
size_t getExtraHash() const { return _extraHash; }
|
||||||
|
|
||||||
|
|
|
@ -1269,7 +1269,14 @@ QVariantMap parseTexturesToMap(QString newTextures, const QVariantMap& defaultTe
|
||||||
QVariantMap newTexturesMap = newTexturesJson.toVariant().toMap();
|
QVariantMap newTexturesMap = newTexturesJson.toVariant().toMap();
|
||||||
QVariantMap toReturn = defaultTextures;
|
QVariantMap toReturn = defaultTextures;
|
||||||
for (auto& texture : newTexturesMap.keys()) {
|
for (auto& texture : newTexturesMap.keys()) {
|
||||||
toReturn[texture] = newTexturesMap[texture];
|
auto newURL = newTexturesMap[texture];
|
||||||
|
if (newURL.canConvert<QUrl>()) {
|
||||||
|
toReturn[texture] = newURL.toUrl();
|
||||||
|
} else if (newURL.canConvert<QString>()) {
|
||||||
|
toReturn[texture] = QUrl(newURL.toString());
|
||||||
|
} else {
|
||||||
|
toReturn[texture] = newURL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return toReturn;
|
return toReturn;
|
||||||
|
|
|
@ -26,10 +26,10 @@ QScriptValue variantToScriptValue(QVariant& qValue, QScriptEngine& scriptEngine)
|
||||||
case QVariant::Double:
|
case QVariant::Double:
|
||||||
return qValue.toDouble();
|
return qValue.toDouble();
|
||||||
break;
|
break;
|
||||||
case QVariant::String: {
|
case QVariant::String:
|
||||||
|
case QVariant::Url:
|
||||||
return scriptEngine.newVariant(qValue);
|
return scriptEngine.newVariant(qValue);
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
case QVariant::Map: {
|
case QVariant::Map: {
|
||||||
QVariantMap childMap = qValue.toMap();
|
QVariantMap childMap = qValue.toMap();
|
||||||
return variantMapToScriptValue(childMap, scriptEngine);
|
return variantMapToScriptValue(childMap, scriptEngine);
|
||||||
|
|
Loading…
Reference in a new issue