mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-30 09:15:38 +00:00
view fix
Signed-off-by: Bret Curtis <psi29a@gmail.com>
This commit is contained in:
parent
b27b76e325
commit
4238fbccdf
4 changed files with 15 additions and 10 deletions
|
@ -1063,6 +1063,7 @@ namespace MWRender
|
|||
mIntersectionVisitor = new osgUtil::IntersectionVisitor;
|
||||
|
||||
mIntersectionVisitor->setTraversalNumber(mViewer->getFrameStamp()->getFrameNumber());
|
||||
mIntersectionVisitor->setFrameStamp(mViewer->getFrameStamp());
|
||||
mIntersectionVisitor->setIntersector(intersector);
|
||||
|
||||
int mask = ~0;
|
||||
|
|
|
@ -305,11 +305,10 @@ namespace MWWorld
|
|||
|
||||
void Scene::update (float duration, bool paused)
|
||||
{
|
||||
mPreloader->updateCache(mRendering.getReferenceTime());
|
||||
preloadCells(duration);
|
||||
|
||||
mRendering.update (duration, paused);
|
||||
|
||||
mPreloader->updateCache(mRendering.getReferenceTime());
|
||||
}
|
||||
|
||||
void Scene::unloadCell (CellStoreCollection::iterator iter, bool test)
|
||||
|
|
|
@ -145,15 +145,15 @@ ViewData *ViewDataMap::getViewData(osg::Object *viewer, const osg::Vec3f& viewPo
|
|||
{
|
||||
float shortestDist = std::numeric_limits<float>::max();
|
||||
const ViewData* mostSuitableView = nullptr;
|
||||
for (const ViewData& other : mViewVector)
|
||||
for (const ViewData* other : mUsedViews)
|
||||
{
|
||||
if (other.suitableToUse(activeGrid) && other.getWorldUpdateRevision() >= mWorldUpdateRevision)
|
||||
if (other->suitableToUse(activeGrid) && other->getWorldUpdateRevision() >= mWorldUpdateRevision)
|
||||
{
|
||||
float dist = (viewPoint-other.getViewPoint()).length2();
|
||||
float dist = (viewPoint-other->getViewPoint()).length2();
|
||||
if (dist < shortestDist)
|
||||
{
|
||||
shortestDist = dist;
|
||||
mostSuitableView = &other;
|
||||
mostSuitableView = other;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -195,6 +195,7 @@ ViewData *ViewDataMap::createOrReuseView()
|
|||
mViewVector.push_back(ViewData());
|
||||
vd = &mViewVector.back();
|
||||
}
|
||||
mUsedViews.push_back(vd);
|
||||
vd->setWorldUpdateRevision(mWorldUpdateRevision);
|
||||
return vd;
|
||||
}
|
||||
|
@ -215,13 +216,16 @@ void ViewDataMap::clearUnusedViews(double referenceTime)
|
|||
else
|
||||
++it;
|
||||
}
|
||||
for (ViewData& vd : mViewVector)
|
||||
for (std::deque<ViewData*>::iterator it = mUsedViews.begin(); it != mUsedViews.end(); )
|
||||
{
|
||||
if (vd.getLastUsageTimeStamp() + mExpiryDelay < referenceTime)
|
||||
if ((*it)->getLastUsageTimeStamp() + mExpiryDelay < referenceTime)
|
||||
{
|
||||
vd.clear();
|
||||
mUnusedViews.push_back(&vd);
|
||||
(*it)->clear();
|
||||
mUnusedViews.push_back(*it);
|
||||
it = mUsedViews.erase(it);
|
||||
}
|
||||
else
|
||||
++it;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -106,6 +106,7 @@ namespace Terrain
|
|||
|
||||
unsigned int mWorldUpdateRevision;
|
||||
|
||||
std::deque<ViewData*> mUsedViews;
|
||||
std::deque<ViewData*> mUnusedViews;
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue