mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-03-13 07:14:31 +00:00
Do not load height data to the qued tree since we do not need it now
This commit is contained in:
parent
ebcf8ca062
commit
a61c0aaee1
@ -108,14 +108,11 @@ void QuadTreeNode::initNeighbours()
|
|||||||
getChild(i)->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())
|
if (!hasValidBounds())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (nv && nv->getVisitorType() == osg::NodeVisitor::CULL_VISITOR)
|
|
||||||
visible = visible && !static_cast<osgUtil::CullVisitor*>(nv)->isCulled(mBoundingBox);
|
|
||||||
|
|
||||||
float dist = distance(viewPoint);
|
float dist = distance(viewPoint);
|
||||||
if (dist > maxDist)
|
if (dist > maxDist)
|
||||||
return;
|
return;
|
||||||
@ -123,11 +120,11 @@ void QuadTreeNode::traverse(ViewData* vd, osg::NodeVisitor* nv, const osg::Vec3f
|
|||||||
bool stopTraversal = (mLodCallback->isSufficientDetail(this, dist)) || !getNumChildren();
|
bool stopTraversal = (mLodCallback->isSufficientDetail(this, dist)) || !getNumChildren();
|
||||||
|
|
||||||
if (stopTraversal)
|
if (stopTraversal)
|
||||||
vd->add(this, visible);
|
vd->add(this, true);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (unsigned int i=0; i<getNumChildren(); ++i)
|
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;
|
const osg::Vec2f& getCenter() const;
|
||||||
|
|
||||||
/// Optimized version of traverse() that doesn't incur the overhead of NodeVisitor double-dispatch or fetching the various variables.
|
/// 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.
|
/// Note this doesn't do any culling.
|
||||||
void traverse(ViewData* vd, osg::NodeVisitor* nv, const osg::Vec3f& viewPoint, bool visible, float maxDist);
|
void traverse(ViewData* vd, const osg::Vec3f& viewPoint, float maxDist);
|
||||||
|
|
||||||
/// Traverse to a specific node and add only that node.
|
/// Traverse to a specific node and add only that node.
|
||||||
void traverseTo(ViewData* vd, float size, const osg::Vec2f& center);
|
void traverseTo(ViewData* vd, float size, const osg::Vec2f& center);
|
||||||
|
@ -188,15 +188,14 @@ public:
|
|||||||
|
|
||||||
if (node->getSize() <= mMinSize)
|
if (node->getSize() <= mMinSize)
|
||||||
{
|
{
|
||||||
// We arrived at a leaf
|
// We arrived at a leaf.
|
||||||
float minZ,maxZ;
|
// Since the tree is used for LOD level selection instead of culling, we do not need to load an actual height data here.
|
||||||
if (mStorage->getMinMaxHeights(size, center, minZ, maxZ))
|
float minZ = -std::numeric_limits<float>::max();
|
||||||
{
|
float maxZ = std::numeric_limits<float>::max();
|
||||||
float cellWorldSize = mStorage->getCellWorldSize();
|
float cellWorldSize = mStorage->getCellWorldSize();
|
||||||
osg::BoundingBox boundingBox(osg::Vec3f((center.x()-halfSize)*cellWorldSize, (center.y()-halfSize)*cellWorldSize, minZ),
|
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));
|
osg::Vec3f((center.x()+halfSize)*cellWorldSize, (center.y()+halfSize)*cellWorldSize, maxZ));
|
||||||
node->setBoundingBox(boundingBox);
|
node->setBoundingBox(boundingBox);
|
||||||
}
|
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -360,7 +359,7 @@ void QuadTreeWorld::accept(osg::NodeVisitor &nv)
|
|||||||
mRootNode->traverseTo(vd, 1, osg::Vec2f(x+0.5,y+0.5));
|
mRootNode->traverseTo(vd, 1, osg::Vec2f(x+0.5,y+0.5));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
mRootNode->traverse(vd, &nv, cv->getViewPoint(), true, mViewDistance);
|
mRootNode->traverse(vd, cv->getViewPoint(), mViewDistance);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -376,9 +375,9 @@ void QuadTreeWorld::accept(osg::NodeVisitor &nv)
|
|||||||
mRootNode->intersect(vd, terrainIntersector);
|
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)
|
for (unsigned int i=0; i<vd->getNumEntries(); ++i)
|
||||||
{
|
{
|
||||||
ViewData::Entry& entry = vd->getEntry(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);
|
ViewData* vd = static_cast<ViewData*>(view);
|
||||||
vd->setViewPoint(viewPoint);
|
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)
|
for (unsigned int i=0; i<vd->getNumEntries() && !abort; ++i)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user