From 3e03a0d7bd6d00253997f5f10e3fff0de449df81 Mon Sep 17 00:00:00 2001 From: scrawl Date: Wed, 19 Jul 2017 13:14:18 +0200 Subject: [PATCH] Terrain: remove ref argument that is now always true --- components/terrain/quadtreenode.cpp | 4 ++-- components/terrain/viewdata.cpp | 10 ++++------ components/terrain/viewdata.hpp | 2 +- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/components/terrain/quadtreenode.cpp b/components/terrain/quadtreenode.cpp index 801cdef5c..0394adea7 100644 --- a/components/terrain/quadtreenode.cpp +++ b/components/terrain/quadtreenode.cpp @@ -132,14 +132,14 @@ ViewData* QuadTreeNode::getView(osg::NodeVisitor &nv) if (nv.getVisitorType() == osg::NodeVisitor::CULL_VISITOR) { osgUtil::CullVisitor* cv = static_cast(&nv); - ViewData* vd = mViewDataMap->getViewData(cv->getCurrentCamera(), true); + ViewData* vd = mViewDataMap->getViewData(cv->getCurrentCamera()); vd->setEyePoint(nv.getEyePoint()); return vd; } else // INTERSECTION_VISITOR { static osg::ref_ptr dummyObj = new osg::DummyObject; - ViewData* vd = mViewDataMap->getViewData(dummyObj.get(), true); + ViewData* vd = mViewDataMap->getViewData(dummyObj.get()); ViewData* defaultView = mViewDataMap->getDefaultView(); if (defaultView->hasEyePoint()) vd->setEyePoint(defaultView->getEyePoint()); diff --git a/components/terrain/viewdata.cpp b/components/terrain/viewdata.cpp index 5e16537f4..5c70f65f2 100644 --- a/components/terrain/viewdata.cpp +++ b/components/terrain/viewdata.cpp @@ -112,14 +112,13 @@ bool ViewData::Entry::set(QuadTreeNode *node, bool visible) } } -ViewData *ViewDataMap::getViewData(osg::Object *viewer, bool ref) +ViewData *ViewDataMap::getViewData(osg::Object *viewer) { Map::const_iterator found = mViews.find(viewer); if (found == mViews.end()) { ViewData* vd = createOrReuseView(); - if (ref) - vd->setViewer(viewer); + vd->setViewer(viewer); mViews[viewer] = vd; return vd; } @@ -147,8 +146,7 @@ void ViewDataMap::clearUnusedViews(unsigned int frame) for (Map::iterator it = mViews.begin(); it != mViews.end(); ) { ViewData* vd = it->second; - if ((!vd->getViewer() // if no ref was held, always need to clear to avoid holding a dangling ref. - || vd->getFrameLastUsed() + 2 < frame)) + if (vd->getFrameLastUsed() + 2 < frame) { vd->setViewer(NULL); vd->clear(); @@ -174,7 +172,7 @@ void ViewDataMap::setDefaultViewer(osg::Object *viewer) ViewData* ViewDataMap::getDefaultView() { - return getViewData(mDefaultViewer, true); + return getViewData(mDefaultViewer); } diff --git a/components/terrain/viewdata.hpp b/components/terrain/viewdata.hpp index e4bfbd10c..aaf5b788f 100644 --- a/components/terrain/viewdata.hpp +++ b/components/terrain/viewdata.hpp @@ -70,7 +70,7 @@ namespace Terrain class ViewDataMap : public osg::Referenced { public: - ViewData* getViewData(osg::Object* viewer, bool ref); + ViewData* getViewData(osg::Object* viewer); ViewData* createOrReuseView();