Add QuadTreeWorld::cacheCell to preload cells at max LOD for local maps

pull/1225/head
scrawl 8 years ago
parent 6ccb6009ee
commit 7d50b6c2e2

@ -384,6 +384,41 @@ void QuadTreeWorld::enable(bool enabled)
mRootNode->setNodeMask(enabled ? ~0 : 0);
}
void traverseToCell(QuadTreeNode* node, ViewData* vd, int cellX, int cellY)
{
if (!node->hasValidBounds())
return;
if (node->getCenter().x() + node->getSize()/2.f <= cellX
|| node->getCenter().x() - node->getSize()/2.f >= cellX+1
|| node->getCenter().y() + node->getSize()/2.f <= cellY
|| node->getCenter().y() - node->getSize()/2.f >= cellY+1)
return;
bool stopTraversal = !node->getNumChildren();
if (stopTraversal)
vd->add(node, true);
else
{
for (unsigned int i=0; i<node->getNumChildren(); ++i)
traverseToCell(node->getChild(i), vd, cellX, cellY);
}
}
void QuadTreeWorld::cacheCell(View *view, int x, int y)
{
ensureQuadTreeBuilt();
ViewData* vd = static_cast<ViewData*>(view);
traverseToCell(mRootNode.get(), vd, x, y);
for (unsigned int i=0; i<vd->getNumEntries(); ++i)
{
ViewData::Entry& entry = vd->getEntry(i);
loadRenderingNode(entry, vd, mChunkManager.get());
}
}
View* QuadTreeWorld::createView()
{
return new ViewData;

@ -28,6 +28,8 @@ namespace Terrain
virtual void enable(bool enabled);
void cacheCell(View *view, int x, int y);
View* createView();
void preload(View* view, const osg::Vec3f& eyePoint);

Loading…
Cancel
Save