mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-03-23 19:20:56 +00:00
takes the right terrain bounds.
This commit is contained in:
parent
7bc4fc6bf9
commit
0e4d21a40c
@ -34,7 +34,7 @@ namespace MWRender
|
||||
return land != nullptr;
|
||||
}
|
||||
|
||||
void TerrainStorage::getBounds(float& minX, float& maxX, float& minY, float& maxY)
|
||||
void TerrainStorage::getBounds(float& minX, float& maxX, float& minY, float& maxY, ESM::RefId worldspace)
|
||||
{
|
||||
minX = 0;
|
||||
minY = 0;
|
||||
@ -43,19 +43,41 @@ namespace MWRender
|
||||
|
||||
const MWWorld::ESMStore& esmStore = *MWBase::Environment::get().getESMStore();
|
||||
|
||||
MWWorld::Store<ESM::Land>::iterator it = esmStore.get<ESM::Land>().begin();
|
||||
for (; it != esmStore.get<ESM::Land>().end(); ++it)
|
||||
if (ESM::isEsm4Ext(worldspace))
|
||||
{
|
||||
if (it->mX < minX)
|
||||
minX = static_cast<float>(it->mX);
|
||||
if (it->mX > maxX)
|
||||
maxX = static_cast<float>(it->mX);
|
||||
if (it->mY < minY)
|
||||
minY = static_cast<float>(it->mY);
|
||||
if (it->mY > maxY)
|
||||
maxY = static_cast<float>(it->mY);
|
||||
const auto& lands = esmStore.get<ESM4::Land>().getLands();
|
||||
for (const auto& it : lands)
|
||||
{
|
||||
if (it.first.mWorldspace == worldspace)
|
||||
{
|
||||
int x = it.first.mX;
|
||||
int y = it.first.mY;
|
||||
if (x < minX)
|
||||
minX = static_cast<float>(x);
|
||||
if (x > maxX)
|
||||
maxX = static_cast<float>(x);
|
||||
if (y < minY)
|
||||
minY = static_cast<float>(y);
|
||||
if (y > maxY)
|
||||
maxY = static_cast<float>(y);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MWWorld::Store<ESM::Land>::iterator it = esmStore.get<ESM::Land>().begin();
|
||||
for (; it != esmStore.get<ESM::Land>().end(); ++it)
|
||||
{
|
||||
if (it->mX < minX)
|
||||
minX = static_cast<float>(it->mX);
|
||||
if (it->mX > maxX)
|
||||
maxX = static_cast<float>(it->mX);
|
||||
if (it->mY < minY)
|
||||
minY = static_cast<float>(it->mY);
|
||||
if (it->mY > maxY)
|
||||
maxY = static_cast<float>(it->mY);
|
||||
}
|
||||
}
|
||||
|
||||
// since grid coords are at cell origin, we need to add 1 cell
|
||||
maxX += 1;
|
||||
maxY += 1;
|
||||
|
@ -27,7 +27,7 @@ namespace MWRender
|
||||
bool hasData(ESM::ExteriorCellLocation cellLocation) override;
|
||||
|
||||
/// Get bounds of the whole terrain in cell units
|
||||
void getBounds(float& minX, float& maxX, float& minY, float& maxY) override;
|
||||
void getBounds(float& minX, float& maxX, float& minY, float& maxY, ESM::RefId worldspace) override;
|
||||
|
||||
LandManager* getLandManager() const;
|
||||
|
||||
|
@ -312,6 +312,7 @@ namespace MWWorld
|
||||
void updateLandPositions(const Store<ESM4::Cell>& cells);
|
||||
|
||||
const ESM4::Land* search(ESM::ExteriorCellLocation cellLocation) const;
|
||||
const std::unordered_map<ESM::ExteriorCellLocation, const ESM4::Land*>& getLands() const { return mLands; };
|
||||
};
|
||||
|
||||
template <>
|
||||
|
@ -72,7 +72,7 @@ namespace ESMTerrain
|
||||
virtual osg::ref_ptr<const LandObject> getLand(ESM::ExteriorCellLocation cellLocation) = 0;
|
||||
virtual const ESM::LandTexture* getLandTexture(int index, short plugin) = 0;
|
||||
/// Get bounds of the whole terrain in cell units
|
||||
void getBounds(float& minX, float& maxX, float& minY, float& maxY) override = 0;
|
||||
void getBounds(float& minX, float& maxX, float& minY, float& maxY, ESM::RefId worldspace) override = 0;
|
||||
|
||||
/// Get the minimum and maximum heights of a terrain region.
|
||||
/// @note Will only be called for chunks with size = minBatchSize, i.e. leafs of the quad tree.
|
||||
|
@ -130,7 +130,7 @@ namespace Terrain
|
||||
|
||||
void build()
|
||||
{
|
||||
mStorage->getBounds(mMinX, mMaxX, mMinY, mMaxY);
|
||||
mStorage->getBounds(mMinX, mMaxX, mMinY, mMaxY, mWorldspace);
|
||||
|
||||
int origSizeX = static_cast<int>(mMaxX - mMinX);
|
||||
int origSizeY = static_cast<int>(mMaxY - mMinY);
|
||||
|
@ -29,7 +29,7 @@ namespace Terrain
|
||||
|
||||
public:
|
||||
/// Get bounds of the whole terrain in cell units
|
||||
virtual void getBounds(float& minX, float& maxX, float& minY, float& maxY) = 0;
|
||||
virtual void getBounds(float& minX, float& maxX, float& minY, float& maxY, ESM::RefId worldspace) = 0;
|
||||
|
||||
/// Return true if there is land data for this cell
|
||||
/// May be overriden for a faster implementation
|
||||
|
Loading…
x
Reference in New Issue
Block a user