mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-31 09:45:40 +00:00
Don't store member variables from document & use simpler and safer
inputs to cell constructor. Explicitly tell the constructor whether land should be loaded or not
This commit is contained in:
parent
9ca6dba2b6
commit
1cf029ec8d
4 changed files with 24 additions and 25 deletions
|
@ -24,6 +24,7 @@
|
|||
#include "cellwater.hpp"
|
||||
#include "instancedragmodes.hpp"
|
||||
#include "mask.hpp"
|
||||
#include "model/doc/document.hpp"
|
||||
#include "object.hpp"
|
||||
#include "pathgrid.hpp"
|
||||
#include "terrainstorage.hpp"
|
||||
|
@ -119,7 +120,7 @@ bool CSVRender::Cell::addObjects(int start, int end)
|
|||
|
||||
void CSVRender::Cell::updateLand()
|
||||
{
|
||||
if (!mUpdateLand || mLandDeleted || !mId.startsWith("#"))
|
||||
if (mLandDeleted)
|
||||
return;
|
||||
|
||||
mUpdateLand = false;
|
||||
|
@ -132,14 +133,6 @@ void CSVRender::Cell::updateLand()
|
|||
}
|
||||
|
||||
const CSMWorld::IdCollection<CSMWorld::Land>& land = mData.getLand();
|
||||
int landIndex = land.searchId(mId);
|
||||
|
||||
if (landIndex == -1)
|
||||
{
|
||||
CSMWorld::IdTable& landTable
|
||||
= dynamic_cast<CSMWorld::IdTable&>(*mData.getTableModel(CSMWorld::UniversalId::Type_Land));
|
||||
mUndoStack.push(new CSMWorld::CreateCommand(landTable, mId.getRefIdString()));
|
||||
}
|
||||
|
||||
if (land.getRecord(mId).isDeleted())
|
||||
return;
|
||||
|
@ -176,14 +169,13 @@ void CSVRender::Cell::unloadLand()
|
|||
}
|
||||
|
||||
CSVRender::Cell::Cell(
|
||||
CSMWorld::Data& data, QUndoStack& undoStack, osg::Group* rootNode, const std::string& id, bool deleted)
|
||||
: mData(data)
|
||||
, mUndoStack(undoStack)
|
||||
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);
|
||||
|
@ -209,7 +201,17 @@ CSVRender::Cell::Cell(
|
|||
|
||||
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);
|
||||
|
|
|
@ -9,10 +9,9 @@
|
|||
#include <osg/Vec3d>
|
||||
#include <osg/ref_ptr>
|
||||
|
||||
#include <QUndoStack>
|
||||
|
||||
#include "../../model/world/cellcoordinates.hpp"
|
||||
#include "instancedragmodes.hpp"
|
||||
#include "model/doc/document.hpp"
|
||||
#include <components/esm/refid.hpp>
|
||||
#include <components/misc/algorithm.hpp>
|
||||
|
||||
|
@ -48,7 +47,6 @@ namespace CSVRender
|
|||
class Cell
|
||||
{
|
||||
CSMWorld::Data& mData;
|
||||
QUndoStack& mUndoStack;
|
||||
ESM::RefId mId;
|
||||
osg::ref_ptr<osg::Group> mCellNode;
|
||||
std::map<std::string, Object*, Misc::StringUtils::CiComp> mObjects;
|
||||
|
@ -92,8 +90,8 @@ namespace CSVRender
|
|||
public:
|
||||
/// \note Deleted covers both cells that are deleted and cells that don't exist in
|
||||
/// the first place.
|
||||
Cell(CSMWorld::Data& data, QUndoStack& undoStack, osg::Group* rootNode, const std::string& id,
|
||||
bool deleted = false);
|
||||
Cell(CSMDoc::Document& document, osg::Group* rootNode, const std::string& id, bool deleted = false,
|
||||
bool isExterior = false);
|
||||
|
||||
~Cell();
|
||||
|
||||
|
|
|
@ -86,8 +86,8 @@ bool CSVRender::PagedWorldspaceWidget::adjustCells()
|
|||
{
|
||||
modified = true;
|
||||
|
||||
auto cell = std::make_unique<Cell>(mDocument.getData(), mDocument.getUndoStack(), mRootNode,
|
||||
iter->first.getId(mWorldspace), deleted);
|
||||
auto cell
|
||||
= std::make_unique<Cell>(mDocument, mRootNode, iter->first.getId(mWorldspace), deleted, true);
|
||||
|
||||
delete iter->second;
|
||||
iter->second = cell.release();
|
||||
|
@ -465,8 +465,7 @@ void CSVRender::PagedWorldspaceWidget::addCellToScene(const CSMWorld::CellCoordi
|
|||
|
||||
bool deleted = index == -1 || cells.getRecord(index).mState == CSMWorld::RecordBase::State_Deleted;
|
||||
|
||||
auto cell = std::make_unique<Cell>(
|
||||
mDocument.getData(), mDocument.getUndoStack(), mRootNode, coordinates.getId(mWorldspace), deleted);
|
||||
auto cell = std::make_unique<Cell>(mDocument, mRootNode, coordinates.getId(mWorldspace), deleted, true);
|
||||
EditMode* editMode = getEditMode();
|
||||
cell->setSubMode(editMode->getSubMode(), editMode->getInteractionMask());
|
||||
|
||||
|
|
|
@ -79,7 +79,7 @@ CSVRender::UnpagedWorldspaceWidget::UnpagedWorldspaceWidget(
|
|||
|
||||
update();
|
||||
|
||||
mCell = std::make_unique<Cell>(document.getData(), document.getUndoStack(), mRootNode, mCellId);
|
||||
mCell = std::make_unique<Cell>(document, mRootNode, mCellId);
|
||||
}
|
||||
|
||||
void CSVRender::UnpagedWorldspaceWidget::cellDataChanged(const QModelIndex& topLeft, const QModelIndex& bottomRight)
|
||||
|
@ -127,7 +127,7 @@ bool CSVRender::UnpagedWorldspaceWidget::handleDrop(
|
|||
|
||||
mCellId = universalIdData.begin()->getId();
|
||||
|
||||
mCell = std::make_unique<Cell>(getDocument().getData(), getDocument().getUndoStack(), mRootNode, mCellId);
|
||||
mCell = std::make_unique<Cell>(getDocument(), mRootNode, mCellId);
|
||||
mCamPositionSet = false;
|
||||
mOrbitCamControl->reset();
|
||||
|
||||
|
|
Loading…
Reference in a new issue