|
|
|
@ -16,6 +16,7 @@
|
|
|
|
|
#include <components/misc/strings/lower.hpp>
|
|
|
|
|
#include <components/terrain/terraingrid.hpp>
|
|
|
|
|
|
|
|
|
|
#include "../../model/doc/document.hpp"
|
|
|
|
|
#include "../../model/world/idtable.hpp"
|
|
|
|
|
|
|
|
|
|
#include "cellarrow.hpp"
|
|
|
|
@ -31,6 +32,7 @@
|
|
|
|
|
#include <apps/opencs/model/world/cell.hpp>
|
|
|
|
|
#include <apps/opencs/model/world/cellcoordinates.hpp>
|
|
|
|
|
#include <apps/opencs/model/world/columns.hpp>
|
|
|
|
|
#include <apps/opencs/model/world/commands.hpp>
|
|
|
|
|
#include <apps/opencs/model/world/data.hpp>
|
|
|
|
|
#include <apps/opencs/model/world/idcollection.hpp>
|
|
|
|
|
#include <apps/opencs/model/world/land.hpp>
|
|
|
|
@ -130,40 +132,31 @@ void CSVRender::Cell::updateLand()
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Setup land if available
|
|
|
|
|
const CSMWorld::IdCollection<CSMWorld::Land>& land = mData.getLand();
|
|
|
|
|
int landIndex = land.searchId(mId);
|
|
|
|
|
if (landIndex != -1 && !land.getRecord(mId).isDeleted())
|
|
|
|
|
{
|
|
|
|
|
const ESM::Land& esmLand = land.getRecord(mId).get();
|
|
|
|
|
|
|
|
|
|
if (esmLand.getLandData(ESM::Land::DATA_VHGT))
|
|
|
|
|
{
|
|
|
|
|
if (mTerrain)
|
|
|
|
|
{
|
|
|
|
|
mTerrain->unloadCell(mCoordinates.getX(), mCoordinates.getY());
|
|
|
|
|
mTerrain->clearAssociatedCaches();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
constexpr double expiryDelay = 0;
|
|
|
|
|
mTerrain = std::make_unique<Terrain::TerrainGrid>(mCellNode, mCellNode, mData.getResourceSystem().get(),
|
|
|
|
|
mTerrainStorage, Mask_Terrain, ESM::Cell::sDefaultWorldspaceId, expiryDelay);
|
|
|
|
|
}
|
|
|
|
|
if (land.getRecord(mId).isDeleted())
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
mTerrain->loadCell(esmLand.mX, esmLand.mY);
|
|
|
|
|
const ESM::Land& esmLand = land.getRecord(mId).get();
|
|
|
|
|
|
|
|
|
|
if (!mCellBorder)
|
|
|
|
|
mCellBorder = std::make_unique<CellBorder>(mCellNode, mCoordinates);
|
|
|
|
|
if (mTerrain)
|
|
|
|
|
{
|
|
|
|
|
mTerrain->unloadCell(mCoordinates.getX(), mCoordinates.getY());
|
|
|
|
|
mTerrain->clearAssociatedCaches();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
constexpr double expiryDelay = 0;
|
|
|
|
|
mTerrain = std::make_unique<Terrain::TerrainGrid>(mCellNode, mCellNode, mData.getResourceSystem().get(),
|
|
|
|
|
mTerrainStorage, Mask_Terrain, ESM::Cell::sDefaultWorldspaceId, expiryDelay);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
mCellBorder->buildShape(esmLand);
|
|
|
|
|
mTerrain->loadCell(esmLand.mX, esmLand.mY);
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (!mCellBorder)
|
|
|
|
|
mCellBorder = std::make_unique<CellBorder>(mCellNode, mCoordinates);
|
|
|
|
|
|
|
|
|
|
// No land data
|
|
|
|
|
unloadLand();
|
|
|
|
|
mCellBorder->buildShape(esmLand);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CSVRender::Cell::unloadLand()
|
|
|
|
@ -175,13 +168,14 @@ void CSVRender::Cell::unloadLand()
|
|
|
|
|
mCellBorder.reset();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CSVRender::Cell::Cell(CSMWorld::Data& data, osg::Group* rootNode, const std::string& id, bool deleted)
|
|
|
|
|
: mData(data)
|
|
|
|
|
CSVRender::Cell::Cell(
|
|
|
|
|
CSMDoc::Document& document, osg::Group* rootNode, const std::string& id, bool deleted, bool isExterior)
|
|
|
|
|
: mData(document.getData())
|
|
|
|
|
, mId(ESM::RefId::stringRefId(id))
|
|
|
|
|
, mDeleted(deleted)
|
|
|
|
|
, mSubMode(0)
|
|
|
|
|
, mSubModeElementMask(0)
|
|
|
|
|
, mUpdateLand(true)
|
|
|
|
|
, mUpdateLand(isExterior)
|
|
|
|
|
, mLandDeleted(false)
|
|
|
|
|
{
|
|
|
|
|
std::pair<CSMWorld::CellCoordinates, bool> result = CSMWorld::CellCoordinates::fromId(id);
|
|
|
|
@ -207,7 +201,17 @@ CSVRender::Cell::Cell(CSMWorld::Data& data, osg::Group* rootNode, const std::str
|
|
|
|
|
|
|
|
|
|
addObjects(0, rows - 1);
|
|
|
|
|
|
|
|
|
|
updateLand();
|
|
|
|
|
if (mUpdateLand)
|
|
|
|
|
{
|
|
|
|
|
int landIndex = document.getData().getLand().searchId(mId);
|
|
|
|
|
if (landIndex == -1)
|
|
|
|
|
{
|
|
|
|
|
CSMWorld::IdTable& landTable
|
|
|
|
|
= dynamic_cast<CSMWorld::IdTable&>(*mData.getTableModel(CSMWorld::UniversalId::Type_Land));
|
|
|
|
|
document.getUndoStack().push(new CSMWorld::CreateCommand(landTable, mId.getRefIdString()));
|
|
|
|
|
}
|
|
|
|
|
updateLand();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
mPathgrid = std::make_unique<Pathgrid>(mData, mCellNode, mId.getRefIdString(), mCoordinates);
|
|
|
|
|
mCellWater = std::make_unique<CellWater>(mData, mCellNode, mId.getRefIdString(), mCoordinates);
|
|
|
|
|