mirror of
https://github.com/OpenMW/openmw.git
synced 2025-02-06 07:45:36 +00:00
attempts to fix spellcasting freezes (#3146)
Firstly, this PR reintroduces commit "Recreate a special case for IntersectionVisitor on QuadTreeWorld" we forgot to reapply while reverting a revert commit. Secondly, in cases we still need to build a view for an intersection visitor, we now use the available `osgUtil::IntersectionVisitor::getReferenceEyePoint` instead of falling back to the origin position that was previously causing long rebuild times.
This commit is contained in:
parent
14d15dcfac
commit
3f731cd102
2 changed files with 6 additions and 6 deletions
|
@ -456,13 +456,13 @@ void QuadTreeWorld::accept(osg::NodeVisitor &nv)
|
|||
|
||||
osg::Object * viewer = isCullVisitor ? static_cast<osgUtil::CullVisitor*>(&nv)->getCurrentCamera() : nullptr;
|
||||
bool needsUpdate = true;
|
||||
ViewData *vd = mViewDataMap->getViewData(viewer, nv.getViewPoint(), mActiveGrid, needsUpdate);
|
||||
|
||||
osg::Vec3f viewPoint = viewer ? nv.getViewPoint() : nv.getEyePoint();
|
||||
ViewData *vd = mViewDataMap->getViewData(viewer, viewPoint, mActiveGrid, needsUpdate);
|
||||
if (needsUpdate)
|
||||
{
|
||||
vd->reset();
|
||||
DefaultLodCallback lodCallback(mLodFactor, mMinSize, mViewDistance, mActiveGrid);
|
||||
mRootNode->traverseNodes(vd, nv.getViewPoint(), &lodCallback);
|
||||
mRootNode->traverseNodes(vd, viewPoint, &lodCallback);
|
||||
}
|
||||
|
||||
const float cellWorldSize = mStorage->getCellWorldSize();
|
||||
|
|
|
@ -143,7 +143,7 @@ ViewData *ViewDataMap::getViewData(osg::Object *viewer, const osg::Vec3f& viewPo
|
|||
|
||||
if (!(vd->suitableToUse(activeGrid) && (vd->getViewPoint()-viewPoint).length2() < mReuseDistance*mReuseDistance && vd->getWorldUpdateRevision() >= mWorldUpdateRevision))
|
||||
{
|
||||
float shortestDist = mReuseDistance*mReuseDistance;
|
||||
float shortestDist = viewer ? mReuseDistance*mReuseDistance : std::numeric_limits<float>::max();
|
||||
const ViewData* mostSuitableView = nullptr;
|
||||
for (const ViewData* other : mUsedViews)
|
||||
{
|
||||
|
@ -157,12 +157,12 @@ ViewData *ViewDataMap::getViewData(osg::Object *viewer, const osg::Vec3f& viewPo
|
|||
}
|
||||
}
|
||||
}
|
||||
if (mostSuitableView)
|
||||
if (mostSuitableView && mostSuitableView != vd)
|
||||
{
|
||||
vd->copyFrom(*mostSuitableView);
|
||||
return vd;
|
||||
}
|
||||
else
|
||||
else if (!mostSuitableView)
|
||||
{
|
||||
vd->setViewPoint(viewPoint);
|
||||
vd->setActiveGrid(activeGrid);
|
||||
|
|
Loading…
Reference in a new issue