Make less copies

pull/541/head
Nelsson Huotari 6 years ago
parent 001ca68cc7
commit dc8de6c6e6

@ -43,17 +43,13 @@ std::vector<std::pair<int, int>> CSVRender::TerrainSelection::getTerrainSelectio
return mSelection;
}
void CSVRender::TerrainSelection::onlySelect(const std::vector<std::pair<int, int>> localPositions)
void CSVRender::TerrainSelection::onlySelect(const std::vector<std::pair<int, int>> &localPositions)
{
mSelection.clear();
for(auto const& value: localPositions)
{
mSelection.emplace_back(value);
}
mSelection = localPositions;
update();
}
void CSVRender::TerrainSelection::addSelect(const std::pair<int, int> localPos)
void CSVRender::TerrainSelection::addSelect(const std::pair<int, int> &localPos)
{
if (std::find(mSelection.begin(), mSelection.end(), localPos) == mSelection.end())
{
@ -62,7 +58,7 @@ void CSVRender::TerrainSelection::addSelect(const std::pair<int, int> localPos)
}
}
void CSVRender::TerrainSelection::toggleSelect(const std::vector<std::pair<int, int>> localPositions, bool toggleInProgress)
void CSVRender::TerrainSelection::toggleSelect(const std::vector<std::pair<int, int>> &localPositions, bool toggleInProgress)
{
if (toggleInProgress == true)
{
@ -146,7 +142,7 @@ void CSVRender::TerrainSelection::drawShapeSelection(const osg::ref_ptr<osg::Vec
{
if (!mSelection.empty())
{
for (std::pair<int, int> localPos : mSelection)
for (std::pair<int, int> &localPos : mSelection)
{
int x (localPos.first);
int y (localPos.second);
@ -189,7 +185,7 @@ void CSVRender::TerrainSelection::drawTextureSelection(const osg::ref_ptr<osg::V
const int textureSizeToLandSizeModifier = (landSize - 1) / landTextureSize;
for (std::pair<int, int> localPos : mSelection)
for (std::pair<int, int> &localPos : mSelection)
{
int x (localPos.first);
int y (localPos.second);

@ -35,9 +35,9 @@ namespace CSVRender
TerrainSelection(osg::Group* parentNode, WorldspaceWidget *worldspaceWidget, TerrainSelectionType type);
~TerrainSelection();
void onlySelect(const std::vector<std::pair<int, int>> localPositions);
void addSelect(const std::pair<int, int> localPos);
void toggleSelect(const std::vector<std::pair<int, int>> localPositions, bool);
void onlySelect(const std::vector<std::pair<int, int>> &localPositions);
void addSelect(const std::pair<int, int> &localPos);
void toggleSelect(const std::vector<std::pair<int, int>> &localPositions, bool);
void activate();
void deactivate();

Loading…
Cancel
Save