From a041546b54f95b64ba9bee7baebdea2314095171 Mon Sep 17 00:00:00 2001 From: scrawl Date: Sun, 12 Mar 2017 22:39:53 +0100 Subject: [PATCH] Use the quad tree's minSize in the LodCallback --- components/terrain/quadtreeworld.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/components/terrain/quadtreeworld.cpp b/components/terrain/quadtreeworld.cpp index dfcf20509..7afdccca6 100644 --- a/components/terrain/quadtreeworld.cpp +++ b/components/terrain/quadtreeworld.cpp @@ -72,14 +72,22 @@ namespace Terrain class DefaultLodCallback : public LodCallback { public: + DefaultLodCallback(float minSize) + : mMinSize(minSize) + { + } + virtual bool isSufficientDetail(QuadTreeNode* node, const osg::Vec3f& eyePoint) { float dist = distance(node->getBoundingBox(), eyePoint); - int nativeLodLevel = Log2(static_cast(node->getSize()*4)); - int lodLevel = Log2(static_cast(dist/2048.0)); + int nativeLodLevel = Log2(static_cast(node->getSize()/mMinSize)); + int lodLevel = Log2(static_cast(dist/(8192*mMinSize))); return nativeLodLevel <= lodLevel; } + +private: + float mMinSize; }; class RootNode : public QuadTreeNode @@ -135,7 +143,7 @@ public: mRootNode = new RootNode(size, osg::Vec2f(centerX, centerY)); mRootNode->setViewDataMap(mViewDataMap); - mRootNode->setLodCallback(new DefaultLodCallback); + mRootNode->setLodCallback(new DefaultLodCallback(mMinSize)); addChildren(mRootNode); mRootNode->initNeighbours(); @@ -177,7 +185,7 @@ public: } osg::ref_ptr node = new QuadTreeNode(parent, direction, size, center); - node->setLodCallback(new DefaultLodCallback); + node->setLodCallback(parent->getLodCallback()); node->setViewDataMap(mViewDataMap); parent->addChild(node);