diff --git a/apps/openmw/mwworld/cellpreloader.cpp b/apps/openmw/mwworld/cellpreloader.cpp index a8f146024..48b058d9e 100644 --- a/apps/openmw/mwworld/cellpreloader.cpp +++ b/apps/openmw/mwworld/cellpreloader.cpp @@ -260,6 +260,11 @@ namespace MWWorld mMaxCacheSize = num; } + unsigned int CellPreloader::getMaxCacheSize() const + { + return mMaxCacheSize; + } + void CellPreloader::setWorkQueue(osg::ref_ptr workQueue) { mWorkQueue = workQueue; diff --git a/apps/openmw/mwworld/cellpreloader.hpp b/apps/openmw/mwworld/cellpreloader.hpp index f78e66e75..e236a3783 100644 --- a/apps/openmw/mwworld/cellpreloader.hpp +++ b/apps/openmw/mwworld/cellpreloader.hpp @@ -44,6 +44,8 @@ namespace MWWorld /// The maximum number of preloaded cells. void setMaxCacheSize(unsigned int num); + unsigned int getMaxCacheSize() const; + void setWorkQueue(osg::ref_ptr workQueue); private: diff --git a/apps/openmw/mwworld/scene.cpp b/apps/openmw/mwworld/scene.cpp index 392374753..33ea9b6a8 100644 --- a/apps/openmw/mwworld/scene.cpp +++ b/apps/openmw/mwworld/scene.cpp @@ -737,11 +737,14 @@ namespace MWWorld { int x = cell->getCell()->getGridX(); int y = cell->getCell()->getGridY(); + unsigned int numpreloaded = 0; for (int dx = -mHalfGridSize; dx <= mHalfGridSize; ++dx) { for (int dy = -mHalfGridSize; dy <= mHalfGridSize; ++dy) { mPreloader->preload(MWBase::Environment::get().getWorld()->getExterior(x+dx, y+dy), mRendering.getReferenceTime()); + if (++numpreloaded >= mPreloader->getMaxCacheSize()) + break; } } }