mirror of
https://github.com/overte-org/overte.git
synced 2025-08-07 05:59:24 +02:00
Clear resource caches instead of restarting
This commit is contained in:
parent
ed296850e2
commit
ee3a8b1b6e
4 changed files with 19 additions and 4 deletions
|
@ -2414,7 +2414,11 @@ void Application::cameraMenuChanged() {
|
||||||
|
|
||||||
void Application::clearCacheAndRestart() {
|
void Application::clearCacheAndRestart() {
|
||||||
emptyLocalCache();
|
emptyLocalCache();
|
||||||
exit(RESTART_CODE);
|
|
||||||
|
DependencyManager::get<AnimationCache>()->refreshAll();
|
||||||
|
DependencyManager::get<GeometryCache>()->refreshAll();
|
||||||
|
DependencyManager::get<SoundCache>()->refreshAll();
|
||||||
|
DependencyManager::get<TextureCache>()->refreshAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::rotationModeChanged() {
|
void Application::rotationModeChanged() {
|
||||||
|
|
|
@ -101,7 +101,7 @@ void Skybox::render(gpu::Batch& batch, const ViewFrustum& viewFrustum, const Sky
|
||||||
batch.setModelTransform(Transform()); // only for Mac
|
batch.setModelTransform(Transform()); // only for Mac
|
||||||
batch.setPipeline(thePipeline);
|
batch.setPipeline(thePipeline);
|
||||||
batch.setInputBuffer(gpu::Stream::POSITION, theBuffer, 0, 8);
|
batch.setInputBuffer(gpu::Stream::POSITION, theBuffer, 0, 8);
|
||||||
batch.setUniformBuffer(SKYBOX_CONSTANTS_SLOT, theConstants, 0, theConstants->getSize());
|
//batch.setUniformBuffer(SKYBOX_CONSTANTS_SLOT, theConstants, 0, theConstants->getSize());
|
||||||
batch.setInputFormat(theFormat);
|
batch.setInputFormat(theFormat);
|
||||||
batch.setUniformTexture(0, skybox.getCubemap());
|
batch.setUniformTexture(0, skybox.getCubemap());
|
||||||
batch.draw(gpu::TRIANGLE_STRIP, 4);
|
batch.draw(gpu::TRIANGLE_STRIP, 4);
|
||||||
|
|
|
@ -44,10 +44,20 @@ ResourceCache::~ResourceCache() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ResourceCache::refreshAll() {
|
||||||
|
for (auto it = _resources.begin(); it != _resources.end(); ++it) {
|
||||||
|
if (!it.value().isNull()) {
|
||||||
|
it.value().data()->refresh();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ResourceCache::refresh(const QUrl& url) {
|
void ResourceCache::refresh(const QUrl& url) {
|
||||||
QSharedPointer<Resource> resource = _resources.value(url);
|
QSharedPointer<Resource> resource = _resources.value(url);
|
||||||
if (!resource.isNull()) {
|
if (!resource.isNull()) {
|
||||||
resource->refresh();
|
resource->refresh();
|
||||||
|
} else {
|
||||||
|
_resources.remove(url);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -78,7 +78,8 @@ public:
|
||||||
|
|
||||||
ResourceCache(QObject* parent = NULL);
|
ResourceCache(QObject* parent = NULL);
|
||||||
virtual ~ResourceCache();
|
virtual ~ResourceCache();
|
||||||
|
|
||||||
|
void refreshAll();
|
||||||
void refresh(const QUrl& url);
|
void refresh(const QUrl& url);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
@ -110,7 +111,7 @@ protected:
|
||||||
private:
|
private:
|
||||||
friend class Resource;
|
friend class Resource;
|
||||||
|
|
||||||
QHash<QUrl, QWeakPointer<Resource> > _resources;
|
QHash<QUrl, QWeakPointer<Resource>> _resources;
|
||||||
int _lastLRUKey = 0;
|
int _lastLRUKey = 0;
|
||||||
|
|
||||||
static int _requestLimit;
|
static int _requestLimit;
|
||||||
|
|
Loading…
Reference in a new issue