mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-03-29 22:06:45 +00:00
Don't allow vertex selection outside visible cells
This commit is contained in:
parent
d186bcb46f
commit
9677203215
2 changed files with 20 additions and 4 deletions
|
@ -1027,6 +1027,17 @@ bool CSVRender::TerrainShapeMode::limitAlteredHeights(const CSMWorld::CellCoordi
|
||||||
return steepnessIsWithinLimits;
|
return steepnessIsWithinLimits;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CSVRender::TerrainShapeMode::isInCellSelection(int globalSelectionX, int globalSelectionY)
|
||||||
|
{
|
||||||
|
if (CSVRender::PagedWorldspaceWidget *paged = dynamic_cast<CSVRender::PagedWorldspaceWidget *> (&getWorldspaceWidget()))
|
||||||
|
{
|
||||||
|
std::pair<int, int> vertexCoords = std::make_pair(globalSelectionX, globalSelectionY);
|
||||||
|
std::string cellId = CSMWorld::CellCoordinates::vertexGlobalToCellId(vertexCoords);
|
||||||
|
return paged->getCellSelection().has(CSMWorld::CellCoordinates::fromId(cellId).first) && isLandLoaded(cellId);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void CSVRender::TerrainShapeMode::selectTerrainShapes(const std::pair<int, int>& vertexCoords, unsigned char selectMode, bool dragOperation)
|
void CSVRender::TerrainShapeMode::selectTerrainShapes(const std::pair<int, int>& vertexCoords, unsigned char selectMode, bool dragOperation)
|
||||||
{
|
{
|
||||||
int r = mBrushSize / 2;
|
int r = mBrushSize / 2;
|
||||||
|
@ -1034,7 +1045,7 @@ void CSVRender::TerrainShapeMode::selectTerrainShapes(const std::pair<int, int>&
|
||||||
|
|
||||||
if (mBrushShape == CSVWidget::BrushShape_Point)
|
if (mBrushShape == CSVWidget::BrushShape_Point)
|
||||||
{
|
{
|
||||||
selections.emplace_back(vertexCoords);
|
if (isInCellSelection(vertexCoords.first, vertexCoords.second)) selections.emplace_back(vertexCoords.first, vertexCoords.second);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mBrushShape == CSVWidget::BrushShape_Square)
|
if (mBrushShape == CSVWidget::BrushShape_Square)
|
||||||
|
@ -1043,7 +1054,7 @@ void CSVRender::TerrainShapeMode::selectTerrainShapes(const std::pair<int, int>&
|
||||||
{
|
{
|
||||||
for(int j = vertexCoords.second - r; j <= vertexCoords.second + r; ++j)
|
for(int j = vertexCoords.second - r; j <= vertexCoords.second + r; ++j)
|
||||||
{
|
{
|
||||||
selections.emplace_back(std::make_pair(i, j));
|
if (isInCellSelection(i, j)) selections.emplace_back(i, j);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1057,7 +1068,7 @@ void CSVRender::TerrainShapeMode::selectTerrainShapes(const std::pair<int, int>&
|
||||||
int distanceX = abs(i - vertexCoords.first);
|
int distanceX = abs(i - vertexCoords.first);
|
||||||
int distanceY = abs(j - vertexCoords.second);
|
int distanceY = abs(j - vertexCoords.second);
|
||||||
int distance = std::round(sqrt(pow(distanceX, 2)+pow(distanceY, 2)));
|
int distance = std::round(sqrt(pow(distanceX, 2)+pow(distanceY, 2)));
|
||||||
if (distance <= r) selections.emplace_back(std::make_pair(i, j));
|
if (isInCellSelection(i, j) && distance <= r) selections.emplace_back(i, j);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1068,7 +1079,9 @@ void CSVRender::TerrainShapeMode::selectTerrainShapes(const std::pair<int, int>&
|
||||||
{
|
{
|
||||||
for(auto const& value: mCustomBrushShape)
|
for(auto const& value: mCustomBrushShape)
|
||||||
{
|
{
|
||||||
selections.emplace_back(std::make_pair(vertexCoords.first + value.first, vertexCoords.second + value.second));
|
std::pair<int, int> localVertexCoords (vertexCoords.first + value.first, vertexCoords.second + value.second);
|
||||||
|
std::string cellId (CSMWorld::CellCoordinates::vertexGlobalToCellId(localVertexCoords));
|
||||||
|
if (isInCellSelection(localVertexCoords.first, localVertexCoords.second)) selections.emplace_back(localVertexCoords);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -131,6 +131,9 @@ namespace CSVRender
|
||||||
/// Check that the edit doesn't break save format limits, fix if necessary, return true if slope steepness is within limits
|
/// Check that the edit doesn't break save format limits, fix if necessary, return true if slope steepness is within limits
|
||||||
bool limitAlteredHeights(const CSMWorld::CellCoordinates& cellCoords, bool reverseMode = false);
|
bool limitAlteredHeights(const CSMWorld::CellCoordinates& cellCoords, bool reverseMode = false);
|
||||||
|
|
||||||
|
/// Check if global selection coordinate belongs to cell in view
|
||||||
|
bool isInCellSelection(int globalSelectionX, int globalSelectionY);
|
||||||
|
|
||||||
/// Handle brush mechanics for terrain shape selection
|
/// Handle brush mechanics for terrain shape selection
|
||||||
void selectTerrainShapes (const std::pair<int, int>& vertexCoords, unsigned char selectMode, bool dragOperation);
|
void selectTerrainShapes (const std::pair<int, int>& vertexCoords, unsigned char selectMode, bool dragOperation);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue