mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-02-04 03:40:14 +00:00
Reject empty quad tree nodes at the cell level without land data
This commit is contained in:
parent
36fa51b6ad
commit
6029ed4ecc
@ -22,6 +22,15 @@ namespace MWRender
|
|||||||
mResourceSystem->removeResourceManager(mLandManager.get());
|
mResourceSystem->removeResourceManager(mLandManager.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool TerrainStorage::hasData(int cellX, int cellY)
|
||||||
|
{
|
||||||
|
const MWWorld::ESMStore &esmStore =
|
||||||
|
MWBase::Environment::get().getWorld()->getStore();
|
||||||
|
|
||||||
|
const ESM::Land* land = esmStore.get<ESM::Land>().search(cellX, cellY);
|
||||||
|
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)
|
||||||
{
|
{
|
||||||
minX = 0, minY = 0, maxX = 0, maxY = 0;
|
minX = 0, minY = 0, maxX = 0, maxY = 0;
|
||||||
|
@ -23,6 +23,8 @@ namespace MWRender
|
|||||||
virtual osg::ref_ptr<const ESMTerrain::LandObject> getLand (int cellX, int cellY);
|
virtual osg::ref_ptr<const ESMTerrain::LandObject> getLand (int cellX, int cellY);
|
||||||
virtual const ESM::LandTexture* getLandTexture(int index, short plugin);
|
virtual const ESM::LandTexture* getLandTexture(int index, short plugin);
|
||||||
|
|
||||||
|
virtual bool hasData(int cellX, int cellY) override;
|
||||||
|
|
||||||
/// Get bounds of the whole terrain in cell units
|
/// Get bounds of the whole terrain in cell units
|
||||||
virtual void getBounds(float& minX, float& maxX, float& minY, float& maxY);
|
virtual void getBounds(float& minX, float& maxX, float& minY, float& maxY);
|
||||||
|
|
||||||
|
@ -184,6 +184,11 @@ public:
|
|||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Do not add child nodes for default cells without data.
|
||||||
|
// size = 1 means that the single shape covers the whole cell.
|
||||||
|
if (node->getSize() == 1 && !mStorage->hasData(center.x()-0.5, center.y()-0.5))
|
||||||
|
return node;
|
||||||
|
|
||||||
if (node->getSize() <= mMinSize)
|
if (node->getSize() <= mMinSize)
|
||||||
{
|
{
|
||||||
// We arrived at a leaf
|
// We arrived at a leaf
|
||||||
|
@ -28,6 +28,14 @@ namespace Terrain
|
|||||||
/// Get bounds of the whole terrain in cell units
|
/// 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) = 0;
|
||||||
|
|
||||||
|
/// Return true if there is land data for this cell
|
||||||
|
/// May be overriden for a faster implementation
|
||||||
|
virtual bool hasData(int cellX, int cellY)
|
||||||
|
{
|
||||||
|
float dummy;
|
||||||
|
return getMinMaxHeights(1, osg::Vec2f(cellX+0.5, cellY+0.5), dummy, dummy);
|
||||||
|
}
|
||||||
|
|
||||||
/// Get the minimum and maximum heights of a terrain region.
|
/// 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.
|
/// @note Will only be called for chunks with size = minBatchSize, i.e. leafs of the quad tree.
|
||||||
/// Larger chunks can simply merge AABB of children.
|
/// Larger chunks can simply merge AABB of children.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user