1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-16 19:19:56 +00:00

Merge pull request #3084 from akortunov/master

Return check for distance when we try to reuse data
This commit is contained in:
Bret Curtis 2021-05-11 11:30:23 +02:00 committed by GitHub
commit 340801e08b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -141,9 +141,9 @@ ViewData *ViewDataMap::getViewData(osg::Object *viewer, const osg::Vec3f& viewPo
vd = found->second; vd = found->second;
needsUpdate = false; needsUpdate = false;
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 = std::numeric_limits<float>::max(); float shortestDist = mReuseDistance*mReuseDistance;
const ViewData* mostSuitableView = nullptr; const ViewData* mostSuitableView = nullptr;
for (const ViewData* other : mUsedViews) for (const ViewData* other : mUsedViews)
{ {
@ -157,11 +157,16 @@ ViewData *ViewDataMap::getViewData(osg::Object *viewer, const osg::Vec3f& viewPo
} }
} }
} }
if (mostSuitableView && mostSuitableView != vd) if (mostSuitableView)
{ {
vd->copyFrom(*mostSuitableView); vd->copyFrom(*mostSuitableView);
return vd; return vd;
} }
else
{
vd->setViewPoint(viewPoint);
needsUpdate = true;
}
} }
if (!vd->suitableToUse(activeGrid)) if (!vd->suitableToUse(activeGrid))
{ {