mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-30 13:15:34 +00:00
Use only cell position to detect cell change
This commit is contained in:
parent
dc05e9adbb
commit
a027cd898b
1 changed files with 13 additions and 4 deletions
|
@ -223,20 +223,29 @@ namespace ESMTerrain
|
||||||
const osg::Vec2f origin = center - osg::Vec2f(size, size) * 0.5f;
|
const osg::Vec2f origin = center - osg::Vec2f(size, size) * 0.5f;
|
||||||
const int startCellX = static_cast<int>(std::floor(origin.x()));
|
const int startCellX = static_cast<int>(std::floor(origin.x()));
|
||||||
const int startCellY = static_cast<int>(std::floor(origin.y()));
|
const int startCellY = static_cast<int>(std::floor(origin.y()));
|
||||||
ESM::ExteriorCellLocation lastCellLocation(startCellX - 1, startCellY - 1, worldspace);
|
std::pair lastCell{ startCellX, startCellY };
|
||||||
const LandObject* land = nullptr;
|
const LandObject* land = getLand(ESM::ExteriorCellLocation(startCellX, startCellY, worldspace), cache);
|
||||||
const ESM::LandData* heightData = nullptr;
|
const ESM::LandData* heightData = nullptr;
|
||||||
const ESM::LandData* normalData = nullptr;
|
const ESM::LandData* normalData = nullptr;
|
||||||
const ESM::LandData* colourData = nullptr;
|
const ESM::LandData* colourData = nullptr;
|
||||||
bool validHeightDataExists = false;
|
bool validHeightDataExists = false;
|
||||||
|
|
||||||
|
if (land != nullptr)
|
||||||
|
{
|
||||||
|
heightData = land->getData(ESM::Land::DATA_VHGT);
|
||||||
|
normalData = land->getData(ESM::Land::DATA_VNML);
|
||||||
|
colourData = land->getData(ESM::Land::DATA_VCLR);
|
||||||
|
validHeightDataExists = true;
|
||||||
|
}
|
||||||
|
|
||||||
const auto handleSample = [&](std::size_t cellShiftX, std::size_t cellShiftY, std::size_t row, std::size_t col,
|
const auto handleSample = [&](std::size_t cellShiftX, std::size_t cellShiftY, std::size_t row, std::size_t col,
|
||||||
std::size_t vertX, std::size_t vertY) {
|
std::size_t vertX, std::size_t vertY) {
|
||||||
const int cellX = startCellX + cellShiftX;
|
const int cellX = startCellX + cellShiftX;
|
||||||
const int cellY = startCellY + cellShiftY;
|
const int cellY = startCellY + cellShiftY;
|
||||||
|
const std::pair cell{ cellX, cellY };
|
||||||
const ESM::ExteriorCellLocation cellLocation(cellX, cellY, worldspace);
|
const ESM::ExteriorCellLocation cellLocation(cellX, cellY, worldspace);
|
||||||
|
|
||||||
if (lastCellLocation != cellLocation)
|
if (lastCell != cell)
|
||||||
{
|
{
|
||||||
land = getLand(cellLocation, cache);
|
land = getLand(cellLocation, cache);
|
||||||
|
|
||||||
|
@ -252,7 +261,7 @@ namespace ESMTerrain
|
||||||
validHeightDataExists = true;
|
validHeightDataExists = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
lastCellLocation = cellLocation;
|
lastCell = cell;
|
||||||
}
|
}
|
||||||
|
|
||||||
float height = defaultHeight;
|
float height = defaultHeight;
|
||||||
|
|
Loading…
Reference in a new issue