Do not load height data to the qued tree since we do not need it now

pull/541/head
bzzt 6 years ago committed by Andrei Kortunov
parent ebcf8ca062
commit a61c0aaee1

@ -108,14 +108,11 @@ void QuadTreeNode::initNeighbours()
getChild(i)->initNeighbours();
}
void QuadTreeNode::traverse(ViewData* vd, osg::NodeVisitor* nv, const osg::Vec3f& viewPoint, bool visible, float maxDist)
void QuadTreeNode::traverse(ViewData* vd, const osg::Vec3f& viewPoint, float maxDist)
{
if (!hasValidBounds())
return;
if (nv && nv->getVisitorType() == osg::NodeVisitor::CULL_VISITOR)
visible = visible && !static_cast<osgUtil::CullVisitor*>(nv)->isCulled(mBoundingBox);
float dist = distance(viewPoint);
if (dist > maxDist)
return;
@ -123,11 +120,11 @@ void QuadTreeNode::traverse(ViewData* vd, osg::NodeVisitor* nv, const osg::Vec3f
bool stopTraversal = (mLodCallback->isSufficientDetail(this, dist)) || !getNumChildren();
if (stopTraversal)
vd->add(this, visible);
vd->add(this, true);
else
{
for (unsigned int i=0; i<getNumChildren(); ++i)
getChild(i)->traverse(vd, nv, viewPoint, visible, maxDist);
getChild(i)->traverse(vd, viewPoint, maxDist);
}
}

@ -92,8 +92,8 @@ namespace Terrain
const osg::Vec2f& getCenter() const;
/// Optimized version of traverse() that doesn't incur the overhead of NodeVisitor double-dispatch or fetching the various variables.
/// Note this doesn't do any culling for non-cull visitors (e.g. intersections) so it shouldn't be used for those.
void traverse(ViewData* vd, osg::NodeVisitor* nv, const osg::Vec3f& viewPoint, bool visible, float maxDist);
/// Note this doesn't do any culling.
void traverse(ViewData* vd, const osg::Vec3f& viewPoint, float maxDist);
/// Traverse to a specific node and add only that node.
void traverseTo(ViewData* vd, float size, const osg::Vec2f& center);

@ -188,15 +188,14 @@ public:
if (node->getSize() <= mMinSize)
{
// We arrived at a leaf
float minZ,maxZ;
if (mStorage->getMinMaxHeights(size, center, minZ, maxZ))
{
float cellWorldSize = mStorage->getCellWorldSize();
osg::BoundingBox boundingBox(osg::Vec3f((center.x()-halfSize)*cellWorldSize, (center.y()-halfSize)*cellWorldSize, minZ),
osg::Vec3f((center.x()+halfSize)*cellWorldSize, (center.y()+halfSize)*cellWorldSize, maxZ));
node->setBoundingBox(boundingBox);
}
// We arrived at a leaf.
// Since the tree is used for LOD level selection instead of culling, we do not need to load an actual height data here.
float minZ = -std::numeric_limits<float>::max();
float maxZ = std::numeric_limits<float>::max();
float cellWorldSize = mStorage->getCellWorldSize();
osg::BoundingBox boundingBox(osg::Vec3f((center.x()-halfSize)*cellWorldSize, (center.y()-halfSize)*cellWorldSize, minZ),
osg::Vec3f((center.x()+halfSize)*cellWorldSize, (center.y()+halfSize)*cellWorldSize, maxZ));
node->setBoundingBox(boundingBox);
return node;
}
else
@ -360,7 +359,7 @@ void QuadTreeWorld::accept(osg::NodeVisitor &nv)
mRootNode->traverseTo(vd, 1, osg::Vec2f(x+0.5,y+0.5));
}
else
mRootNode->traverse(vd, &nv, cv->getViewPoint(), true, mViewDistance);
mRootNode->traverse(vd, cv->getViewPoint(), mViewDistance);
}
else
{
@ -376,9 +375,9 @@ void QuadTreeWorld::accept(osg::NodeVisitor &nv)
mRootNode->intersect(vd, terrainIntersector);
}
}
else if (isCullVisitor)
if (isCullVisitor)
{
// view point is the same, but must still update visible status in case the camera has rotated
for (unsigned int i=0; i<vd->getNumEntries(); ++i)
{
ViewData::Entry& entry = vd->getEntry(i);
@ -471,7 +470,7 @@ void QuadTreeWorld::preload(View *view, const osg::Vec3f &viewPoint, std::atomic
ViewData* vd = static_cast<ViewData*>(view);
vd->setViewPoint(viewPoint);
mRootNode->traverse(vd, nullptr, viewPoint, false, mViewDistance);
mRootNode->traverse(vd, viewPoint, mViewDistance);
for (unsigned int i=0; i<vd->getNumEntries() && !abort; ++i)
{

Loading…
Cancel
Save