mirror of
https://github.com/TES3MP/TES3MP.git
synced 2025-09-28 23:51:09 -04:00
Remove unused functions, improve formatting, handle terrain edit click
This commit is contained in:
parent
1046d57190
commit
dc7dc93320
@ -360,11 +360,6 @@ float CSVRender::Cell::getSumOfAlteredAndTrueHeight(int cellX, int cellY, int in
|
|||||||
return mTerrainStorage->getSumOfAlteredAndTrueHeight(cellX, cellY, inCellX, inCellY);
|
return mTerrainStorage->getSumOfAlteredAndTrueHeight(cellX, cellY, inCellX, inCellY);
|
||||||
}
|
}
|
||||||
|
|
||||||
float* CSVRender::Cell::getAlteredHeights()
|
|
||||||
{
|
|
||||||
return mTerrainStorage->getAlteredHeights();
|
|
||||||
}
|
|
||||||
|
|
||||||
float* CSVRender::Cell::getAlteredHeight(int inCellX, int inCellY)
|
float* CSVRender::Cell::getAlteredHeight(int inCellX, int inCellY)
|
||||||
{
|
{
|
||||||
return mTerrainStorage->getAlteredHeight(inCellX, inCellY);
|
return mTerrainStorage->getAlteredHeight(inCellX, inCellY);
|
||||||
|
@ -124,8 +124,6 @@ namespace CSVRender
|
|||||||
|
|
||||||
float getSumOfAlteredAndTrueHeight(int cellX, int cellY, int inCellX, int inCellY);
|
float getSumOfAlteredAndTrueHeight(int cellX, int cellY, int inCellX, int inCellY);
|
||||||
|
|
||||||
float* getAlteredHeights();
|
|
||||||
|
|
||||||
float* getAlteredHeight(int inCellX, int inCellY);
|
float* getAlteredHeight(int inCellX, int inCellY);
|
||||||
|
|
||||||
void resetAlteredHeights();
|
void resetAlteredHeights();
|
||||||
|
@ -796,26 +796,21 @@ CSVRender::Cell* CSVRender::PagedWorldspaceWidget::getCell(const CSMWorld::CellC
|
|||||||
if (searchResult != mCells.end())
|
if (searchResult != mCells.end())
|
||||||
return searchResult->second;
|
return searchResult->second;
|
||||||
else
|
else
|
||||||
return 0;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVRender::PagedWorldspaceWidget::setCellAlteredHeight(const CSMWorld::CellCoordinates& coords, int inCellX, int inCellY, float height)
|
void CSVRender::PagedWorldspaceWidget::setCellAlteredHeight(const CSMWorld::CellCoordinates& coords, int inCellX, int inCellY, float height)
|
||||||
{
|
{
|
||||||
std::map<CSMWorld::CellCoordinates, Cell*>::iterator searchResult = mCells.find(coords);
|
std::map<CSMWorld::CellCoordinates, Cell*>::iterator searchResult = mCells.find(coords);
|
||||||
if (searchResult != mCells.end()) searchResult->second->setAlteredHeight(inCellX, inCellY, height);
|
if (searchResult != mCells.end())
|
||||||
}
|
searchResult->second->setAlteredHeight(inCellX, inCellY, height);
|
||||||
|
|
||||||
float* CSVRender::PagedWorldspaceWidget::getCellAlteredHeights(const CSMWorld::CellCoordinates& coords)
|
|
||||||
{
|
|
||||||
std::map<CSMWorld::CellCoordinates, Cell*>::iterator searchResult = mCells.find(coords);
|
|
||||||
if (searchResult != mCells.end()) return searchResult->second->getAlteredHeights();
|
|
||||||
return nullptr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
float* CSVRender::PagedWorldspaceWidget::getCellAlteredHeight(const CSMWorld::CellCoordinates& coords, int inCellX, int inCellY)
|
float* CSVRender::PagedWorldspaceWidget::getCellAlteredHeight(const CSMWorld::CellCoordinates& coords, int inCellX, int inCellY)
|
||||||
{
|
{
|
||||||
std::map<CSMWorld::CellCoordinates, Cell*>::iterator searchResult = mCells.find(coords);
|
std::map<CSMWorld::CellCoordinates, Cell*>::iterator searchResult = mCells.find(coords);
|
||||||
if (searchResult != mCells.end()) return searchResult->second->getAlteredHeight(inCellX, inCellY);
|
if (searchResult != mCells.end())
|
||||||
|
return searchResult->second->getAlteredHeight(inCellX, inCellY);
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -128,8 +128,6 @@ namespace CSVRender
|
|||||||
|
|
||||||
void setCellAlteredHeight(const CSMWorld::CellCoordinates& coords, int inCellX, int inCellY, float height);
|
void setCellAlteredHeight(const CSMWorld::CellCoordinates& coords, int inCellX, int inCellY, float height);
|
||||||
|
|
||||||
float* getCellAlteredHeights(const CSMWorld::CellCoordinates& coords);
|
|
||||||
|
|
||||||
float* getCellAlteredHeight(const CSMWorld::CellCoordinates& coords, int inCellX, int inCellY);
|
float* getCellAlteredHeight(const CSMWorld::CellCoordinates& coords, int inCellX, int inCellY);
|
||||||
|
|
||||||
void resetAllAlteredHeights();
|
void resetAllAlteredHeights();
|
||||||
|
@ -93,6 +93,24 @@ void CSVRender::TerrainShapeMode::primaryEditPressed(const WorldspaceHitResult&
|
|||||||
|
|
||||||
if (hit.hit && hit.tag == 0)
|
if (hit.hit && hit.tag == 0)
|
||||||
{
|
{
|
||||||
|
if (mShapeEditTool == 4)
|
||||||
|
setFlattenToolTargetHeight(hit);
|
||||||
|
if (mDragMode == InteractionType_PrimaryEdit && mShapeEditTool > 0)
|
||||||
|
{
|
||||||
|
std::string cellId = getWorldspaceWidget().getCellId (hit.worldPos);
|
||||||
|
if (mShapeEditTool > 0) editTerrainShapeGrid(CSMWorld::CellCoordinates::toVertexCoords(hit.worldPos), true);
|
||||||
|
applyTerrainEditChanges();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mDragMode == InteractionType_PrimarySelect)
|
||||||
|
{
|
||||||
|
selectTerrainShapes(CSMWorld::CellCoordinates::toVertexCoords(hit.worldPos), 0, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mDragMode == InteractionType_SecondarySelect)
|
||||||
|
{
|
||||||
|
selectTerrainShapes(CSMWorld::CellCoordinates::toVertexCoords(hit.worldPos), 1, true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (CSVRender::PagedWorldspaceWidget *paged =
|
if (CSVRender::PagedWorldspaceWidget *paged =
|
||||||
dynamic_cast<CSVRender::PagedWorldspaceWidget *> (&getWorldspaceWidget()))
|
dynamic_cast<CSVRender::PagedWorldspaceWidget *> (&getWorldspaceWidget()))
|
||||||
@ -131,21 +149,7 @@ bool CSVRender::TerrainShapeMode::primaryEditStartDrag (const QPoint& pos)
|
|||||||
mEditingPos = hit.worldPos;
|
mEditingPos = hit.worldPos;
|
||||||
mIsEditing = true;
|
mIsEditing = true;
|
||||||
if (mShapeEditTool == 4)
|
if (mShapeEditTool == 4)
|
||||||
{
|
setFlattenToolTargetHeight(hit);
|
||||||
std::pair<int, int> vertexCoords = CSMWorld::CellCoordinates::toVertexCoords(hit.worldPos);
|
|
||||||
std::string cellId = CSMWorld::CellCoordinates::vertexGlobalToCellId(vertexCoords);
|
|
||||||
int inCellX = CSMWorld::CellCoordinates::vertexGlobalToInCellCoords(vertexCoords.first);
|
|
||||||
int inCellY = CSMWorld::CellCoordinates::vertexGlobalToInCellCoords(vertexCoords.second);
|
|
||||||
|
|
||||||
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);
|
|
||||||
const CSMWorld::LandHeightsColumn::DataType landShapePointer =
|
|
||||||
landTable.data(landTable.getModelIndex(cellId, landshapeColumn)).value<CSMWorld::LandHeightsColumn::DataType>();
|
|
||||||
|
|
||||||
mTargetHeight = landShapePointer[inCellY * ESM::Land::LAND_SIZE + inCellX];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -216,6 +220,31 @@ void CSVRender::TerrainShapeMode::dragCompleted(const QPoint& pos)
|
|||||||
mIsEditing = false;
|
mIsEditing = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
applyTerrainEditChanges();
|
||||||
|
|
||||||
|
if (CSVRender::PagedWorldspaceWidget *paged = dynamic_cast<CSVRender::PagedWorldspaceWidget *> (&getWorldspaceWidget()))
|
||||||
|
paged->resetAllAlteredHeights();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void CSVRender::TerrainShapeMode::dragAborted()
|
||||||
|
{
|
||||||
|
if (CSVRender::PagedWorldspaceWidget *paged =
|
||||||
|
dynamic_cast<CSVRender::PagedWorldspaceWidget *> (&getWorldspaceWidget()))
|
||||||
|
{
|
||||||
|
paged->resetAllAlteredHeights();
|
||||||
|
mTotalDiffY = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSVRender::TerrainShapeMode::dragWheel (int diff, double speedFactor)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void CSVRender::TerrainShapeMode::applyTerrainEditChanges()
|
||||||
|
{
|
||||||
std::sort(mAlteredCells.begin(), mAlteredCells.end());
|
std::sort(mAlteredCells.begin(), mAlteredCells.end());
|
||||||
std::set<CSMWorld::CellCoordinates> removeDuplicates(mAlteredCells.begin(), mAlteredCells.end());
|
std::set<CSMWorld::CellCoordinates> removeDuplicates(mAlteredCells.begin(), mAlteredCells.end());
|
||||||
mAlteredCells.assign(removeDuplicates.begin(), removeDuplicates.end());
|
mAlteredCells.assign(removeDuplicates.begin(), removeDuplicates.end());
|
||||||
@ -348,25 +377,6 @@ void CSVRender::TerrainShapeMode::dragCompleted(const QPoint& pos)
|
|||||||
}
|
}
|
||||||
undoStack.endMacro();
|
undoStack.endMacro();
|
||||||
mAlteredCells.clear();
|
mAlteredCells.clear();
|
||||||
|
|
||||||
if (CSVRender::PagedWorldspaceWidget *paged = dynamic_cast<CSVRender::PagedWorldspaceWidget *> (&getWorldspaceWidget()))
|
|
||||||
paged->resetAllAlteredHeights();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void CSVRender::TerrainShapeMode::dragAborted()
|
|
||||||
{
|
|
||||||
if (CSVRender::PagedWorldspaceWidget *paged =
|
|
||||||
dynamic_cast<CSVRender::PagedWorldspaceWidget *> (&getWorldspaceWidget()))
|
|
||||||
{
|
|
||||||
paged->resetAllAlteredHeights();
|
|
||||||
mTotalDiffY = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void CSVRender::TerrainShapeMode::dragWheel (int diff, double speedFactor)
|
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVRender::TerrainShapeMode::editTerrainShapeGrid(const std::pair<int, int>& vertexCoords, bool dragOperation)
|
void CSVRender::TerrainShapeMode::editTerrainShapeGrid(const std::pair<int, int>& vertexCoords, bool dragOperation)
|
||||||
@ -460,6 +470,24 @@ void CSVRender::TerrainShapeMode::editTerrainShapeGrid(const std::pair<int, int>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CSVRender::TerrainShapeMode::setFlattenToolTargetHeight(const WorldspaceHitResult& hit)
|
||||||
|
{
|
||||||
|
std::pair<int, int> vertexCoords = CSMWorld::CellCoordinates::toVertexCoords(hit.worldPos);
|
||||||
|
std::string cellId = CSMWorld::CellCoordinates::vertexGlobalToCellId(vertexCoords);
|
||||||
|
int inCellX = CSMWorld::CellCoordinates::vertexGlobalToInCellCoords(vertexCoords.first);
|
||||||
|
int inCellY = CSMWorld::CellCoordinates::vertexGlobalToInCellCoords(vertexCoords.second);
|
||||||
|
|
||||||
|
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);
|
||||||
|
const CSMWorld::LandHeightsColumn::DataType landShapePointer =
|
||||||
|
landTable.data(landTable.getModelIndex(cellId, landshapeColumn)).value<CSMWorld::LandHeightsColumn::DataType>();
|
||||||
|
|
||||||
|
mTargetHeight = landShapePointer[inCellY * ESM::Land::LAND_SIZE + inCellX];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void CSVRender::TerrainShapeMode::alterHeight(const CSMWorld::CellCoordinates& cellCoords, int inCellX, int inCellY, float alteredHeight, bool useTool)
|
void CSVRender::TerrainShapeMode::alterHeight(const CSMWorld::CellCoordinates& cellCoords, int inCellX, int inCellY, float alteredHeight, bool useTool)
|
||||||
{
|
{
|
||||||
std::string cellId = CSMWorld::CellCoordinates::generateId(cellCoords.getX(), cellCoords.getY());
|
std::string cellId = CSMWorld::CellCoordinates::generateId(cellCoords.getX(), cellCoords.getY());
|
||||||
|
@ -81,9 +81,15 @@ namespace CSVRender
|
|||||||
virtual void dragWheel (int diff, double speedFactor);
|
virtual void dragWheel (int diff, double speedFactor);
|
||||||
virtual void dragMoveEvent (QDragMoveEvent *event);
|
virtual void dragMoveEvent (QDragMoveEvent *event);
|
||||||
|
|
||||||
|
/// Move pending alteredHeights changes to omwgame/omeaddon -data
|
||||||
|
void applyTerrainEditChanges();
|
||||||
|
|
||||||
/// Handle brush mechanics for shape editing
|
/// Handle brush mechanics for shape editing
|
||||||
void editTerrainShapeGrid (const std::pair<int, int>& vertexCoords, bool dragOperation);
|
void editTerrainShapeGrid (const std::pair<int, int>& vertexCoords, bool dragOperation);
|
||||||
|
|
||||||
|
/// set the target height for flatten tool
|
||||||
|
void setFlattenToolTargetHeight(const WorldspaceHitResult& hit);
|
||||||
|
|
||||||
/// Do a single height alteration for transient shape edit map
|
/// Do a single height alteration for transient shape edit map
|
||||||
void alterHeight(const CSMWorld::CellCoordinates& cellCoords, int inCellX, int inCellY, float alteredHeight, bool useTool = true);
|
void alterHeight(const CSMWorld::CellCoordinates& cellCoords, int inCellX, int inCellY, float alteredHeight, bool useTool = true);
|
||||||
|
|
||||||
|
@ -73,11 +73,6 @@ namespace CSVRender
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
float* TerrainStorage::getAlteredHeights()
|
|
||||||
{
|
|
||||||
return mAlteredHeight;
|
|
||||||
}
|
|
||||||
|
|
||||||
float* TerrainStorage::getAlteredHeight(int inCellX, int inCellY)
|
float* TerrainStorage::getAlteredHeight(int inCellX, int inCellY)
|
||||||
{
|
{
|
||||||
return &mAlteredHeight[inCellY*ESM::Land::LAND_SIZE + inCellX];
|
return &mAlteredHeight[inCellY*ESM::Land::LAND_SIZE + inCellX];
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
#ifndef OPENCS_RENDER_TERRAINSTORAGE_H
|
#ifndef OPENCS_RENDER_TERRAINSTORAGE_H
|
||||||
#define OPENCS_RENDER_TERRAINSTORAGE_H
|
#define OPENCS_RENDER_TERRAINSTORAGE_H
|
||||||
|
|
||||||
|
#include <array>
|
||||||
|
|
||||||
#include <components/esmterrain/storage.hpp>
|
#include <components/esmterrain/storage.hpp>
|
||||||
|
|
||||||
#include "../../model/world/data.hpp"
|
#include "../../model/world/data.hpp"
|
||||||
@ -16,11 +18,10 @@ namespace CSVRender
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
TerrainStorage(const CSMWorld::Data& data);
|
TerrainStorage(const CSMWorld::Data& data);
|
||||||
float mAlteredHeight[ESM::Land::LAND_SIZE * ESM::Land::LAND_SIZE + ESM::Land::LAND_SIZE];
|
std::array<float, ESM::Land::LAND_SIZE * ESM::Land::LAND_SIZE> mAlteredHeight;
|
||||||
void setAlteredHeight(int inCellX, int inCellY, float heightMap);
|
void setAlteredHeight(int inCellX, int inCellY, float heightMap);
|
||||||
void resetHeights();
|
void resetHeights();
|
||||||
float getSumOfAlteredAndTrueHeight(int cellX, int cellY, int inCellX, int inCellY);
|
float getSumOfAlteredAndTrueHeight(int cellX, int cellY, int inCellX, int inCellY);
|
||||||
float* getAlteredHeights();
|
|
||||||
float* getAlteredHeight(int inCellX, int inCellY);
|
float* getAlteredHeight(int inCellX, int inCellY);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user