mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-04-10 22:36:44 +00:00
Fixed brush calculations, implement undostack macro when clicked.
This commit is contained in:
parent
5f3c8b2b99
commit
20d1d8ac89
1 changed files with 24 additions and 12 deletions
|
@ -174,7 +174,19 @@ void CSVRender::TerrainTextureMode::deactivate(CSVWidget::SceneToolbar* toolbar)
|
||||||
|
|
||||||
void CSVRender::TerrainTextureMode::primaryEditPressed(const WorldspaceHitResult& hit) // Apply changes here
|
void CSVRender::TerrainTextureMode::primaryEditPressed(const WorldspaceHitResult& hit) // Apply changes here
|
||||||
{
|
{
|
||||||
|
CSMDoc::Document& document = getWorldspaceWidget().getDocument();
|
||||||
|
CSMWorld::IdTable& landTable = dynamic_cast<CSMWorld::IdTable&> (
|
||||||
|
*document.getData().getTableModel (CSMWorld::UniversalId::Type_Land));
|
||||||
|
CSMWorld::IdTable& ltexTable = dynamic_cast<CSMWorld::IdTable&> (
|
||||||
|
*document.getData().getTableModel (CSMWorld::UniversalId::Type_LandTextures));
|
||||||
|
|
||||||
|
mCellId = getWorldspaceWidget().getCellId (hit.worldPos);
|
||||||
|
|
||||||
|
QUndoStack& undoStack = document.getUndoStack();
|
||||||
|
undoStack.beginMacro ("Edit texture records");
|
||||||
|
undoStack.push (new CSMWorld::TouchLandCommand(landTable, ltexTable, mCellId));
|
||||||
editTerrainTextureGrid(hit);
|
editTerrainTextureGrid(hit);
|
||||||
|
undoStack.endMacro();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVRender::TerrainTextureMode::primarySelectPressed(const WorldspaceHitResult& hit)
|
void CSVRender::TerrainTextureMode::primarySelectPressed(const WorldspaceHitResult& hit)
|
||||||
|
@ -331,10 +343,10 @@ void CSVRender::TerrainTextureMode::editTerrainTextureGrid(const WorldspaceHitRe
|
||||||
{
|
{
|
||||||
int distanceX(0);
|
int distanceX(0);
|
||||||
int distanceY(0);
|
int distanceY(0);
|
||||||
if (i_cell < cellX) distanceX = xHitInCell + landTextureSize - i;
|
if (i_cell < cellX) distanceX = xHitInCell + landTextureSize * abs(i_cell-cellX) - i;
|
||||||
if (j_cell < cellY) distanceY = yHitInCell + landTextureSize - j;
|
if (j_cell < cellY) distanceY = yHitInCell + landTextureSize * abs(j_cell-cellY) - j;
|
||||||
if (i_cell > cellX) distanceX = -xHitInCell + landTextureSize + i - 1;
|
if (i_cell > cellX) distanceX = -xHitInCell + landTextureSize * abs(i_cell-cellX) + i;
|
||||||
if (j_cell > cellY) distanceY = -yHitInCell + landTextureSize + j - 1;
|
if (j_cell > cellY) distanceY = -yHitInCell + landTextureSize * abs(j_cell-cellY) + j;
|
||||||
if (i_cell == cellX) distanceX = abs(i-xHitInCell);
|
if (i_cell == cellX) distanceX = abs(i-xHitInCell);
|
||||||
if (j_cell == cellY) distanceY = abs(j-yHitInCell);
|
if (j_cell == cellY) distanceY = abs(j-yHitInCell);
|
||||||
if (distanceX < r && distanceY < r) mNew[j*landTextureSize+i] = brushInt;
|
if (distanceX < r && distanceY < r) mNew[j*landTextureSize+i] = brushInt;
|
||||||
|
@ -374,10 +386,10 @@ void CSVRender::TerrainTextureMode::editTerrainTextureGrid(const WorldspaceHitRe
|
||||||
{
|
{
|
||||||
int distanceX(0);
|
int distanceX(0);
|
||||||
int distanceY(0);
|
int distanceY(0);
|
||||||
if (i_cell < cellX) distanceX = xHitInCell + landTextureSize - i;
|
if (i_cell < cellX) distanceX = xHitInCell + landTextureSize * abs(i_cell-cellX) - i;
|
||||||
if (j_cell < cellY) distanceY = yHitInCell + landTextureSize - j;
|
if (j_cell < cellY) distanceY = yHitInCell + landTextureSize * abs(j_cell-cellY) - j;
|
||||||
if (i_cell > cellX) distanceX = -xHitInCell + landTextureSize + i - 1;
|
if (i_cell > cellX) distanceX = -xHitInCell + landTextureSize* abs(i_cell-cellX) + i;
|
||||||
if (j_cell > cellY) distanceY = -yHitInCell + landTextureSize + j - 1;
|
if (j_cell > cellY) distanceY = -yHitInCell + landTextureSize * abs(j_cell-cellY) + j;
|
||||||
if (i_cell == cellX) distanceX = abs(i-xHitInCell);
|
if (i_cell == cellX) distanceX = abs(i-xHitInCell);
|
||||||
if (j_cell == cellY) distanceY = abs(j-yHitInCell);
|
if (j_cell == cellY) distanceY = abs(j-yHitInCell);
|
||||||
distance = std::round(sqrt(pow(distanceX, 2)+pow(distanceY, 2)));
|
distance = std::round(sqrt(pow(distanceX, 2)+pow(distanceY, 2)));
|
||||||
|
@ -387,10 +399,10 @@ void CSVRender::TerrainTextureMode::editTerrainTextureGrid(const WorldspaceHitRe
|
||||||
{
|
{
|
||||||
int distanceX(0);
|
int distanceX(0);
|
||||||
int distanceY(0);
|
int distanceY(0);
|
||||||
if (i_cell < cellX) distanceX = xHitInCell + landTextureSize - i;
|
if (i_cell < cellX) distanceX = xHitInCell + landTextureSize * abs(i_cell-cellX) - i;
|
||||||
if (j_cell < cellY) distanceY = yHitInCell + landTextureSize - j;
|
if (j_cell < cellY) distanceY = yHitInCell + landTextureSize * abs(j_cell-cellY) - j;
|
||||||
if (i_cell > cellX) distanceX = -xHitInCell + landTextureSize + i - 1;
|
if (i_cell > cellX) distanceX = -xHitInCell + landTextureSize * abs(i_cell-cellX) + i;
|
||||||
if (j_cell > cellY) distanceY = -yHitInCell + landTextureSize + j - 1;
|
if (j_cell > cellY) distanceY = -yHitInCell + landTextureSize * abs(j_cell-cellY) + j;
|
||||||
if (i_cell == cellX) distanceX = abs(i-xHitInCell);
|
if (i_cell == cellX) distanceX = abs(i-xHitInCell);
|
||||||
if (j_cell == cellY) distanceY = abs(j-yHitInCell);
|
if (j_cell == cellY) distanceY = abs(j-yHitInCell);
|
||||||
distance = std::round(sqrt(pow(distanceX, 2)+pow(distanceY, 2)));
|
distance = std::round(sqrt(pow(distanceX, 2)+pow(distanceY, 2)));
|
||||||
|
|
Loading…
Reference in a new issue