mirror of
https://github.com/OpenMW/openmw.git
synced 2025-02-28 12:09:53 +00:00
Add OpenMW-CS Terrain Equalize tool
This commit is contained in:
parent
a9281b5246
commit
78e365f382
3 changed files with 40 additions and 3 deletions
|
@ -128,7 +128,7 @@ void CSVRender::TerrainShapeMode::primaryEditPressed(const WorldspaceHitResult&
|
|||
{
|
||||
if (hit.hit && hit.tag == nullptr)
|
||||
{
|
||||
if (mShapeEditTool == ShapeEditTool_Flatten)
|
||||
if (mShapeEditTool == ShapeEditTool_Flatten || mShapeEditTool == ShapeEditTool_Equalize)
|
||||
setFlattenToolTargetHeight(hit);
|
||||
if (mDragMode == InteractionType_PrimaryEdit && mShapeEditTool != ShapeEditTool_Drag)
|
||||
{
|
||||
|
@ -167,7 +167,7 @@ bool CSVRender::TerrainShapeMode::primaryEditStartDrag(const QPoint& pos)
|
|||
{
|
||||
mEditingPos = hit.worldPos;
|
||||
mIsEditing = true;
|
||||
if (mShapeEditTool == ShapeEditTool_Flatten)
|
||||
if (mShapeEditTool == ShapeEditTool_Flatten || mShapeEditTool == ShapeEditTool_Equalize)
|
||||
setFlattenToolTargetHeight(hit);
|
||||
}
|
||||
|
||||
|
@ -463,6 +463,8 @@ void CSVRender::TerrainShapeMode::editTerrainShapeGrid(const std::pair<int, int>
|
|||
smoothHeight(cellCoords, x, y, mShapeEditToolStrength);
|
||||
if (mShapeEditTool == ShapeEditTool_Flatten)
|
||||
flattenHeight(cellCoords, x, y, mShapeEditToolStrength, mTargetHeight);
|
||||
if (mShapeEditTool == ShapeEditTool_Equalize)
|
||||
equalizeHeight(cellCoords, x, y, mTargetHeight);
|
||||
}
|
||||
|
||||
if (mBrushShape == CSVWidget::BrushShape_Square)
|
||||
|
@ -489,6 +491,8 @@ void CSVRender::TerrainShapeMode::editTerrainShapeGrid(const std::pair<int, int>
|
|||
smoothHeight(cellCoords, x, y, mShapeEditToolStrength);
|
||||
if (mShapeEditTool == ShapeEditTool_Flatten)
|
||||
flattenHeight(cellCoords, x, y, mShapeEditToolStrength, mTargetHeight);
|
||||
if (mShapeEditTool == ShapeEditTool_Equalize)
|
||||
equalizeHeight(cellCoords, x, y, mTargetHeight);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -529,6 +533,8 @@ void CSVRender::TerrainShapeMode::editTerrainShapeGrid(const std::pair<int, int>
|
|||
smoothHeight(cellCoords, x, y, mShapeEditToolStrength);
|
||||
if (mShapeEditTool == ShapeEditTool_Flatten)
|
||||
flattenHeight(cellCoords, x, y, mShapeEditToolStrength, mTargetHeight);
|
||||
if (mShapeEditTool == ShapeEditTool_Equalize)
|
||||
equalizeHeight(cellCoords, x, y, mTargetHeight);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -558,6 +564,8 @@ void CSVRender::TerrainShapeMode::editTerrainShapeGrid(const std::pair<int, int>
|
|||
smoothHeight(cellCoords, x, y, mShapeEditToolStrength);
|
||||
if (mShapeEditTool == ShapeEditTool_Flatten)
|
||||
flattenHeight(cellCoords, x, y, mShapeEditToolStrength, mTargetHeight);
|
||||
if (mShapeEditTool == ShapeEditTool_Equalize)
|
||||
equalizeHeight(cellCoords, x, y, mTargetHeight);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -889,6 +897,30 @@ void CSVRender::TerrainShapeMode::flattenHeight(
|
|||
alterHeight(cellCoords, inCellX, inCellY, thisAlteredHeight + toolStrength);
|
||||
}
|
||||
|
||||
void CSVRender::TerrainShapeMode::equalizeHeight(
|
||||
const CSMWorld::CellCoordinates& cellCoords, int inCellX, int inCellY, int targetHeight)
|
||||
{
|
||||
CSMDoc::Document& document = getWorldspaceWidget().getDocument();
|
||||
CSMWorld::IdTable& landTable
|
||||
= dynamic_cast<CSMWorld::IdTable&>(*document.getData().getTableModel(CSMWorld::UniversalId::Type_Land));
|
||||
int landshapeColumn = landTable.findColumnIndex(CSMWorld::Columns::ColumnId_LandHeightsIndex);
|
||||
|
||||
float thisHeight = 0.0f;
|
||||
|
||||
const std::string cellId = CSMWorld::CellCoordinates::generateId(cellCoords.getX(), cellCoords.getY());
|
||||
|
||||
if (!noCell(cellId) && !noLand(cellId))
|
||||
{
|
||||
const CSMWorld::LandHeightsColumn::DataType landShapePointer
|
||||
= landTable.data(landTable.getModelIndex(cellId, landshapeColumn))
|
||||
.value<CSMWorld::LandHeightsColumn::DataType>();
|
||||
|
||||
thisHeight = landShapePointer[inCellY * ESM::Land::LAND_SIZE + inCellX];
|
||||
}
|
||||
|
||||
alterHeight(cellCoords, inCellX, inCellY, targetHeight - thisHeight);
|
||||
}
|
||||
|
||||
void CSVRender::TerrainShapeMode::updateKeyHeightValues(const CSMWorld::CellCoordinates& cellCoords, int inCellX,
|
||||
int inCellY, float* thisHeight, float* thisAlteredHeight, float* leftHeight, float* leftAlteredHeight,
|
||||
float* upHeight, float* upAlteredHeight, float* rightHeight, float* rightAlteredHeight, float* downHeight,
|
||||
|
|
|
@ -74,7 +74,8 @@ namespace CSVRender
|
|||
ShapeEditTool_PaintToRaise = 1,
|
||||
ShapeEditTool_PaintToLower = 2,
|
||||
ShapeEditTool_Smooth = 3,
|
||||
ShapeEditTool_Flatten = 4
|
||||
ShapeEditTool_Flatten = 4,
|
||||
ShapeEditTool_Equalize = 5
|
||||
};
|
||||
|
||||
/// Editmode for terrain shape grid
|
||||
|
@ -145,6 +146,9 @@ namespace CSVRender
|
|||
void flattenHeight(
|
||||
const CSMWorld::CellCoordinates& cellCoords, int inCellX, int inCellY, int toolStrength, int targetHeight);
|
||||
|
||||
/// Do a single equalize alteration for transient shape edit map
|
||||
void equalizeHeight(const CSMWorld::CellCoordinates& cellCoords, int inCellX, int inCellY, int targetHeight);
|
||||
|
||||
/// Get altered height values around one vertex
|
||||
void updateKeyHeightValues(const CSMWorld::CellCoordinates& cellCoords, int inCellX, int inCellY,
|
||||
float* thisHeight, float* thisAlteredHeight, float* leftHeight, float* leftAlteredHeight, float* upHeight,
|
||||
|
|
|
@ -109,6 +109,7 @@ CSVWidget::ShapeBrushWindow::ShapeBrushWindow(CSMDoc::Document& document, QWidge
|
|||
mToolSelector->addItem(tr("Height, lower (paint)"));
|
||||
mToolSelector->addItem(tr("Smooth (paint)"));
|
||||
mToolSelector->addItem(tr("Flatten (paint)"));
|
||||
mToolSelector->addItem(tr("Equalize (paint)"));
|
||||
|
||||
QLabel* brushStrengthLabel = new QLabel(this);
|
||||
brushStrengthLabel->setText("Brush strength:");
|
||||
|
|
Loading…
Reference in a new issue