forked from mirror/openmw-tes3mp
Don't use terrain LOD for the map camera
This commit is contained in:
parent
e7a0878c10
commit
28fd492711
2 changed files with 18 additions and 5 deletions
|
@ -160,6 +160,7 @@ void LocalMap::saveFogOfWar(MWWorld::CellStore* cell)
|
||||||
osg::ref_ptr<osg::Camera> LocalMap::createOrthographicCamera(float x, float y, float width, float height, const osg::Vec3d& upVector, float zmin, float zmax)
|
osg::ref_ptr<osg::Camera> LocalMap::createOrthographicCamera(float x, float y, float width, float height, const osg::Vec3d& upVector, float zmin, float zmax)
|
||||||
{
|
{
|
||||||
osg::ref_ptr<osg::Camera> camera (new osg::Camera);
|
osg::ref_ptr<osg::Camera> camera (new osg::Camera);
|
||||||
|
camera->getOrCreateUserDataContainer()->addDescription("NoTerrainLod");
|
||||||
|
|
||||||
camera->setProjectionMatrixAsOrtho(-width/2, width/2, -height/2, height/2, 5, (zmax-zmin) + 10);
|
camera->setProjectionMatrixAsOrtho(-width/2, width/2, -height/2, height/2, 5, (zmax-zmin) + 10);
|
||||||
camera->setComputeNearFarMode(osg::Camera::DO_NOT_COMPUTE_NEAR_FAR);
|
camera->setComputeNearFarMode(osg::Camera::DO_NOT_COMPUTE_NEAR_FAR);
|
||||||
|
|
|
@ -133,6 +133,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);
|
||||||
addChildren(mRootNode);
|
addChildren(mRootNode);
|
||||||
|
|
||||||
mRootNode->initNeighbours();
|
mRootNode->initNeighbours();
|
||||||
|
@ -238,7 +239,7 @@ QuadTreeWorld::~QuadTreeWorld()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void traverse(QuadTreeNode* node, ViewData* vd, osg::NodeVisitor* nv, const osg::Vec3f& eyePoint, bool visible)
|
void traverse(QuadTreeNode* node, ViewData* vd, osg::NodeVisitor* nv, LodCallback* lodCallback, const osg::Vec3f& eyePoint, bool visible, bool traverseNonVisible)
|
||||||
{
|
{
|
||||||
if (!node->hasValidBounds())
|
if (!node->hasValidBounds())
|
||||||
return;
|
return;
|
||||||
|
@ -246,14 +247,17 @@ void traverse(QuadTreeNode* node, ViewData* vd, osg::NodeVisitor* nv, const osg:
|
||||||
if (nv && nv->getVisitorType() == osg::NodeVisitor::CULL_VISITOR)
|
if (nv && nv->getVisitorType() == osg::NodeVisitor::CULL_VISITOR)
|
||||||
visible = visible && !static_cast<osgUtil::CullVisitor*>(nv)->isCulled(node->getBoundingBox());
|
visible = visible && !static_cast<osgUtil::CullVisitor*>(nv)->isCulled(node->getBoundingBox());
|
||||||
|
|
||||||
bool stopTraversal = (node->getLodCallback() && node->getLodCallback()->isSufficientDetail(node, eyePoint)) || !node->getNumChildren();
|
if (!visible && !traverseNonVisible)
|
||||||
|
return;
|
||||||
|
|
||||||
|
bool stopTraversal = (lodCallback && lodCallback->isSufficientDetail(node, eyePoint)) || !node->getNumChildren();
|
||||||
|
|
||||||
if (stopTraversal)
|
if (stopTraversal)
|
||||||
vd->add(node, visible);
|
vd->add(node, visible);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (unsigned int i=0; i<node->getNumChildren(); ++i)
|
for (unsigned int i=0; i<node->getNumChildren(); ++i)
|
||||||
traverse(node->getChild(i), vd, nv, eyePoint, visible);
|
traverse(node->getChild(i), vd, nv, lodCallback, eyePoint, visible, traverseNonVisible);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -315,7 +319,15 @@ void QuadTreeWorld::accept(osg::NodeVisitor &nv)
|
||||||
if (nv.getVisitorType() == osg::NodeVisitor::CULL_VISITOR)
|
if (nv.getVisitorType() == osg::NodeVisitor::CULL_VISITOR)
|
||||||
{
|
{
|
||||||
osgUtil::CullVisitor* cv = static_cast<osgUtil::CullVisitor*>(&nv);
|
osgUtil::CullVisitor* cv = static_cast<osgUtil::CullVisitor*>(&nv);
|
||||||
traverse(mRootNode.get(), vd, cv, cv->getEyePoint(), true);
|
|
||||||
|
LodCallback* lodCallback = mRootNode->getLodCallback();
|
||||||
|
if (osg::UserDataContainer* udc = cv->getCurrentCamera()->getUserDataContainer())
|
||||||
|
{
|
||||||
|
if (udc->getNumDescriptions() && udc->getDescriptions()[0] == "NoTerrainLod")
|
||||||
|
lodCallback = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
traverse(mRootNode.get(), vd, cv, lodCallback, cv->getEyePoint(), true, lodCallback != NULL);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
mRootNode->traverse(nv);
|
mRootNode->traverse(nv);
|
||||||
|
@ -389,7 +401,7 @@ void QuadTreeWorld::preload(View *view, const osg::Vec3f &eyePoint)
|
||||||
ensureQuadTreeBuilt();
|
ensureQuadTreeBuilt();
|
||||||
|
|
||||||
ViewData* vd = static_cast<ViewData*>(view);
|
ViewData* vd = static_cast<ViewData*>(view);
|
||||||
traverse(mRootNode.get(), vd, NULL, eyePoint, false);
|
traverse(mRootNode.get(), vd, NULL, mRootNode->getLodCallback(), eyePoint, false, true);
|
||||||
|
|
||||||
for (unsigned int i=0; i<vd->getNumEntries(); ++i)
|
for (unsigned int i=0; i<vd->getNumEntries(); ++i)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue