mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-16 05:19:55 +00:00
6fb0022b35
Disable 'preload fast travel' by default. Add 'min cache size' and 'max cache size' settings. Split the 'cache expiry delay' into 'preload cell expiry delay' and 'cache expiry delay'.
81 lines
2.3 KiB
C++
81 lines
2.3 KiB
C++
#ifndef OPENMW_MWWORLD_CELLPRELOADER_H
|
|
#define OPENMW_MWWORLD_CELLPRELOADER_H
|
|
|
|
#include <map>
|
|
#include <osg/ref_ptr>
|
|
#include <components/sceneutil/workqueue.hpp>
|
|
|
|
namespace Resource
|
|
{
|
|
class ResourceSystem;
|
|
class BulletShapeManager;
|
|
}
|
|
|
|
namespace Terrain
|
|
{
|
|
class World;
|
|
}
|
|
|
|
namespace MWWorld
|
|
{
|
|
class CellStore;
|
|
|
|
class CellPreloader
|
|
{
|
|
public:
|
|
CellPreloader(Resource::ResourceSystem* resourceSystem, Resource::BulletShapeManager* bulletShapeManager, Terrain::World* terrain);
|
|
~CellPreloader();
|
|
|
|
/// Ask a background thread to preload rendering meshes and collision shapes for objects in this cell.
|
|
/// @note The cell itself must be in State_Loaded or State_Preloaded.
|
|
void preload(MWWorld::CellStore* cell, double timestamp);
|
|
|
|
void notifyLoaded(MWWorld::CellStore* cell);
|
|
|
|
/// Removes preloaded cells that have not had a preload request for a while.
|
|
void updateCache(double timestamp);
|
|
|
|
/// How long to keep a preloaded cell in cache after it's no longer requested.
|
|
void setExpiryDelay(double expiryDelay);
|
|
|
|
/// The minimum number of preloaded cells before unused cells get thrown out.
|
|
void setMinCacheSize(unsigned int num);
|
|
|
|
/// The maximum number of preloaded cells.
|
|
void setMaxCacheSize(unsigned int num);
|
|
|
|
void setWorkQueue(osg::ref_ptr<SceneUtil::WorkQueue> workQueue);
|
|
|
|
private:
|
|
Resource::ResourceSystem* mResourceSystem;
|
|
Resource::BulletShapeManager* mBulletShapeManager;
|
|
Terrain::World* mTerrain;
|
|
osg::ref_ptr<SceneUtil::WorkQueue> mWorkQueue;
|
|
double mExpiryDelay;
|
|
unsigned int mMinCacheSize;
|
|
unsigned int mMaxCacheSize;
|
|
|
|
struct PreloadEntry
|
|
{
|
|
PreloadEntry(double timestamp, osg::ref_ptr<SceneUtil::WorkItem> workItem)
|
|
: mTimeStamp(timestamp)
|
|
, mWorkItem(workItem)
|
|
{
|
|
}
|
|
PreloadEntry()
|
|
: mTimeStamp(0.0)
|
|
{
|
|
}
|
|
|
|
double mTimeStamp;
|
|
osg::ref_ptr<SceneUtil::WorkItem> mWorkItem;
|
|
};
|
|
typedef std::map<const MWWorld::CellStore*, PreloadEntry> PreloadMap;
|
|
|
|
// Cells that are currently being preloaded, or have already finished preloading
|
|
PreloadMap mPreloadCells;
|
|
};
|
|
|
|
}
|
|
|
|
#endif
|