1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-02-22 18:39:42 +00:00

Add height field to navigator in ESM4 cells

This commit is contained in:
elsid 2023-08-13 02:02:00 +02:00
parent 5abbc56bf2
commit eb77fd1813
No known key found for this signature in database
GPG key ID: 4DE04C198CBA7625
3 changed files with 6 additions and 11 deletions

View file

@ -481,11 +481,9 @@ namespace MWPhysics
mHeightFields.erase(heightfield);
}
const HeightField* PhysicsSystem::getHeightField(ESM::ExteriorCellLocation cellIndex) const
const HeightField* PhysicsSystem::getHeightField(int x, int y) const
{
if (ESM::isEsm4Ext(cellIndex.mWorldspace))
return nullptr;
const auto heightField = mHeightFields.find(std::make_pair(cellIndex.mX, cellIndex.mY));
const auto heightField = mHeightFields.find(std::make_pair(x, y));
if (heightField == mHeightFields.end())
return nullptr;
return heightField->second.get();

View file

@ -189,7 +189,7 @@ namespace MWPhysics
void removeHeightField(int x, int y);
const HeightField* getHeightField(ESM::ExteriorCellLocation cellIndex) const;
const HeightField* getHeightField(int x, int y) const;
bool toggleCollisionMode();

View file

@ -346,10 +346,7 @@ namespace MWWorld
if (cell->getCell()->isExterior())
{
if (mPhysics->getHeightField(ESM::ExteriorCellLocation(cellX, cellY, cell->getCell()->getWorldSpace()))
!= nullptr)
mNavigator.removeHeightfield(osg::Vec2i(cellX, cellY), navigatorUpdateGuard);
mPhysics->removeHeightField(cellX, cellY);
}
@ -414,7 +411,7 @@ namespace MWWorld
mPhysics->addHeightField(defaultHeight.data(), cellX, cellY, worldsize, verts,
ESM::Land::DEFAULT_HEIGHT, ESM::Land::DEFAULT_HEIGHT, land.get());
}
if (const auto heightField = mPhysics->getHeightField(cellIndex))
if (const auto heightField = mPhysics->getHeightField(cellX, cellY))
{
const osg::Vec2i cellPosition(cellX, cellY);
const btVector3& origin = heightField->getCollisionObject()->getWorldTransform().getOrigin();
@ -469,7 +466,7 @@ namespace MWWorld
if (cellVariant.isExterior())
{
if (const auto heightField = mPhysics->getHeightField(cellIndex))
if (const auto heightField = mPhysics->getHeightField(cellX, cellY))
mNavigator.addWater(
osg::Vec2i(cellX, cellY), ESM::Land::REAL_SIZE, waterLevel, navigatorUpdateGuard);
}