mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-29 21:45:32 +00:00
Preload levelled creatures
This commit is contained in:
parent
6806741d9b
commit
f6f9eff9a6
3 changed files with 21 additions and 1 deletions
|
@ -6,6 +6,7 @@
|
|||
#include "../mwmechanics/levelledlist.hpp"
|
||||
|
||||
#include "../mwworld/customdata.hpp"
|
||||
#include "../mwmechanics/creaturestats.hpp"
|
||||
|
||||
namespace MWClass
|
||||
{
|
||||
|
@ -53,6 +54,22 @@ namespace MWClass
|
|||
registerClass (typeid (ESM::CreatureLevList).name(), instance);
|
||||
}
|
||||
|
||||
void CreatureLevList::getModelsToPreload(const MWWorld::Ptr &ptr, std::vector<std::string> &models) const
|
||||
{
|
||||
const MWWorld::LiveCellRef<ESM::CreatureLevList> *ref = ptr.get<ESM::CreatureLevList>();
|
||||
|
||||
for (std::vector<ESM::LevelledListBase::LevelItem>::const_iterator it = ref->mBase->mList.begin(); it != ref->mBase->mList.end(); ++it)
|
||||
{
|
||||
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr();
|
||||
if (it->mLevel > player.getClass().getCreatureStats(player).getLevel())
|
||||
continue;
|
||||
|
||||
const MWWorld::ESMStore& store = MWBase::Environment::get().getWorld()->getStore();
|
||||
MWWorld::ManualRef ref(store, it->mId);
|
||||
ref.getPtr().getClass().getModelsToPreload(ref.getPtr(), models);
|
||||
}
|
||||
}
|
||||
|
||||
void CreatureLevList::insertObjectRendering(const MWWorld::Ptr &ptr, const std::string& model, MWRender::RenderingInterface &renderingInterface) const
|
||||
{
|
||||
ensureCustomData(ptr);
|
||||
|
|
|
@ -17,6 +17,9 @@ namespace MWClass
|
|||
|
||||
static void registerSelf();
|
||||
|
||||
virtual void getModelsToPreload(const MWWorld::Ptr& ptr, std::vector<std::string>& models) const;
|
||||
///< Get a list of models to preload that this object may use (directly or indirectly). default implementation: list getModel().
|
||||
|
||||
virtual void insertObjectRendering (const MWWorld::Ptr& ptr, const std::string& model, MWRender::RenderingInterface& renderingInterface) const;
|
||||
///< Add reference into a cell for rendering
|
||||
|
||||
|
|
|
@ -197,7 +197,7 @@ namespace MWWorld
|
|||
if (mPreloadEnabled)
|
||||
{
|
||||
mPreloadTimer += duration;
|
||||
if (mPreloadTimer > 0.5f)
|
||||
if (mPreloadTimer > 0.25f)
|
||||
{
|
||||
preloadCells();
|
||||
mPreloadTimer = 0.f;
|
||||
|
|
Loading…
Reference in a new issue