|
|
|
@ -19,9 +19,8 @@ namespace MWRender
|
|
|
|
|
|
|
|
|
|
osg::ref_ptr<ESMTerrain::LandObject> LandManager::getLand(ESM::ExteriorCellLocation cellIndex)
|
|
|
|
|
{
|
|
|
|
|
const osg::ref_ptr<osg::Object> obj = mCache->getRefFromObjectCache(cellIndex);
|
|
|
|
|
if (obj != nullptr)
|
|
|
|
|
return static_cast<ESMTerrain::LandObject*>(obj.get());
|
|
|
|
|
if (const std::optional<osg::ref_ptr<osg::Object>> obj = mCache->getRefFromObjectCacheOrNone(cellIndex))
|
|
|
|
|
return static_cast<ESMTerrain::LandObject*>(obj->get());
|
|
|
|
|
|
|
|
|
|
const MWBase::World& world = *MWBase::Environment::get().getWorld();
|
|
|
|
|
osg::ref_ptr<ESMTerrain::LandObject> landObj = nullptr;
|
|
|
|
@ -29,16 +28,14 @@ namespace MWRender
|
|
|
|
|
if (ESM::isEsm4Ext(cellIndex.mWorldspace))
|
|
|
|
|
{
|
|
|
|
|
const ESM4::Land* land = world.getStore().get<ESM4::Land>().search(cellIndex);
|
|
|
|
|
if (land == nullptr)
|
|
|
|
|
return nullptr;
|
|
|
|
|
landObj = new ESMTerrain::LandObject(*land, mLoadFlags);
|
|
|
|
|
if (land != nullptr)
|
|
|
|
|
landObj = new ESMTerrain::LandObject(*land, mLoadFlags);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
const ESM::Land* land = world.getStore().get<ESM::Land>().search(cellIndex.mX, cellIndex.mY);
|
|
|
|
|
if (land == nullptr)
|
|
|
|
|
return nullptr;
|
|
|
|
|
landObj = new ESMTerrain::LandObject(*land, mLoadFlags);
|
|
|
|
|
if (land != nullptr)
|
|
|
|
|
landObj = new ESMTerrain::LandObject(*land, mLoadFlags);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
mCache->addEntryToObjectCache(cellIndex, landObj.get());
|
|
|
|
|