mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-19 23:23:52 +00:00
Merge pull request #1406 from Aesylwinn/reloadassets
Editor: Asset Reloading
This commit is contained in:
commit
aa95cb3d91
44 changed files with 309 additions and 64 deletions
|
@ -5,9 +5,6 @@
|
||||||
#include <QLocalSocket>
|
#include <QLocalSocket>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
|
||||||
#include <components/vfs/manager.hpp>
|
|
||||||
#include <components/vfs/registerarchives.hpp>
|
|
||||||
|
|
||||||
#include <components/fallback/validate.hpp>
|
#include <components/fallback/validate.hpp>
|
||||||
|
|
||||||
#include <components/nifosg/nifloader.hpp>
|
#include <components/nifosg/nifloader.hpp>
|
||||||
|
@ -33,11 +30,7 @@ CS::Editor::Editor ()
|
||||||
|
|
||||||
NifOsg::Loader::setShowMarkers(true);
|
NifOsg::Loader::setShowMarkers(true);
|
||||||
|
|
||||||
mVFS.reset(new VFS::Manager(mFsStrict));
|
mDocumentManager.setFileData(mFsStrict, config.first, config.second);
|
||||||
|
|
||||||
VFS::registerArchives(mVFS.get(), Files::Collections(config.first, !mFsStrict), config.second, true);
|
|
||||||
|
|
||||||
mDocumentManager.setVFS(mVFS.get());
|
|
||||||
|
|
||||||
mNewGame.setLocalData (mLocal);
|
mNewGame.setLocalData (mLocal);
|
||||||
mFileDialog.setLocalData (mLocal);
|
mFileDialog.setLocalData (mLocal);
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
#ifndef CS_EDITOR_H
|
#ifndef CS_EDITOR_H
|
||||||
#define CS_EDITOR_H
|
#define CS_EDITOR_H
|
||||||
|
|
||||||
#include <memory>
|
|
||||||
|
|
||||||
#include <boost/interprocess/sync/file_lock.hpp>
|
#include <boost/interprocess/sync/file_lock.hpp>
|
||||||
#include <boost/filesystem/fstream.hpp>
|
#include <boost/filesystem/fstream.hpp>
|
||||||
|
|
||||||
|
@ -30,11 +28,6 @@
|
||||||
|
|
||||||
#include "view/tools/merge.hpp"
|
#include "view/tools/merge.hpp"
|
||||||
|
|
||||||
namespace VFS
|
|
||||||
{
|
|
||||||
class Manager;
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace CSMDoc
|
namespace CSMDoc
|
||||||
{
|
{
|
||||||
class Document;
|
class Document;
|
||||||
|
@ -46,9 +39,6 @@ namespace CS
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
// FIXME: should be moved to document, so we can have different resources for each opened project
|
|
||||||
std::unique_ptr<VFS::Manager> mVFS;
|
|
||||||
|
|
||||||
Files::ConfigurationManager mCfgMgr;
|
Files::ConfigurationManager mCfgMgr;
|
||||||
CSMPrefs::State mSettingsState;
|
CSMPrefs::State mSettingsState;
|
||||||
CSMDoc::DocumentManager mDocumentManager;
|
CSMDoc::DocumentManager mDocumentManager;
|
||||||
|
|
|
@ -269,13 +269,14 @@ void CSMDoc::Document::createBase()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CSMDoc::Document::Document (const VFS::Manager* vfs, const Files::ConfigurationManager& configuration,
|
CSMDoc::Document::Document (const Files::ConfigurationManager& configuration,
|
||||||
const std::vector< boost::filesystem::path >& files, bool new_,
|
const std::vector< boost::filesystem::path >& files,bool new_,
|
||||||
const boost::filesystem::path& savePath, const boost::filesystem::path& resDir,
|
const boost::filesystem::path& savePath, const boost::filesystem::path& resDir,
|
||||||
const Fallback::Map* fallback,
|
const Fallback::Map* fallback,
|
||||||
ToUTF8::FromType encoding, const CSMWorld::ResourcesManager& resourcesManager,
|
ToUTF8::FromType encoding,
|
||||||
const std::vector<std::string>& blacklistedScripts)
|
const std::vector<std::string>& blacklistedScripts,
|
||||||
: mVFS(vfs), mSavePath (savePath), mContentFiles (files), mNew (new_), mData (encoding, resourcesManager, fallback, resDir),
|
bool fsStrict, const Files::PathContainer& dataPaths, const std::vector<std::string>& archives)
|
||||||
|
: mSavePath (savePath), mContentFiles (files), mNew (new_), mData (encoding, fsStrict, dataPaths, archives, fallback, resDir),
|
||||||
mTools (*this, encoding),
|
mTools (*this, encoding),
|
||||||
mProjectPath ((configuration.getUserDataPath() / "projects") /
|
mProjectPath ((configuration.getUserDataPath() / "projects") /
|
||||||
(savePath.filename().string() + ".project")),
|
(savePath.filename().string() + ".project")),
|
||||||
|
@ -337,11 +338,6 @@ CSMDoc::Document::~Document()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
const VFS::Manager *CSMDoc::Document::getVFS() const
|
|
||||||
{
|
|
||||||
return mVFS;
|
|
||||||
}
|
|
||||||
|
|
||||||
QUndoStack& CSMDoc::Document::getUndoStack()
|
QUndoStack& CSMDoc::Document::getUndoStack()
|
||||||
{
|
{
|
||||||
return mUndoStack;
|
return mUndoStack;
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
|
||||||
|
#include <components/files/multidircollection.hpp>
|
||||||
#include <components/to_utf8/to_utf8.hpp>
|
#include <components/to_utf8/to_utf8.hpp>
|
||||||
|
|
||||||
#include "../world/data.hpp"
|
#include "../world/data.hpp"
|
||||||
|
@ -59,7 +60,6 @@ namespace CSMDoc
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
const VFS::Manager* mVFS;
|
|
||||||
boost::filesystem::path mSavePath;
|
boost::filesystem::path mSavePath;
|
||||||
std::vector<boost::filesystem::path> mContentFiles;
|
std::vector<boost::filesystem::path> mContentFiles;
|
||||||
bool mNew;
|
bool mNew;
|
||||||
|
@ -102,17 +102,15 @@ namespace CSMDoc
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
Document (const VFS::Manager* vfs, const Files::ConfigurationManager& configuration,
|
Document (const Files::ConfigurationManager& configuration,
|
||||||
const std::vector< boost::filesystem::path >& files, bool new_,
|
const std::vector< boost::filesystem::path >& files, bool new_,
|
||||||
const boost::filesystem::path& savePath, const boost::filesystem::path& resDir,
|
const boost::filesystem::path& savePath, const boost::filesystem::path& resDir,
|
||||||
const Fallback::Map* fallback,
|
const Fallback::Map* fallback, ToUTF8::FromType encoding,
|
||||||
ToUTF8::FromType encoding, const CSMWorld::ResourcesManager& resourcesManager,
|
const std::vector<std::string>& blacklistedScripts,
|
||||||
const std::vector<std::string>& blacklistedScripts);
|
bool fsStrict, const Files::PathContainer& dataPaths, const std::vector<std::string>& archives);
|
||||||
|
|
||||||
~Document();
|
~Document();
|
||||||
|
|
||||||
const VFS::Manager* getVFS() const;
|
|
||||||
|
|
||||||
QUndoStack& getUndoStack();
|
QUndoStack& getUndoStack();
|
||||||
|
|
||||||
int getState() const;
|
int getState() const;
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
#include "document.hpp"
|
#include "document.hpp"
|
||||||
|
|
||||||
CSMDoc::DocumentManager::DocumentManager (const Files::ConfigurationManager& configuration)
|
CSMDoc::DocumentManager::DocumentManager (const Files::ConfigurationManager& configuration)
|
||||||
: mConfiguration (configuration), mEncoding (ToUTF8::WINDOWS_1252), mVFS(NULL)
|
: mConfiguration (configuration), mEncoding (ToUTF8::WINDOWS_1252)
|
||||||
{
|
{
|
||||||
boost::filesystem::path projectPath = configuration.getUserDataPath() / "projects";
|
boost::filesystem::path projectPath = configuration.getUserDataPath() / "projects";
|
||||||
|
|
||||||
|
@ -62,7 +62,7 @@ CSMDoc::Document *CSMDoc::DocumentManager::makeDocument (
|
||||||
const std::vector< boost::filesystem::path >& files,
|
const std::vector< boost::filesystem::path >& files,
|
||||||
const boost::filesystem::path& savePath, bool new_)
|
const boost::filesystem::path& savePath, bool new_)
|
||||||
{
|
{
|
||||||
return new Document (mVFS, mConfiguration, files, new_, savePath, mResDir, &mFallbackMap, mEncoding, mResourcesManager, mBlacklistedScripts);
|
return new Document (mConfiguration, files, new_, savePath, mResDir, &mFallbackMap, mEncoding, mBlacklistedScripts, mFsStrict, mDataPaths, mArchives);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSMDoc::DocumentManager::insertDocument (CSMDoc::Document *document)
|
void CSMDoc::DocumentManager::insertDocument (CSMDoc::Document *document)
|
||||||
|
@ -127,8 +127,9 @@ void CSMDoc::DocumentManager::documentNotLoaded (Document *document, const std::
|
||||||
removeDocument (document);
|
removeDocument (document);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSMDoc::DocumentManager::setVFS(const VFS::Manager *vfs)
|
void CSMDoc::DocumentManager::setFileData(bool strict, const Files::PathContainer& dataPaths, const std::vector<std::string>& archives)
|
||||||
{
|
{
|
||||||
mResourcesManager.setVFS(vfs);
|
mFsStrict = strict;
|
||||||
mVFS = vfs;
|
mDataPaths = dataPaths;
|
||||||
|
mArchives = archives;
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,8 +11,7 @@
|
||||||
|
|
||||||
#include <components/to_utf8/to_utf8.hpp>
|
#include <components/to_utf8/to_utf8.hpp>
|
||||||
#include <components/fallback/fallback.hpp>
|
#include <components/fallback/fallback.hpp>
|
||||||
|
#include <components/files/multidircollection.hpp>
|
||||||
#include "../world/resourcesmanager.hpp"
|
|
||||||
|
|
||||||
#include "loader.hpp"
|
#include "loader.hpp"
|
||||||
|
|
||||||
|
@ -39,9 +38,14 @@ namespace CSMDoc
|
||||||
QThread mLoaderThread;
|
QThread mLoaderThread;
|
||||||
Loader mLoader;
|
Loader mLoader;
|
||||||
ToUTF8::FromType mEncoding;
|
ToUTF8::FromType mEncoding;
|
||||||
CSMWorld::ResourcesManager mResourcesManager;
|
|
||||||
std::vector<std::string> mBlacklistedScripts;
|
std::vector<std::string> mBlacklistedScripts;
|
||||||
const VFS::Manager* mVFS;
|
|
||||||
|
boost::filesystem::path mResDir;
|
||||||
|
Fallback::Map mFallbackMap;
|
||||||
|
|
||||||
|
bool mFsStrict;
|
||||||
|
Files::PathContainer mDataPaths;
|
||||||
|
std::vector<std::string> mArchives;
|
||||||
|
|
||||||
DocumentManager (const DocumentManager&);
|
DocumentManager (const DocumentManager&);
|
||||||
DocumentManager& operator= (const DocumentManager&);
|
DocumentManager& operator= (const DocumentManager&);
|
||||||
|
@ -74,15 +78,11 @@ namespace CSMDoc
|
||||||
|
|
||||||
void setBlacklistedScripts (const std::vector<std::string>& scriptIds);
|
void setBlacklistedScripts (const std::vector<std::string>& scriptIds);
|
||||||
|
|
||||||
void setVFS(const VFS::Manager* vfs);
|
/// Sets the file data that gets passed to newly created documents.
|
||||||
|
void setFileData(bool strict, const Files::PathContainer& dataPaths, const std::vector<std::string>& archives);
|
||||||
|
|
||||||
bool isEmpty();
|
bool isEmpty();
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
boost::filesystem::path mResDir;
|
|
||||||
Fallback::Map mFallbackMap;
|
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
|
||||||
void documentLoaded (Document *document);
|
void documentLoaded (Document *document);
|
||||||
|
|
|
@ -259,6 +259,7 @@ void CSMPrefs::State::declare()
|
||||||
declareShortcut ("document-character-topicinfos", "Open Topic Info List", QKeySequence());
|
declareShortcut ("document-character-topicinfos", "Open Topic Info List", QKeySequence());
|
||||||
declareShortcut ("document-character-journalinfos", "Open Journal Info List", QKeySequence());
|
declareShortcut ("document-character-journalinfos", "Open Journal Info List", QKeySequence());
|
||||||
declareShortcut ("document-character-bodyparts", "Open Body Part List", QKeySequence());
|
declareShortcut ("document-character-bodyparts", "Open Body Part List", QKeySequence());
|
||||||
|
declareShortcut ("document-assets-reload", "Reload Assets", QKeySequence(Qt::Key_F5));
|
||||||
declareShortcut ("document-assets-sounds", "Open Sound Asset List", QKeySequence());
|
declareShortcut ("document-assets-sounds", "Open Sound Asset List", QKeySequence());
|
||||||
declareShortcut ("document-assets-soundgens", "Open Sound Generator List", QKeySequence());
|
declareShortcut ("document-assets-soundgens", "Open Sound Generator List", QKeySequence());
|
||||||
declareShortcut ("document-assets-meshes", "Open Mesh Asset List", QKeySequence());
|
declareShortcut ("document-assets-meshes", "Open Mesh Asset List", QKeySequence());
|
||||||
|
|
|
@ -11,6 +11,8 @@
|
||||||
#include <components/esm/cellref.hpp>
|
#include <components/esm/cellref.hpp>
|
||||||
|
|
||||||
#include <components/resource/scenemanager.hpp>
|
#include <components/resource/scenemanager.hpp>
|
||||||
|
#include <components/vfs/manager.hpp>
|
||||||
|
#include <components/vfs/registerarchives.hpp>
|
||||||
|
|
||||||
#include "idtable.hpp"
|
#include "idtable.hpp"
|
||||||
#include "idtree.hpp"
|
#include "idtree.hpp"
|
||||||
|
@ -61,11 +63,18 @@ int CSMWorld::Data::count (RecordBase::State state, const CollectionBase& collec
|
||||||
return number;
|
return number;
|
||||||
}
|
}
|
||||||
|
|
||||||
CSMWorld::Data::Data (ToUTF8::FromType encoding, const ResourcesManager& resourcesManager, const Fallback::Map* fallback, const boost::filesystem::path& resDir)
|
CSMWorld::Data::Data (ToUTF8::FromType encoding, bool fsStrict, const Files::PathContainer& dataPaths,
|
||||||
|
const std::vector<std::string>& archives, const Fallback::Map* fallback, const boost::filesystem::path& resDir)
|
||||||
: mEncoder (encoding), mPathgrids (mCells), mRefs (mCells),
|
: mEncoder (encoding), mPathgrids (mCells), mRefs (mCells),
|
||||||
mResourcesManager (resourcesManager), mFallbackMap(fallback),
|
mFallbackMap(fallback), mReader (0), mDialogue (0), mReaderIndex(1),
|
||||||
mReader (0), mDialogue (0), mReaderIndex(1), mResourceSystem(new Resource::ResourceSystem(resourcesManager.getVFS()))
|
mFsStrict(fsStrict), mDataPaths(dataPaths), mArchives(archives)
|
||||||
{
|
{
|
||||||
|
mVFS.reset(new VFS::Manager(mFsStrict));
|
||||||
|
VFS::registerArchives(mVFS.get(), Files::Collections(mDataPaths, !mFsStrict), mArchives, true);
|
||||||
|
|
||||||
|
mResourcesManager.setVFS(mVFS.get());
|
||||||
|
mResourceSystem.reset(new Resource::ResourceSystem(mVFS.get()));
|
||||||
|
|
||||||
mResourceSystem->getSceneManager()->setShaderPath((resDir / "shaders").string());
|
mResourceSystem->getSceneManager()->setShaderPath((resDir / "shaders").string());
|
||||||
|
|
||||||
int index = 0;
|
int index = 0;
|
||||||
|
@ -1215,6 +1224,43 @@ std::vector<std::string> CSMWorld::Data::getIds (bool listDeleted) const
|
||||||
return ids;
|
return ids;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CSMWorld::Data::assetsChanged()
|
||||||
|
{
|
||||||
|
mVFS.get()->reset();
|
||||||
|
VFS::registerArchives(mVFS.get(), Files::Collections(mDataPaths, !mFsStrict), mArchives, true);
|
||||||
|
|
||||||
|
const UniversalId assetTableIds[] = {
|
||||||
|
UniversalId::Type_Meshes,
|
||||||
|
UniversalId::Type_Icons,
|
||||||
|
UniversalId::Type_Musics,
|
||||||
|
UniversalId::Type_SoundsRes,
|
||||||
|
UniversalId::Type_Textures,
|
||||||
|
UniversalId::Type_Videos
|
||||||
|
};
|
||||||
|
|
||||||
|
size_t numAssetTables = sizeof(assetTableIds) / sizeof(UniversalId);
|
||||||
|
|
||||||
|
for (size_t i = 0; i < numAssetTables; ++i)
|
||||||
|
{
|
||||||
|
ResourceTable* table = static_cast<ResourceTable*>(getTableModel(assetTableIds[i]));
|
||||||
|
table->beginReset();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Trigger recreation
|
||||||
|
mResourcesManager.recreateResources();
|
||||||
|
|
||||||
|
for (size_t i = 0; i < numAssetTables; ++i)
|
||||||
|
{
|
||||||
|
ResourceTable* table = static_cast<ResourceTable*>(getTableModel(assetTableIds[i]));
|
||||||
|
table->endReset();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get rid of potentially old cached assets
|
||||||
|
mResourceSystem->clearCache();
|
||||||
|
|
||||||
|
emit assetTablesChanged();
|
||||||
|
}
|
||||||
|
|
||||||
void CSMWorld::Data::dataChanged (const QModelIndex& topLeft, const QModelIndex& bottomRight)
|
void CSMWorld::Data::dataChanged (const QModelIndex& topLeft, const QModelIndex& bottomRight)
|
||||||
{
|
{
|
||||||
if (topLeft.column()<=0)
|
if (topLeft.column()<=0)
|
||||||
|
@ -1228,7 +1274,7 @@ void CSMWorld::Data::rowsChanged (const QModelIndex& parent, int start, int end)
|
||||||
|
|
||||||
const VFS::Manager* CSMWorld::Data::getVFS() const
|
const VFS::Manager* CSMWorld::Data::getVFS() const
|
||||||
{
|
{
|
||||||
return mResourcesManager.getVFS();
|
return mVFS.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
const Fallback::Map* CSMWorld::Data::getFallbackMap() const
|
const Fallback::Map* CSMWorld::Data::getFallbackMap() const
|
||||||
|
|
|
@ -31,6 +31,7 @@
|
||||||
|
|
||||||
#include <components/resource/resourcesystem.hpp>
|
#include <components/resource/resourcesystem.hpp>
|
||||||
|
|
||||||
|
#include <components/files/multidircollection.hpp>
|
||||||
#include <components/to_utf8/to_utf8.hpp>
|
#include <components/to_utf8/to_utf8.hpp>
|
||||||
|
|
||||||
#include "../doc/stage.hpp"
|
#include "../doc/stage.hpp"
|
||||||
|
@ -46,6 +47,7 @@
|
||||||
#include "infocollection.hpp"
|
#include "infocollection.hpp"
|
||||||
#include "nestedinfocollection.hpp"
|
#include "nestedinfocollection.hpp"
|
||||||
#include "pathgrid.hpp"
|
#include "pathgrid.hpp"
|
||||||
|
#include "resourcesmanager.hpp"
|
||||||
#include "metadata.hpp"
|
#include "metadata.hpp"
|
||||||
#ifndef Q_MOC_RUN
|
#ifndef Q_MOC_RUN
|
||||||
#include "subcellcollection.hpp"
|
#include "subcellcollection.hpp"
|
||||||
|
@ -108,7 +110,6 @@ namespace CSMWorld
|
||||||
RefCollection mRefs;
|
RefCollection mRefs;
|
||||||
IdCollection<ESM::Filter> mFilters;
|
IdCollection<ESM::Filter> mFilters;
|
||||||
Collection<MetaData> mMetaData;
|
Collection<MetaData> mMetaData;
|
||||||
const ResourcesManager& mResourcesManager;
|
|
||||||
const Fallback::Map* mFallbackMap;
|
const Fallback::Map* mFallbackMap;
|
||||||
std::vector<QAbstractItemModel *> mModels;
|
std::vector<QAbstractItemModel *> mModels;
|
||||||
std::map<UniversalId::Type, QAbstractItemModel *> mModelIndex;
|
std::map<UniversalId::Type, QAbstractItemModel *> mModelIndex;
|
||||||
|
@ -119,6 +120,11 @@ namespace CSMWorld
|
||||||
std::map<std::string, std::map<ESM::RefNum, std::string> > mRefLoadCache;
|
std::map<std::string, std::map<ESM::RefNum, std::string> > mRefLoadCache;
|
||||||
int mReaderIndex;
|
int mReaderIndex;
|
||||||
|
|
||||||
|
bool mFsStrict;
|
||||||
|
Files::PathContainer mDataPaths;
|
||||||
|
std::vector<std::string> mArchives;
|
||||||
|
std::unique_ptr<VFS::Manager> mVFS;
|
||||||
|
ResourcesManager mResourcesManager;
|
||||||
std::shared_ptr<Resource::ResourceSystem> mResourceSystem;
|
std::shared_ptr<Resource::ResourceSystem> mResourceSystem;
|
||||||
|
|
||||||
std::vector<std::shared_ptr<ESM::ESMReader> > mReaders;
|
std::vector<std::shared_ptr<ESM::ESMReader> > mReaders;
|
||||||
|
@ -140,7 +146,9 @@ namespace CSMWorld
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
Data (ToUTF8::FromType encoding, const ResourcesManager& resourcesManager, const Fallback::Map* fallback, const boost::filesystem::path& resDir);
|
Data (ToUTF8::FromType encoding, bool fsStrict, const Files::PathContainer& dataPaths,
|
||||||
|
const std::vector<std::string>& archives, const Fallback::Map* fallback,
|
||||||
|
const boost::filesystem::path& resDir);
|
||||||
|
|
||||||
virtual ~Data();
|
virtual ~Data();
|
||||||
|
|
||||||
|
@ -304,8 +312,12 @@ namespace CSMWorld
|
||||||
|
|
||||||
void idListChanged();
|
void idListChanged();
|
||||||
|
|
||||||
|
void assetTablesChanged();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
|
||||||
|
void assetsChanged();
|
||||||
|
|
||||||
void dataChanged (const QModelIndex& topLeft, const QModelIndex& bottomRight);
|
void dataChanged (const QModelIndex& topLeft, const QModelIndex& bottomRight);
|
||||||
|
|
||||||
void rowsChanged (const QModelIndex& parent, int start, int end);
|
void rowsChanged (const QModelIndex& parent, int start, int end);
|
||||||
|
|
|
@ -12,6 +12,14 @@ CSMWorld::Resources::Resources (const VFS::Manager* vfs, const std::string& base
|
||||||
const char * const *extensions)
|
const char * const *extensions)
|
||||||
: mBaseDirectory (baseDirectory), mType (type)
|
: mBaseDirectory (baseDirectory), mType (type)
|
||||||
{
|
{
|
||||||
|
recreate(vfs, extensions);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSMWorld::Resources::recreate(const VFS::Manager* vfs, const char * const *extensions)
|
||||||
|
{
|
||||||
|
mFiles.clear();
|
||||||
|
mIndex.clear();
|
||||||
|
|
||||||
int baseSize = mBaseDirectory.size();
|
int baseSize = mBaseDirectory.size();
|
||||||
|
|
||||||
const std::map<std::string, VFS::File*>& index = vfs->getIndex();
|
const std::map<std::string, VFS::File*>& index = vfs->getIndex();
|
||||||
|
|
|
@ -27,6 +27,8 @@ namespace CSMWorld
|
||||||
Resources (const VFS::Manager* vfs, const std::string& baseDirectory, UniversalId::Type type,
|
Resources (const VFS::Manager* vfs, const std::string& baseDirectory, UniversalId::Type type,
|
||||||
const char * const *extensions = 0);
|
const char * const *extensions = 0);
|
||||||
|
|
||||||
|
void recreate(const VFS::Manager* vfs, const char * const *extensions = 0);
|
||||||
|
|
||||||
int getSize() const;
|
int getSize() const;
|
||||||
|
|
||||||
std::string getId (int index) const;
|
std::string getId (int index) const;
|
||||||
|
|
|
@ -14,16 +14,19 @@ void CSMWorld::ResourcesManager::addResources (const Resources& resources)
|
||||||
resources));
|
resources));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char * const * CSMWorld::ResourcesManager::getMeshExtensions()
|
||||||
|
{
|
||||||
|
// maybe we could go over the osgDB::Registry to list all supported node formats
|
||||||
|
static const char * const sMeshTypes[] = { "nif", "osg", "osgt", "osgb", "osgx", "osg2", 0 };
|
||||||
|
return sMeshTypes;
|
||||||
|
}
|
||||||
|
|
||||||
void CSMWorld::ResourcesManager::setVFS(const VFS::Manager *vfs)
|
void CSMWorld::ResourcesManager::setVFS(const VFS::Manager *vfs)
|
||||||
{
|
{
|
||||||
mVFS = vfs;
|
mVFS = vfs;
|
||||||
mResources.clear();
|
mResources.clear();
|
||||||
|
|
||||||
// maybe we could go over the osgDB::Registry to list all supported node formats
|
addResources (Resources (vfs, "meshes", UniversalId::Type_Mesh, getMeshExtensions()));
|
||||||
|
|
||||||
static const char * const sMeshTypes[] = { "nif", "osg", "osgt", "osgb", "osgx", "osg2", 0 };
|
|
||||||
|
|
||||||
addResources (Resources (vfs, "meshes", UniversalId::Type_Mesh, sMeshTypes));
|
|
||||||
addResources (Resources (vfs, "icons", UniversalId::Type_Icon));
|
addResources (Resources (vfs, "icons", UniversalId::Type_Icon));
|
||||||
addResources (Resources (vfs, "music", UniversalId::Type_Music));
|
addResources (Resources (vfs, "music", UniversalId::Type_Music));
|
||||||
addResources (Resources (vfs, "sound", UniversalId::Type_SoundRes));
|
addResources (Resources (vfs, "sound", UniversalId::Type_SoundRes));
|
||||||
|
@ -36,6 +39,18 @@ const VFS::Manager* CSMWorld::ResourcesManager::getVFS() const
|
||||||
return mVFS;
|
return mVFS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CSMWorld::ResourcesManager::recreateResources()
|
||||||
|
{
|
||||||
|
std::map<UniversalId::Type, Resources>::iterator it = mResources.begin();
|
||||||
|
for ( ; it != mResources.end(); ++it)
|
||||||
|
{
|
||||||
|
if (it->first == UniversalId::Type_Mesh)
|
||||||
|
it->second.recreate(mVFS, getMeshExtensions());
|
||||||
|
else
|
||||||
|
it->second.recreate(mVFS);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const CSMWorld::Resources& CSMWorld::ResourcesManager::get (UniversalId::Type type) const
|
const CSMWorld::Resources& CSMWorld::ResourcesManager::get (UniversalId::Type type) const
|
||||||
{
|
{
|
||||||
std::map<UniversalId::Type, Resources>::const_iterator iter = mResources.find (type);
|
std::map<UniversalId::Type, Resources>::const_iterator iter = mResources.find (type);
|
||||||
|
|
|
@ -22,6 +22,8 @@ namespace CSMWorld
|
||||||
|
|
||||||
void addResources (const Resources& resources);
|
void addResources (const Resources& resources);
|
||||||
|
|
||||||
|
const char * const * getMeshExtensions();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
ResourcesManager();
|
ResourcesManager();
|
||||||
|
@ -30,6 +32,8 @@ namespace CSMWorld
|
||||||
|
|
||||||
void setVFS(const VFS::Manager* vfs);
|
void setVFS(const VFS::Manager* vfs);
|
||||||
|
|
||||||
|
void recreateResources();
|
||||||
|
|
||||||
const Resources& get (UniversalId::Type type) const;
|
const Resources& get (UniversalId::Type type) const;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -154,3 +154,13 @@ int CSMWorld::ResourceTable::getColumnId (int column) const
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CSMWorld::ResourceTable::beginReset()
|
||||||
|
{
|
||||||
|
beginResetModel();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSMWorld::ResourceTable::endReset()
|
||||||
|
{
|
||||||
|
endResetModel();
|
||||||
|
}
|
||||||
|
|
|
@ -53,6 +53,11 @@ namespace CSMWorld
|
||||||
virtual bool isDeleted (const std::string& id) const;
|
virtual bool isDeleted (const std::string& id) const;
|
||||||
|
|
||||||
virtual int getColumnId (int column) const;
|
virtual int getColumnId (int column) const;
|
||||||
|
|
||||||
|
/// Signal Qt that the data is about to change.
|
||||||
|
void beginReset();
|
||||||
|
/// Signal Qt that the data has been changed.
|
||||||
|
void endReset();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -284,6 +284,13 @@ void CSVDoc::View::setupAssetsMenu()
|
||||||
{
|
{
|
||||||
QMenu *assets = menuBar()->addMenu (tr ("Assets"));
|
QMenu *assets = menuBar()->addMenu (tr ("Assets"));
|
||||||
|
|
||||||
|
QAction *reload = new QAction (tr ("Reload"), this);
|
||||||
|
connect (reload, SIGNAL (triggered()), &mDocument->getData(), SLOT (assetsChanged()));
|
||||||
|
setupShortcut("document-assets-reload", reload);
|
||||||
|
assets->addAction (reload);
|
||||||
|
|
||||||
|
assets->addSeparator();
|
||||||
|
|
||||||
QAction *sounds = new QAction (tr ("Sounds"), this);
|
QAction *sounds = new QAction (tr ("Sounds"), this);
|
||||||
connect (sounds, SIGNAL (triggered()), this, SLOT (addSoundsSubView()));
|
connect (sounds, SIGNAL (triggered()), this, SLOT (addSoundsSubView()));
|
||||||
setupShortcut("document-assets-sounds", sounds);
|
setupShortcut("document-assets-sounds", sounds);
|
||||||
|
|
|
@ -283,6 +283,24 @@ void CSVRender::Cell::pathgridRemoved()
|
||||||
mPathgrid->removeGeometry();
|
mPathgrid->removeGeometry();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CSVRender::Cell::reloadAssets()
|
||||||
|
{
|
||||||
|
for (std::map<std::string, Object *>::const_iterator iter (mObjects.begin());
|
||||||
|
iter != mObjects.end(); ++iter)
|
||||||
|
{
|
||||||
|
iter->second->reloadAssets();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mTerrain)
|
||||||
|
{
|
||||||
|
mTerrain->unloadCell(mCoordinates.getX(), mCoordinates.getY());
|
||||||
|
mTerrain->loadCell(mCoordinates.getX(), mCoordinates.getY());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mCellWater)
|
||||||
|
mCellWater->reloadAssets();
|
||||||
|
}
|
||||||
|
|
||||||
void CSVRender::Cell::setSelection (int elementMask, Selection mode)
|
void CSVRender::Cell::setSelection (int elementMask, Selection mode)
|
||||||
{
|
{
|
||||||
if (elementMask & Mask_Reference)
|
if (elementMask & Mask_Reference)
|
||||||
|
|
|
@ -118,6 +118,8 @@ namespace CSVRender
|
||||||
|
|
||||||
void pathgridRemoved();
|
void pathgridRemoved();
|
||||||
|
|
||||||
|
void reloadAssets();
|
||||||
|
|
||||||
void setSelection (int elementMask, Selection mode);
|
void setSelection (int elementMask, Selection mode);
|
||||||
|
|
||||||
// Select everything that references the same ID as at least one of the elements
|
// Select everything that references the same ID as at least one of the elements
|
||||||
|
|
|
@ -92,6 +92,11 @@ namespace CSVRender
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CellWater::reloadAssets()
|
||||||
|
{
|
||||||
|
recreate();
|
||||||
|
}
|
||||||
|
|
||||||
void CellWater::cellDataChanged(const QModelIndex& topLeft, const QModelIndex& bottomRight)
|
void CellWater::cellDataChanged(const QModelIndex& topLeft, const QModelIndex& bottomRight)
|
||||||
{
|
{
|
||||||
const CSMWorld::Collection<CSMWorld::Cell>& cells = mData.getCells();
|
const CSMWorld::Collection<CSMWorld::Cell>& cells = mData.getCells();
|
||||||
|
|
|
@ -42,6 +42,8 @@ namespace CSVRender
|
||||||
|
|
||||||
void updateCellData(const CSMWorld::Record<CSMWorld::Cell>& cellRecord);
|
void updateCellData(const CSMWorld::Record<CSMWorld::Cell>& cellRecord);
|
||||||
|
|
||||||
|
void reloadAssets();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
|
||||||
void cellDataChanged(const QModelIndex& topLeft, const QModelIndex& bottomRight);
|
void cellDataChanged(const QModelIndex& topLeft, const QModelIndex& bottomRight);
|
||||||
|
|
|
@ -532,6 +532,12 @@ bool CSVRender::Object::referenceDataChanged (const QModelIndex& topLeft,
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CSVRender::Object::reloadAssets()
|
||||||
|
{
|
||||||
|
update();
|
||||||
|
updateMarker();
|
||||||
|
}
|
||||||
|
|
||||||
std::string CSVRender::Object::getReferenceId() const
|
std::string CSVRender::Object::getReferenceId() const
|
||||||
{
|
{
|
||||||
return mReferenceId;
|
return mReferenceId;
|
||||||
|
|
|
@ -151,6 +151,9 @@ namespace CSVRender
|
||||||
/// this object?
|
/// this object?
|
||||||
bool referenceDataChanged (const QModelIndex& topLeft, const QModelIndex& bottomRight);
|
bool referenceDataChanged (const QModelIndex& topLeft, const QModelIndex& bottomRight);
|
||||||
|
|
||||||
|
/// Reloads the underlying asset
|
||||||
|
void reloadAssets();
|
||||||
|
|
||||||
/// Returns an empty string if this is a refereceable-type object.
|
/// Returns an empty string if this is a refereceable-type object.
|
||||||
std::string getReferenceId() const;
|
std::string getReferenceId() const;
|
||||||
|
|
||||||
|
|
|
@ -472,6 +472,9 @@ CSVRender::PagedWorldspaceWidget::PagedWorldspaceWidget (QWidget* parent, CSMDoc
|
||||||
connect (cells, SIGNAL (rowsInserted (const QModelIndex&, int, int)),
|
connect (cells, SIGNAL (rowsInserted (const QModelIndex&, int, int)),
|
||||||
this, SLOT (cellAdded (const QModelIndex&, int, int)));
|
this, SLOT (cellAdded (const QModelIndex&, int, int)));
|
||||||
|
|
||||||
|
connect (&document.getData(), SIGNAL (assetTablesChanged ()),
|
||||||
|
this, SLOT (assetTablesChanged ()));
|
||||||
|
|
||||||
// Shortcuts
|
// Shortcuts
|
||||||
CSMPrefs::Shortcut* loadCameraCellShortcut = new CSMPrefs::Shortcut("scene-load-cam-cell", this);
|
CSMPrefs::Shortcut* loadCameraCellShortcut = new CSMPrefs::Shortcut("scene-load-cam-cell", this);
|
||||||
connect(loadCameraCellShortcut, SIGNAL(activated()), this, SLOT(loadCameraCell()));
|
connect(loadCameraCellShortcut, SIGNAL(activated()), this, SLOT(loadCameraCell()));
|
||||||
|
@ -763,6 +766,15 @@ void CSVRender::PagedWorldspaceWidget::cellAdded (const QModelIndex& index, int
|
||||||
flagAsModified();
|
flagAsModified();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CSVRender::PagedWorldspaceWidget::assetTablesChanged()
|
||||||
|
{
|
||||||
|
std::map<CSMWorld::CellCoordinates, Cell *>::iterator iter = mCells.begin();
|
||||||
|
for ( ; iter != mCells.end(); ++iter)
|
||||||
|
{
|
||||||
|
iter->second->reloadAssets();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void CSVRender::PagedWorldspaceWidget::loadCameraCell()
|
void CSVRender::PagedWorldspaceWidget::loadCameraCell()
|
||||||
{
|
{
|
||||||
addCellToSceneFromCamera(0, 0);
|
addCellToSceneFromCamera(0, 0);
|
||||||
|
|
|
@ -155,6 +155,8 @@ namespace CSVRender
|
||||||
|
|
||||||
virtual void cellAdded (const QModelIndex& index, int start, int end);
|
virtual void cellAdded (const QModelIndex& index, int start, int end);
|
||||||
|
|
||||||
|
void assetTablesChanged ();
|
||||||
|
|
||||||
void loadCameraCell();
|
void loadCameraCell();
|
||||||
|
|
||||||
void loadEastCell();
|
void loadEastCell();
|
||||||
|
|
|
@ -17,6 +17,9 @@ CSVRender::PreviewWidget::PreviewWidget (CSMWorld::Data& data,
|
||||||
connect (referenceables, SIGNAL (rowsAboutToBeRemoved (const QModelIndex&, int, int)),
|
connect (referenceables, SIGNAL (rowsAboutToBeRemoved (const QModelIndex&, int, int)),
|
||||||
this, SLOT (referenceableAboutToBeRemoved (const QModelIndex&, int, int)));
|
this, SLOT (referenceableAboutToBeRemoved (const QModelIndex&, int, int)));
|
||||||
|
|
||||||
|
connect (&mData, SIGNAL (assetTablesChanged ()),
|
||||||
|
this, SLOT (assetTablesChanged ()));
|
||||||
|
|
||||||
if (!referenceable)
|
if (!referenceable)
|
||||||
{
|
{
|
||||||
QAbstractItemModel *references =
|
QAbstractItemModel *references =
|
||||||
|
@ -119,3 +122,8 @@ void CSVRender::PreviewWidget::referenceAboutToBeRemoved (const QModelIndex& par
|
||||||
if (index.row()>=start && index.row()<=end)
|
if (index.row()>=start && index.row()<=end)
|
||||||
emit closeRequest();
|
emit closeRequest();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CSVRender::PreviewWidget::assetTablesChanged ()
|
||||||
|
{
|
||||||
|
mObject.reloadAssets();
|
||||||
|
}
|
||||||
|
|
|
@ -47,6 +47,8 @@ namespace CSVRender
|
||||||
void referenceDataChanged (const QModelIndex& topLeft, const QModelIndex& bottomRight);
|
void referenceDataChanged (const QModelIndex& topLeft, const QModelIndex& bottomRight);
|
||||||
|
|
||||||
void referenceAboutToBeRemoved (const QModelIndex& parent, int start, int end);
|
void referenceAboutToBeRemoved (const QModelIndex& parent, int start, int end);
|
||||||
|
|
||||||
|
void assetTablesChanged ();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -47,6 +47,9 @@ CSVRender::UnpagedWorldspaceWidget::UnpagedWorldspaceWidget (const std::string&
|
||||||
connect (mCellsModel, SIGNAL (rowsAboutToBeRemoved (const QModelIndex&, int, int)),
|
connect (mCellsModel, SIGNAL (rowsAboutToBeRemoved (const QModelIndex&, int, int)),
|
||||||
this, SLOT (cellRowsAboutToBeRemoved (const QModelIndex&, int, int)));
|
this, SLOT (cellRowsAboutToBeRemoved (const QModelIndex&, int, int)));
|
||||||
|
|
||||||
|
connect (&document.getData(), SIGNAL (assetTablesChanged ()),
|
||||||
|
this, SLOT (assetTablesChanged ()));
|
||||||
|
|
||||||
update();
|
update();
|
||||||
|
|
||||||
mCell.reset (new Cell (document.getData(), mRootNode, mCellId));
|
mCell.reset (new Cell (document.getData(), mRootNode, mCellId));
|
||||||
|
@ -82,6 +85,12 @@ void CSVRender::UnpagedWorldspaceWidget::cellRowsAboutToBeRemoved (const QModelI
|
||||||
emit closeRequest();
|
emit closeRequest();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CSVRender::UnpagedWorldspaceWidget::assetTablesChanged()
|
||||||
|
{
|
||||||
|
if (mCell)
|
||||||
|
mCell->reloadAssets();
|
||||||
|
}
|
||||||
|
|
||||||
bool CSVRender::UnpagedWorldspaceWidget::handleDrop (const std::vector<CSMWorld::UniversalId>& universalIdData, DropType type)
|
bool CSVRender::UnpagedWorldspaceWidget::handleDrop (const std::vector<CSMWorld::UniversalId>& universalIdData, DropType type)
|
||||||
{
|
{
|
||||||
if (WorldspaceWidget::handleDrop (universalIdData, type))
|
if (WorldspaceWidget::handleDrop (universalIdData, type))
|
||||||
|
|
|
@ -108,6 +108,8 @@ namespace CSVRender
|
||||||
|
|
||||||
void cellRowsAboutToBeRemoved (const QModelIndex& parent, int start, int end);
|
void cellRowsAboutToBeRemoved (const QModelIndex& parent, int start, int end);
|
||||||
|
|
||||||
|
void assetTablesChanged ();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|
||||||
void cellChanged(const CSMWorld::UniversalId& id);
|
void cellChanged(const CSMWorld::UniversalId& id);
|
||||||
|
|
|
@ -190,6 +190,13 @@ void BulletShapeManager::updateCache(double referenceTime)
|
||||||
mInstanceCache->removeUnreferencedObjectsInCache();
|
mInstanceCache->removeUnreferencedObjectsInCache();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BulletShapeManager::clearCache()
|
||||||
|
{
|
||||||
|
ResourceManager::clearCache();
|
||||||
|
|
||||||
|
mInstanceCache->clear();
|
||||||
|
}
|
||||||
|
|
||||||
void BulletShapeManager::reportStats(unsigned int frameNumber, osg::Stats *stats) const
|
void BulletShapeManager::reportStats(unsigned int frameNumber, osg::Stats *stats) const
|
||||||
{
|
{
|
||||||
stats->setAttribute(frameNumber, "Shape", mCache->getCacheSize());
|
stats->setAttribute(frameNumber, "Shape", mCache->getCacheSize());
|
||||||
|
|
|
@ -42,6 +42,8 @@ namespace Resource
|
||||||
/// @see ResourceManager::updateCache
|
/// @see ResourceManager::updateCache
|
||||||
virtual void updateCache(double referenceTime);
|
virtual void updateCache(double referenceTime);
|
||||||
|
|
||||||
|
virtual void clearCache();
|
||||||
|
|
||||||
void reportStats(unsigned int frameNumber, osg::Stats *stats) const;
|
void reportStats(unsigned int frameNumber, osg::Stats *stats) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -43,6 +43,12 @@ namespace Resource
|
||||||
objectsToRemove.clear();
|
objectsToRemove.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MultiObjectCache::clear()
|
||||||
|
{
|
||||||
|
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_objectCacheMutex);
|
||||||
|
_objectCache.clear();
|
||||||
|
}
|
||||||
|
|
||||||
void MultiObjectCache::addEntryToObjectCache(const std::string &filename, osg::Object *object)
|
void MultiObjectCache::addEntryToObjectCache(const std::string &filename, osg::Object *object)
|
||||||
{
|
{
|
||||||
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_objectCacheMutex);
|
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_objectCacheMutex);
|
||||||
|
|
|
@ -25,6 +25,9 @@ namespace Resource
|
||||||
|
|
||||||
void removeUnreferencedObjectsInCache();
|
void removeUnreferencedObjectsInCache();
|
||||||
|
|
||||||
|
/** Remove all objects from the cache. */
|
||||||
|
void clear();
|
||||||
|
|
||||||
void addEntryToObjectCache(const std::string& filename, osg::Object* object);
|
void addEntryToObjectCache(const std::string& filename, osg::Object* object);
|
||||||
|
|
||||||
/** Take an Object from cache. Return NULL if no object found. */
|
/** Take an Object from cache. Return NULL if no object found. */
|
||||||
|
|
|
@ -23,6 +23,11 @@ namespace Resource
|
||||||
mCache->removeExpiredObjectsInCache(referenceTime - mExpiryDelay);
|
mCache->removeExpiredObjectsInCache(referenceTime - mExpiryDelay);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ResourceManager::clearCache()
|
||||||
|
{
|
||||||
|
mCache->clear();
|
||||||
|
}
|
||||||
|
|
||||||
void ResourceManager::setExpiryDelay(double expiryDelay)
|
void ResourceManager::setExpiryDelay(double expiryDelay)
|
||||||
{
|
{
|
||||||
mExpiryDelay = expiryDelay;
|
mExpiryDelay = expiryDelay;
|
||||||
|
|
|
@ -28,6 +28,9 @@ namespace Resource
|
||||||
/// Clear cache entries that have not been referenced for longer than expiryDelay.
|
/// Clear cache entries that have not been referenced for longer than expiryDelay.
|
||||||
virtual void updateCache(double referenceTime);
|
virtual void updateCache(double referenceTime);
|
||||||
|
|
||||||
|
/// Clear all cache entries.
|
||||||
|
virtual void clearCache();
|
||||||
|
|
||||||
/// How long to keep objects in cache after no longer being referenced.
|
/// How long to keep objects in cache after no longer being referenced.
|
||||||
void setExpiryDelay (double expiryDelay);
|
void setExpiryDelay (double expiryDelay);
|
||||||
|
|
||||||
|
|
|
@ -68,6 +68,12 @@ namespace Resource
|
||||||
(*it)->updateCache(referenceTime);
|
(*it)->updateCache(referenceTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ResourceSystem::clearCache()
|
||||||
|
{
|
||||||
|
for (std::vector<ResourceManager*>::iterator it = mResourceManagers.begin(); it != mResourceManagers.end(); ++it)
|
||||||
|
(*it)->clearCache();
|
||||||
|
}
|
||||||
|
|
||||||
void ResourceSystem::addResourceManager(ResourceManager *resourceMgr)
|
void ResourceSystem::addResourceManager(ResourceManager *resourceMgr)
|
||||||
{
|
{
|
||||||
mResourceManagers.push_back(resourceMgr);
|
mResourceManagers.push_back(resourceMgr);
|
||||||
|
|
|
@ -41,6 +41,10 @@ namespace Resource
|
||||||
/// @note May be called from any thread if you do not add or remove resource managers at that point.
|
/// @note May be called from any thread if you do not add or remove resource managers at that point.
|
||||||
void updateCache(double referenceTime);
|
void updateCache(double referenceTime);
|
||||||
|
|
||||||
|
/// Indicates to each resource manager to clear the entire cache.
|
||||||
|
/// @note May be called from any thread if you do not add or remove resource managers at that point.
|
||||||
|
void clearCache();
|
||||||
|
|
||||||
/// Add this ResourceManager to be handled by the ResourceSystem.
|
/// Add this ResourceManager to be handled by the ResourceSystem.
|
||||||
/// @note Does not transfer ownership.
|
/// @note Does not transfer ownership.
|
||||||
void addResourceManager(ResourceManager* resourceMgr);
|
void addResourceManager(ResourceManager* resourceMgr);
|
||||||
|
|
|
@ -122,6 +122,13 @@ namespace Resource
|
||||||
{
|
{
|
||||||
return _sharedStateSetList.size();
|
return _sharedStateSetList.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void clearCache()
|
||||||
|
{
|
||||||
|
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_listMutex);
|
||||||
|
_sharedTextureList.clear();
|
||||||
|
_sharedStateSetList.clear();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Set texture filtering settings on textures contained in a FlipController.
|
/// Set texture filtering settings on textures contained in a FlipController.
|
||||||
|
@ -710,6 +717,15 @@ namespace Resource
|
||||||
mSharedStateMutex.unlock();
|
mSharedStateMutex.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SceneManager::clearCache()
|
||||||
|
{
|
||||||
|
ResourceManager::clearCache();
|
||||||
|
|
||||||
|
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(mSharedStateMutex);
|
||||||
|
mSharedStateManager->clearCache();
|
||||||
|
mInstanceCache->clear();
|
||||||
|
}
|
||||||
|
|
||||||
void SceneManager::reportStats(unsigned int frameNumber, osg::Stats *stats) const
|
void SceneManager::reportStats(unsigned int frameNumber, osg::Stats *stats) const
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
|
|
|
@ -143,6 +143,8 @@ namespace Resource
|
||||||
/// @see ResourceManager::updateCache
|
/// @see ResourceManager::updateCache
|
||||||
virtual void updateCache(double referenceTime);
|
virtual void updateCache(double referenceTime);
|
||||||
|
|
||||||
|
virtual void clearCache();
|
||||||
|
|
||||||
virtual void reportStats(unsigned int frameNumber, osg::Stats* stats) const;
|
virtual void reportStats(unsigned int frameNumber, osg::Stats* stats) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -231,4 +231,16 @@ namespace Terrain
|
||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BufferCache::clearCache()
|
||||||
|
{
|
||||||
|
{
|
||||||
|
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(mIndexBufferMutex);
|
||||||
|
mIndexBufferMap.clear();
|
||||||
|
}
|
||||||
|
{
|
||||||
|
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(mUvBufferMutex);
|
||||||
|
mUvBufferMap.clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,8 @@ namespace Terrain
|
||||||
/// @note Thread safe.
|
/// @note Thread safe.
|
||||||
osg::ref_ptr<osg::Vec2Array> getUVBuffer(unsigned int numVerts);
|
osg::ref_ptr<osg::Vec2Array> getUVBuffer(unsigned int numVerts);
|
||||||
|
|
||||||
|
void clearCache();
|
||||||
|
|
||||||
// TODO: add releaseGLObjects() for our vertex/element buffer objects
|
// TODO: add releaseGLObjects() for our vertex/element buffer objects
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -55,6 +55,13 @@ void ChunkManager::reportStats(unsigned int frameNumber, osg::Stats *stats) cons
|
||||||
stats->setAttribute(frameNumber, "Terrain Chunk", mCache->getCacheSize());
|
stats->setAttribute(frameNumber, "Terrain Chunk", mCache->getCacheSize());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ChunkManager::clearCache()
|
||||||
|
{
|
||||||
|
ResourceManager::clearCache();
|
||||||
|
|
||||||
|
mBufferCache.clearCache();
|
||||||
|
}
|
||||||
|
|
||||||
void ChunkManager::setCullingActive(bool active)
|
void ChunkManager::setCullingActive(bool active)
|
||||||
{
|
{
|
||||||
mCullingActive = active;
|
mCullingActive = active;
|
||||||
|
|
|
@ -34,6 +34,8 @@ namespace Terrain
|
||||||
|
|
||||||
virtual void reportStats(unsigned int frameNumber, osg::Stats* stats) const;
|
virtual void reportStats(unsigned int frameNumber, osg::Stats* stats) const;
|
||||||
|
|
||||||
|
virtual void clearCache();
|
||||||
|
|
||||||
void setCullingActive(bool active);
|
void setCullingActive(bool active);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -39,6 +39,12 @@ namespace VFS
|
||||||
|
|
||||||
Manager::~Manager()
|
Manager::~Manager()
|
||||||
{
|
{
|
||||||
|
reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Manager::reset()
|
||||||
|
{
|
||||||
|
mIndex.clear();
|
||||||
for (std::vector<Archive*>::iterator it = mArchives.begin(); it != mArchives.end(); ++it)
|
for (std::vector<Archive*>::iterator it = mArchives.begin(); it != mArchives.end(); ++it)
|
||||||
delete *it;
|
delete *it;
|
||||||
mArchives.clear();
|
mArchives.clear();
|
||||||
|
|
|
@ -26,6 +26,9 @@ namespace VFS
|
||||||
|
|
||||||
~Manager();
|
~Manager();
|
||||||
|
|
||||||
|
// Empty the file index and unregister archives.
|
||||||
|
void reset();
|
||||||
|
|
||||||
/// Register the given archive. All files contained in it will be added to the index on the next buildIndex() call.
|
/// Register the given archive. All files contained in it will be added to the index on the next buildIndex() call.
|
||||||
/// @note Takes ownership of the given pointer.
|
/// @note Takes ownership of the given pointer.
|
||||||
void addArchive(Archive* archive);
|
void addArchive(Archive* archive);
|
||||||
|
|
Loading…
Reference in a new issue