1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-01-29 17:15:34 +00:00

Use only cell position to detect cell change

This commit is contained in:
elsid 2023-08-12 00:55:06 +02:00
parent dc05e9adbb
commit a027cd898b
No known key found for this signature in database
GPG key ID: 4DE04C198CBA7625

View file

@ -223,20 +223,29 @@ namespace ESMTerrain
const osg::Vec2f origin = center - osg::Vec2f(size, size) * 0.5f;
const int startCellX = static_cast<int>(std::floor(origin.x()));
const int startCellY = static_cast<int>(std::floor(origin.y()));
ESM::ExteriorCellLocation lastCellLocation(startCellX - 1, startCellY - 1, worldspace);
const LandObject* land = nullptr;
std::pair lastCell{ startCellX, startCellY };
const LandObject* land = getLand(ESM::ExteriorCellLocation(startCellX, startCellY, worldspace), cache);
const ESM::LandData* heightData = nullptr;
const ESM::LandData* normalData = nullptr;
const ESM::LandData* colourData = nullptr;
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,
std::size_t vertX, std::size_t vertY) {
const int cellX = startCellX + cellShiftX;
const int cellY = startCellY + cellShiftY;
const std::pair cell{ cellX, cellY };
const ESM::ExteriorCellLocation cellLocation(cellX, cellY, worldspace);
if (lastCellLocation != cellLocation)
if (lastCell != cell)
{
land = getLand(cellLocation, cache);
@ -252,7 +261,7 @@ namespace ESMTerrain
validHeightDataExists = true;
}
lastCellLocation = cellLocation;
lastCell = cell;
}
float height = defaultHeight;