1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-04-01 04:20:20 +00:00

Merge pull request #2137 from elsid/navmesh_render

Avoid useless read of navmeshes from navigator
This commit is contained in:
Bret Curtis 2019-01-20 20:32:24 +01:00 committed by GitHub
commit c5a67c2079
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 37 additions and 21 deletions

View File

@ -30,6 +30,11 @@ namespace MWRender
void disable();
bool isEnabled() const
{
return mEnabled;
}
private:
osg::ref_ptr<osg::Group> mRootNode;
bool mEnabled;

View File

@ -599,28 +599,8 @@ namespace MWRender
mWater->update(dt);
}
const auto navMeshes = mNavigator.getNavMeshes();
updateNavMesh();
auto it = navMeshes.begin();
for (std::size_t i = 0; it != navMeshes.end() && i < mNavMeshNumber; ++i)
++it;
if (it == navMeshes.end())
{
mNavMesh->reset();
}
else
{
try
{
const auto locked = it->second.lockConst();
mNavMesh->update(locked->getValue(), mNavMeshNumber, locked->getGeneration(),
locked->getNavMeshRevision(), mNavigator.getSettings());
}
catch (const std::exception& e)
{
Log(Debug::Error) << "NavMesh render update exception: " << e.what();
}
}
mCamera->update(dt, paused);
osg::Vec3f focal, cameraPos;
@ -1402,4 +1382,33 @@ namespace MWRender
{
mNavMeshNumber = value;
}
void RenderingManager::updateNavMesh()
{
if (!mNavMesh->isEnabled())
return;
const auto navMeshes = mNavigator.getNavMeshes();
auto it = navMeshes.begin();
for (std::size_t i = 0; it != navMeshes.end() && i < mNavMeshNumber; ++i)
++it;
if (it == navMeshes.end())
{
mNavMesh->reset();
}
else
{
try
{
const auto locked = it->second.lockConst();
mNavMesh->update(locked->getValue(), mNavMeshNumber, locked->getGeneration(),
locked->getNavMeshRevision(), mNavigator.getSettings());
}
catch (const std::exception& e)
{
Log(Debug::Error) << "NavMesh render update exception: " << e.what();
}
}
}
}

View File

@ -240,6 +240,8 @@ namespace MWRender
void renderCameraToImage(osg::Camera *camera, osg::Image *image, int w, int h);
void updateNavMesh();
osg::ref_ptr<osgUtil::IntersectionVisitor> getIntersectionVisitor(osgUtil::Intersector* intersector, bool ignorePlayer, bool ignoreActors);
osg::ref_ptr<osgUtil::IntersectionVisitor> mIntersectionVisitor;