Remove unused code, clarifications, optimizations

pull/541/head
Nelsson Huotari 6 years ago
parent d6722c7492
commit 1a08944a8b

@ -66,12 +66,12 @@ void CSVRender::TerrainSelection::toggleSelect(const std::vector<std::pair<int,
{ {
for(auto const& localPos: localPositions) for(auto const& localPos: localPositions)
{ {
auto iter = std::find(mSelection.begin(), mSelection.end(), localPos); auto iterTemp = std::find(mTemporarySelection.begin(), mTemporarySelection.end(), localPos);
auto itertemp = std::find(mTemporarySelection.begin(), mTemporarySelection.end(), localPos);
mDraggedOperationFlag = true; mDraggedOperationFlag = true;
if (itertemp == mTemporarySelection.end()) if (iterTemp == mTemporarySelection.end())
{ {
auto iter = std::find(mSelection.begin(), mSelection.end(), localPos);
if (iter != mSelection.end()) if (iter != mSelection.end())
{ {
mSelection.erase(iter); mSelection.erase(iter);

@ -112,7 +112,7 @@ void CSVRender::TerrainTextureMode::primaryEditPressed(const WorldspaceHitResult
CSMWorld::IdCollection<CSMWorld::LandTexture>& landtexturesCollection = document.getData().getLandTextures(); CSMWorld::IdCollection<CSMWorld::LandTexture>& landtexturesCollection = document.getData().getLandTextures();
int index = landtexturesCollection.searchId(mBrushTexture); int index = landtexturesCollection.searchId(mBrushTexture);
if (index != -1 && !landtexturesCollection.getRecord(index).isDeleted() && hit.hit && hit.tag == 0) if (index != -1 && !landtexturesCollection.getRecord(index).isDeleted() && hit.hit && hit.tag == 0)
{ {
undoStack.beginMacro ("Edit texture records"); undoStack.beginMacro ("Edit texture records");
if(allowLandTextureEditing(mCellId)==true) if(allowLandTextureEditing(mCellId)==true)
@ -505,25 +505,24 @@ void CSVRender::TerrainTextureMode::selectTerrainTextures(std::pair<int, int> te
if (mBrushShape == 1) if (mBrushShape == 1)
{ {
for(int i = texCoords.first - r; i <= texCoords.first + r; ++i) for (int i = -r; i <= r; i++)
{ {
for(int j = texCoords.second - r; j <= texCoords.second + r; ++j) for (int j = -r; j <= r; j++)
{ {
selections.emplace_back(std::make_pair(i, j)); selections.emplace_back(i + texCoords.first, j + texCoords.second);
} }
} }
} }
if (mBrushShape == 2) if (mBrushShape == 2)
{ {
for(int i = texCoords.first - r; i <= texCoords.first + r; ++i) for (int i = -r; i <= r; i++)
{ {
for(int j = texCoords.second - r; j <= texCoords.second + r; ++j) for (int j = -r; j <= r; j++)
{ {
int distanceX = abs(i - texCoords.first); osg::Vec2f coords(i,j);
int distanceY = abs(j - texCoords.second); if (std::round(coords.length()) < r)
int distance = std::round(sqrt(pow(distanceX, 2)+pow(distanceY, 2))); selections.emplace_back(i + texCoords.first, j + texCoords.second);
if (distance < r) selections.emplace_back(std::make_pair(i, j));
} }
} }
} }
@ -534,7 +533,7 @@ void CSVRender::TerrainTextureMode::selectTerrainTextures(std::pair<int, int> te
{ {
for(auto const& value: mCustomBrushShape) for(auto const& value: mCustomBrushShape)
{ {
selections.emplace_back(std::make_pair(texCoords.first + value.first, texCoords.second + value.second)); selections.emplace_back(texCoords.first + value.first, texCoords.second + value.second);
} }
} }
} }
@ -585,8 +584,7 @@ void CSVRender::TerrainTextureMode::createTexture(std::string textureFileName)
newId = CSMWorld::LandTexture::createUniqueRecordId(0, counter); newId = CSMWorld::LandTexture::createUniqueRecordId(0, counter);
freeIndexFound = true; freeIndexFound = true;
} }
} } while (freeIndexFound == false);
while (freeIndexFound == false);
std::size_t idlocation = textureFileName.find("Texture: "); std::size_t idlocation = textureFileName.find("Texture: ");
textureFileName = textureFileName.substr (idlocation + 9); textureFileName = textureFileName.substr (idlocation + 9);
@ -711,13 +709,8 @@ void CSVRender::TerrainTextureMode::setBrushShape(int brushShape)
selectionCenterY = selectionCenterY / selectionAmount; selectionCenterY = selectionCenterY / selectionAmount;
mCustomBrushShape.clear(); mCustomBrushShape.clear();
std::pair<int, int> differentialPos {}; for (auto const& value: terrainSelection)
for(auto const& value: terrainSelection) mCustomBrushShape.emplace_back(value.first - selectionCenterX, value.second - selectionCenterY);
{
differentialPos.first = value.first - selectionCenterX;
differentialPos.second = value.second - selectionCenterY;
mCustomBrushShape.push_back(differentialPos);
}
} }
} }
@ -725,8 +718,3 @@ void CSVRender::TerrainTextureMode::setBrushTexture(std::string brushTexture)
{ {
mBrushTexture = brushTexture; mBrushTexture = brushTexture;
} }
CSVRender::PagedWorldspaceWidget& CSVRender::TerrainTextureMode::getPagedWorldspaceWidget()
{
return dynamic_cast<PagedWorldspaceWidget&>(getWorldspaceWidget());
}

@ -110,8 +110,6 @@ namespace CSVRender
const int landSize {ESM::Land::LAND_SIZE}; const int landSize {ESM::Land::LAND_SIZE};
const int landTextureSize {ESM::Land::LAND_TEXTURE_SIZE}; const int landTextureSize {ESM::Land::LAND_TEXTURE_SIZE};
PagedWorldspaceWidget& getPagedWorldspaceWidget();
signals: signals:
void passBrushTexture(std::string brushTexture); void passBrushTexture(std::string brushTexture);

Loading…
Cancel
Save