mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 19:52:26 +02:00
Merge remote-tracking branch 'upstream/master' into HEAD
This commit is contained in:
commit
8f2ed2ca5c
5 changed files with 43 additions and 6 deletions
|
@ -2326,7 +2326,9 @@ SelectionDisplay = (function () {
|
|||
|
||||
that.checkMove = function() {
|
||||
if (SelectionManager.hasSelection()) {
|
||||
SelectionManager._update();
|
||||
|
||||
// FIXME - this cause problems with editing in the entity properties window
|
||||
//SelectionManager._update();
|
||||
|
||||
if (!Vec3.equal(Camera.getPosition(), lastCameraPosition) ||
|
||||
!Quat.equal(Camera.getOrientation(), lastCameraOrientation)) {
|
||||
|
|
|
@ -704,7 +704,9 @@ void EntityTreeRenderer::checkAndCallPreload(const EntityItemID& entityID, const
|
|||
if (_tree && !_shuttingDown) {
|
||||
EntityItemPointer entity = getTree()->findEntityByEntityItemID(entityID);
|
||||
if (entity && !entity->getScript().isEmpty()) {
|
||||
_entitiesScriptEngine->loadEntityScript(entityID, entity->getScript(), reload);
|
||||
QString scriptUrl = entity->getScript();
|
||||
scriptUrl = ResourceManager::normalizeURL(scriptUrl);
|
||||
_entitiesScriptEngine->loadEntityScript(entityID, scriptUrl, reload);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,7 +17,30 @@
|
|||
|
||||
#include <SharedUtil.h>
|
||||
|
||||
QUrl ResourceManager::normalizeURL(const QUrl& url) {
|
||||
ResourceManager::PrefixMap ResourceManager::_prefixMap;
|
||||
QMutex ResourceManager::_prefixMapLock;
|
||||
|
||||
|
||||
void ResourceManager::setUrlPrefixOverride(const QString& prefix, const QString& replacement) {
|
||||
QMutexLocker locker(&_prefixMapLock);
|
||||
_prefixMap[prefix] = replacement;
|
||||
}
|
||||
|
||||
QString ResourceManager::normalizeURL(const QString& urlString) {
|
||||
QString result = urlString;
|
||||
QMutexLocker locker(&_prefixMapLock);
|
||||
foreach(const auto& entry, _prefixMap) {
|
||||
const auto& prefix = entry.first;
|
||||
const auto& replacement = entry.second;
|
||||
if (result.startsWith(prefix)) {
|
||||
result.replace(0, prefix.size(), replacement);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
QUrl ResourceManager::normalizeURL(const QUrl& originalUrl) {
|
||||
QUrl url = QUrl(normalizeURL(originalUrl.toString()));
|
||||
auto scheme = url.scheme();
|
||||
if (!(scheme == URL_SCHEME_FILE ||
|
||||
scheme == URL_SCHEME_HTTP || scheme == URL_SCHEME_HTTPS || scheme == URL_SCHEME_FTP ||
|
||||
|
@ -37,11 +60,11 @@ ResourceRequest* ResourceManager::createResourceRequest(QObject* parent, const Q
|
|||
auto normalizedURL = normalizeURL(url);
|
||||
auto scheme = normalizedURL.scheme();
|
||||
if (scheme == URL_SCHEME_FILE) {
|
||||
return new FileResourceRequest(parent, url);
|
||||
return new FileResourceRequest(parent, normalizedURL);
|
||||
} else if (scheme == URL_SCHEME_HTTP || scheme == URL_SCHEME_HTTPS || scheme == URL_SCHEME_FTP) {
|
||||
return new HTTPResourceRequest(parent, url);
|
||||
return new HTTPResourceRequest(parent, normalizedURL);
|
||||
} else if (scheme == URL_SCHEME_ATP) {
|
||||
return new AssetResourceRequest(parent, url);
|
||||
return new AssetResourceRequest(parent, normalizedURL);
|
||||
}
|
||||
|
||||
qDebug() << "Unknown scheme (" << scheme << ") for URL: " << url.url();
|
||||
|
|
|
@ -14,6 +14,8 @@
|
|||
|
||||
#include <functional>
|
||||
|
||||
#include <QtCore/QMutex>
|
||||
|
||||
#include "ResourceRequest.h"
|
||||
|
||||
const QString URL_SCHEME_FILE = "file";
|
||||
|
@ -24,8 +26,15 @@ const QString URL_SCHEME_ATP = "atp";
|
|||
|
||||
class ResourceManager {
|
||||
public:
|
||||
static void setUrlPrefixOverride(const QString& prefix, const QString& replacement);
|
||||
static QString normalizeURL(const QString& urlString);
|
||||
static QUrl normalizeURL(const QUrl& url);
|
||||
static ResourceRequest* createResourceRequest(QObject* parent, const QUrl& url);
|
||||
private:
|
||||
using PrefixMap = std::map<QString, QString>;
|
||||
|
||||
static PrefixMap _prefixMap;
|
||||
static QMutex _prefixMapLock;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -88,6 +88,7 @@ void Procedural::parse(const QJsonObject& proceduralData) {
|
|||
// Get the path to the shader
|
||||
{
|
||||
QString shaderUrl = proceduralData[URL_KEY].toString();
|
||||
shaderUrl = ResourceManager::normalizeURL(shaderUrl);
|
||||
_shaderUrl = QUrl(shaderUrl);
|
||||
if (!_shaderUrl.isValid()) {
|
||||
qWarning() << "Invalid shader URL: " << shaderUrl;
|
||||
|
|
Loading…
Reference in a new issue