mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-31 21:45:33 +00:00
Render nearby default cells if the Distant Terrain is disabled
This commit is contained in:
parent
46e1ed660c
commit
a6fd077537
3 changed files with 32 additions and 2 deletions
|
@ -249,7 +249,7 @@ private:
|
|||
};
|
||||
|
||||
QuadTreeWorld::QuadTreeWorld(osg::Group *parent, osg::Group *compileRoot, Resource::ResourceSystem *resourceSystem, Storage *storage, int nodeMask, int preCompileMask, int borderMask, int compMapResolution, float compMapLevel, float lodFactor, int vertexLodMod, float maxCompGeometrySize)
|
||||
: World(parent, compileRoot, resourceSystem, storage, nodeMask, preCompileMask, borderMask)
|
||||
: TerrainGrid(parent, compileRoot, resourceSystem, storage, nodeMask, preCompileMask, borderMask)
|
||||
, mViewDataMap(new ViewDataMap)
|
||||
, mQuadTreeBuilt(false)
|
||||
, mLodFactor(lodFactor)
|
||||
|
@ -515,5 +515,25 @@ void QuadTreeWorld::setDefaultViewer(osg::Object *obj)
|
|||
mViewDataMap->setDefaultViewer(obj);
|
||||
}
|
||||
|
||||
void QuadTreeWorld::loadCell(int x, int y)
|
||||
{
|
||||
// fallback behavior only for undefined cells (every other is already handled in quadtree)
|
||||
float dummy;
|
||||
if (!mStorage->getMinMaxHeights(1, osg::Vec2f(x+0.5, y+0.5), dummy, dummy))
|
||||
TerrainGrid::loadCell(x,y);
|
||||
else
|
||||
World::loadCell(x,y);
|
||||
}
|
||||
|
||||
void QuadTreeWorld::unloadCell(int x, int y)
|
||||
{
|
||||
// fallback behavior only for undefined cells (every other is already handled in quadtree)
|
||||
float dummy;
|
||||
if (!mStorage->getMinMaxHeights(1, osg::Vec2f(x+0.5, y+0.5), dummy, dummy))
|
||||
TerrainGrid::unloadCell(x,y);
|
||||
else
|
||||
World::unloadCell(x,y);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#define COMPONENTS_TERRAIN_QUADTREEWORLD_H
|
||||
|
||||
#include "world.hpp"
|
||||
#include "terraingrid.hpp"
|
||||
|
||||
#include <OpenThreads/Mutex>
|
||||
|
||||
|
@ -16,7 +17,7 @@ namespace Terrain
|
|||
class ViewDataMap;
|
||||
|
||||
/// @brief Terrain implementation that loads cells into a Quad Tree, with geometry LOD and texture LOD. The entire world is displayed at all times.
|
||||
class QuadTreeWorld : public Terrain::World
|
||||
class QuadTreeWorld : public TerrainGrid // note: derived from TerrainGrid is only to render default cells (see loadCell)
|
||||
{
|
||||
public:
|
||||
QuadTreeWorld(osg::Group* parent, osg::Group* compileRoot, Resource::ResourceSystem* resourceSystem, Storage* storage, int nodeMask, int preCompileMask, int borderMask, int compMapResolution, float comMapLevel, float lodFactor, int vertexLodMod, float maxCompGeometrySize);
|
||||
|
@ -28,6 +29,10 @@ namespace Terrain
|
|||
virtual void enable(bool enabled);
|
||||
|
||||
void cacheCell(View *view, int x, int y);
|
||||
/// @note Not thread safe.
|
||||
virtual void loadCell(int x, int y);
|
||||
/// @note Not thread safe.
|
||||
virtual void unloadCell(int x, int y);
|
||||
|
||||
View* createView();
|
||||
void preload(View* view, const osg::Vec3f& eyePoint);
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
#include <osg/Group>
|
||||
|
||||
#include "chunkmanager.hpp"
|
||||
#include "compositemaprenderer.hpp"
|
||||
|
||||
namespace Terrain
|
||||
{
|
||||
|
@ -61,6 +62,10 @@ osg::ref_ptr<osg::Node> TerrainGrid::buildTerrain (osg::Group* parent, float chu
|
|||
if (parent)
|
||||
parent->addChild(node);
|
||||
|
||||
osg::UserDataContainer* udc = node->getUserDataContainer();
|
||||
if (udc && udc->getUserData())
|
||||
mCompositeMapRenderer->setImmediate(static_cast<CompositeMap*>(udc->getUserData()));
|
||||
|
||||
return node;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue