forked from mirror/openmw-tes3mp
Use the quad tree's minSize in the LodCallback
This commit is contained in:
parent
c22fde2bcd
commit
a041546b54
1 changed files with 12 additions and 4 deletions
|
@ -72,14 +72,22 @@ namespace Terrain
|
||||||
class DefaultLodCallback : public LodCallback
|
class DefaultLodCallback : public LodCallback
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
DefaultLodCallback(float minSize)
|
||||||
|
: mMinSize(minSize)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
virtual bool isSufficientDetail(QuadTreeNode* node, const osg::Vec3f& eyePoint)
|
virtual bool isSufficientDetail(QuadTreeNode* node, const osg::Vec3f& eyePoint)
|
||||||
{
|
{
|
||||||
float dist = distance(node->getBoundingBox(), eyePoint);
|
float dist = distance(node->getBoundingBox(), eyePoint);
|
||||||
int nativeLodLevel = Log2(static_cast<unsigned int>(node->getSize()*4));
|
int nativeLodLevel = Log2(static_cast<unsigned int>(node->getSize()/mMinSize));
|
||||||
int lodLevel = Log2(static_cast<unsigned int>(dist/2048.0));
|
int lodLevel = Log2(static_cast<unsigned int>(dist/(8192*mMinSize)));
|
||||||
|
|
||||||
return nativeLodLevel <= lodLevel;
|
return nativeLodLevel <= lodLevel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
float mMinSize;
|
||||||
};
|
};
|
||||||
|
|
||||||
class RootNode : public QuadTreeNode
|
class RootNode : public QuadTreeNode
|
||||||
|
@ -135,7 +143,7 @@ public:
|
||||||
|
|
||||||
mRootNode = new RootNode(size, osg::Vec2f(centerX, centerY));
|
mRootNode = new RootNode(size, osg::Vec2f(centerX, centerY));
|
||||||
mRootNode->setViewDataMap(mViewDataMap);
|
mRootNode->setViewDataMap(mViewDataMap);
|
||||||
mRootNode->setLodCallback(new DefaultLodCallback);
|
mRootNode->setLodCallback(new DefaultLodCallback(mMinSize));
|
||||||
addChildren(mRootNode);
|
addChildren(mRootNode);
|
||||||
|
|
||||||
mRootNode->initNeighbours();
|
mRootNode->initNeighbours();
|
||||||
|
@ -177,7 +185,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
osg::ref_ptr<QuadTreeNode> node = new QuadTreeNode(parent, direction, size, center);
|
osg::ref_ptr<QuadTreeNode> node = new QuadTreeNode(parent, direction, size, center);
|
||||||
node->setLodCallback(new DefaultLodCallback);
|
node->setLodCallback(parent->getLodCallback());
|
||||||
node->setViewDataMap(mViewDataMap);
|
node->setViewDataMap(mViewDataMap);
|
||||||
parent->addChild(node);
|
parent->addChild(node);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue