mirror of
https://github.com/OpenMW/openmw.git
synced 2025-02-21 12:39:41 +00:00
Get vertex height from data, if not available in visible cells.
This commit is contained in:
parent
9677203215
commit
8f6dc78217
2 changed files with 48 additions and 2 deletions
|
@ -242,10 +242,37 @@ void CSVRender::TerrainSelection::drawTextureSelection(const osg::ref_ptr<osg::V
|
|||
}
|
||||
}
|
||||
|
||||
bool CSVRender::TerrainSelection::noCell(const std::string& cellId)
|
||||
{
|
||||
CSMDoc::Document& document = mWorldspaceWidget->getDocument();
|
||||
const CSMWorld::IdCollection<CSMWorld::Cell>& cellCollection = document.getData().getCells();
|
||||
return cellCollection.searchId (cellId) == -1;
|
||||
}
|
||||
|
||||
bool CSVRender::TerrainSelection::noLand(const std::string& cellId)
|
||||
{
|
||||
CSMDoc::Document& document = mWorldspaceWidget->getDocument();
|
||||
const CSMWorld::IdCollection<CSMWorld::Land>& landCollection = document.getData().getLand();
|
||||
return landCollection.searchId (cellId) == -1;
|
||||
}
|
||||
|
||||
bool CSVRender::TerrainSelection::noLandLoaded(const std::string& cellId)
|
||||
{
|
||||
CSMDoc::Document& document = mWorldspaceWidget->getDocument();
|
||||
const CSMWorld::IdCollection<CSMWorld::Land>& landCollection = document.getData().getLand();
|
||||
return !landCollection.getRecord(cellId).get().isDataLoaded(ESM::Land::DATA_VNML);
|
||||
}
|
||||
|
||||
bool CSVRender::TerrainSelection::isLandLoaded(const std::string& cellId)
|
||||
{
|
||||
if (!noCell(cellId) && !noLand(cellId) && !noLandLoaded(cellId)) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
int CSVRender::TerrainSelection::calculateLandHeight(int x, int y) // global vertex coordinates
|
||||
{
|
||||
int cellX = std::floor((1.0f*x / (ESM::Land::LAND_SIZE - 1)));
|
||||
int cellY = std::floor((1.0f*y / (ESM::Land::LAND_SIZE - 1)));
|
||||
int cellX = std::floor(static_cast<float>(x) / (ESM::Land::LAND_SIZE - 1));
|
||||
int cellY = std::floor(static_cast<float>(y) / (ESM::Land::LAND_SIZE - 1));
|
||||
int localX = x - cellX * (ESM::Land::LAND_SIZE - 1);
|
||||
int localY = y - cellY * (ESM::Land::LAND_SIZE - 1);
|
||||
|
||||
|
@ -253,7 +280,18 @@ int CSVRender::TerrainSelection::calculateLandHeight(int x, int y) // global ver
|
|||
|
||||
float landHeight = 0.f;
|
||||
if (CSVRender::Cell* cell = dynamic_cast<CSVRender::Cell*>(mWorldspaceWidget->getCell(coords)))
|
||||
{
|
||||
landHeight = cell->getSumOfAlteredAndTrueHeight(cellX, cellY, localX, localY);
|
||||
}
|
||||
else if (isLandLoaded(CSMWorld::CellCoordinates::generateId(cellX, cellY)))
|
||||
{
|
||||
CSMDoc::Document& document = mWorldspaceWidget->getDocument();
|
||||
CSMWorld::IdTable& landTable = dynamic_cast<CSMWorld::IdTable&> ( *document.getData().getTableModel (CSMWorld::UniversalId::Type_Land));
|
||||
std::string cellId = CSMWorld::CellCoordinates::generateId(cellX, cellY);
|
||||
int landshapeColumn = landTable.findColumnIndex(CSMWorld::Columns::ColumnId_LandHeightsIndex);
|
||||
const CSMWorld::LandHeightsColumn::DataType mPointer = landTable.data(landTable.getModelIndex(cellId, landshapeColumn)).value<CSMWorld::LandHeightsColumn::DataType>();
|
||||
return mPointer[localY*ESM::Land::LAND_SIZE + localX];
|
||||
}
|
||||
|
||||
return landHeight;
|
||||
}
|
||||
|
|
|
@ -55,6 +55,14 @@ namespace CSVRender
|
|||
|
||||
private:
|
||||
|
||||
bool noCell(const std::string& cellId);
|
||||
|
||||
bool noLand(const std::string& cellId);
|
||||
|
||||
bool noLandLoaded(const std::string& cellId);
|
||||
|
||||
bool isLandLoaded(const std::string& cellId);
|
||||
|
||||
osg::Group* mParentNode;
|
||||
WorldspaceWidget *mWorldspaceWidget;
|
||||
osg::ref_ptr<osg::PositionAttitudeTransform> mBaseNode;
|
||||
|
|
Loading…
Reference in a new issue