improved performance of CSVRender::Cell::addObjects by bypassing Qt model

celladd
Marc Zinnschlag 9 years ago
parent be6ee927b9
commit a9a8b5ad47

@ -10,6 +10,7 @@
#include "../../model/world/idtable.hpp"
#include "../../model/world/columns.hpp"
#include "../../model/world/data.hpp"
#include "../../model/world/refcollection.hpp"
#include "../world/physicssystem.hpp"
#include "elements.hpp"
@ -30,26 +31,19 @@ bool CSVRender::Cell::removeObject (const std::string& id)
bool CSVRender::Cell::addObjects (int start, int end)
{
CSMWorld::IdTable& references = dynamic_cast<CSMWorld::IdTable&> (
*mData.getTableModel (CSMWorld::UniversalId::Type_References));
int idColumn = references.findColumnIndex (CSMWorld::Columns::ColumnId_Id);
int cellColumn = references.findColumnIndex (CSMWorld::Columns::ColumnId_Cell);
int stateColumn = references.findColumnIndex (CSMWorld::Columns::ColumnId_Modification);
bool modified = false;
const CSMWorld::RefCollection& collection = mData.getReferences();
for (int i=start; i<=end; ++i)
{
std::string cell = Misc::StringUtils::lowerCase (references.data (
references.index (i, cellColumn)).toString().toUtf8().constData());
std::string cell = Misc::StringUtils::lowerCase (collection.getRecord (i).get().mCell);
int state = references.data (references.index (i, stateColumn)).toInt();
CSMWorld::RecordBase::State state = collection.getRecord (i).mState;
if (cell==mId && state!=CSMWorld::RecordBase::State_Deleted)
{
std::string id = Misc::StringUtils::lowerCase (references.data (
references.index (i, idColumn)).toString().toUtf8().constData());
std::string id = Misc::StringUtils::lowerCase (collection.getRecord (i).get().mId);
mObjects.insert (std::make_pair (id, new Object (mData, mCellNode, id, false, mPhysics)));
modified = true;

Loading…
Cancel
Save