1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-02-26 14:09:46 +00:00
openmw/apps/opencs/model/world/ref.cpp
cc9cii 86945d1912 Convert the CellRef record index lookup maps to use integer keys rather than strings.
- Morrowind load over 300,000 references, so even small inefficiencies add up to longer loading times.
- std::map is used, but should try others, std::unordered_map or even std::vector
2015-12-11 21:00:13 +11:00

41 lines
860 B
C++

#include "ref.hpp"
#include <cmath>
CSMWorld::CellRef::CellRef()
: mIdNum(0)
{
mId.clear();
mCell.clear();
mOriginalCell.clear();
mRefNum.mIndex = 0;
mRefNum.mContentFile = 0;
}
CSMWorld::CellRef::CellRef (CSMWorld::CellRef&& other) : ESM::CellRef (other)
{
*this = std::move(other);
}
CSMWorld::CellRef& CSMWorld::CellRef::operator= (CSMWorld::CellRef&& other)
{
if (this != &other)
{
ESM::CellRef::operator= (other);
mIdNum = other.mIdNum;
mId = std::move(other.mId);
mCell = std::move(other.mCell);
mOriginalCell = std::move(other.mOriginalCell);
}
return *this;
}
std::pair<int, int> CSMWorld::CellRef::getCellIndex() const
{
const int cellSize = 8192;
return std::make_pair (
std::floor (mPos.pos[0]/cellSize), std::floor (mPos.pos[1]/cellSize));
}