From 120583f443f5cec487f235dd2c07b0892d2ecf27 Mon Sep 17 00:00:00 2001 From: Nelsson Huotari Date: Thu, 14 Nov 2019 11:28:49 +0200 Subject: [PATCH] optimize isInCellSelection calls --- apps/opencs/view/render/terrainshapemode.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/apps/opencs/view/render/terrainshapemode.cpp b/apps/opencs/view/render/terrainshapemode.cpp index ee6492a87..e73887615 100644 --- a/apps/opencs/view/render/terrainshapemode.cpp +++ b/apps/opencs/view/render/terrainshapemode.cpp @@ -1047,9 +1047,16 @@ void CSVRender::TerrainShapeMode::handleSelection(int globalSelectionX, int glob int moduloY = globalSelectionY % (ESM::Land::LAND_SIZE - 1); bool xIsAtCellBorder = moduloX == 0; bool yIsAtCellBorder = moduloY == 0; - if (isInCellSelection(globalSelectionX - 1, globalSelectionY) && xIsAtCellBorder && !yIsAtCellBorder) selections->emplace_back(globalSelectionX, globalSelectionY); - if (isInCellSelection(globalSelectionX, globalSelectionY - 1) && !xIsAtCellBorder && yIsAtCellBorder) selections->emplace_back(globalSelectionX, globalSelectionY); - if (isInCellSelection(globalSelectionX - 1, globalSelectionY - 1) && xIsAtCellBorder && yIsAtCellBorder) selections->emplace_back(globalSelectionX, globalSelectionY); + if (!xIsAtCellBorder && !yIsAtCellBorder) + return; + int selectionX = globalSelectionX; + int selectionY = globalSelectionY; + if (xIsAtCellBorder) + selectionX--; + if (yIsAtCellBorder) + selectionY--; + if (isInCellSelection(selectionX, selectionY)) + selections->emplace_back(globalSelectionX, globalSelectionY); } }