1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-02-06 14:15:34 +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:
Bo Svensson 2021-10-04 20:00:31 +00:00 committed by GitHub
parent 14d15dcfac
commit 3f731cd102
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 6 deletions

View file

@ -456,13 +456,13 @@ void QuadTreeWorld::accept(osg::NodeVisitor &nv)
osg::Object * viewer = isCullVisitor ? static_cast<osgUtil::CullVisitor*>(&nv)->getCurrentCamera() : nullptr; osg::Object * viewer = isCullVisitor ? static_cast<osgUtil::CullVisitor*>(&nv)->getCurrentCamera() : nullptr;
bool needsUpdate = true; 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) if (needsUpdate)
{ {
vd->reset(); vd->reset();
DefaultLodCallback lodCallback(mLodFactor, mMinSize, mViewDistance, mActiveGrid); DefaultLodCallback lodCallback(mLodFactor, mMinSize, mViewDistance, mActiveGrid);
mRootNode->traverseNodes(vd, nv.getViewPoint(), &lodCallback); mRootNode->traverseNodes(vd, viewPoint, &lodCallback);
} }
const float cellWorldSize = mStorage->getCellWorldSize(); const float cellWorldSize = mStorage->getCellWorldSize();

View file

@ -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)) 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; const ViewData* mostSuitableView = nullptr;
for (const ViewData* other : mUsedViews) 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); vd->copyFrom(*mostSuitableView);
return vd; return vd;
} }
else else if (!mostSuitableView)
{ {
vd->setViewPoint(viewPoint); vd->setViewPoint(viewPoint);
vd->setActiveGrid(activeGrid); vd->setActiveGrid(activeGrid);