From 3572edab72d3b9b2a534afd657be02fd93522038 Mon Sep 17 00:00:00 2001 From: elsid Date: Sun, 20 Jan 2019 19:27:52 +0300 Subject: [PATCH] Update navmesh in a separate method --- apps/openmw/mwrender/renderingmanager.cpp | 48 +++++++++++++---------- apps/openmw/mwrender/renderingmanager.hpp | 2 + 2 files changed, 29 insertions(+), 21 deletions(-) diff --git a/apps/openmw/mwrender/renderingmanager.cpp b/apps/openmw/mwrender/renderingmanager.cpp index 4d79fd3de..693491efe 100644 --- a/apps/openmw/mwrender/renderingmanager.cpp +++ b/apps/openmw/mwrender/renderingmanager.cpp @@ -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,30 @@ namespace MWRender { mNavMeshNumber = value; } + + void RenderingManager::updateNavMesh() + { + 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(); + } + } + } } diff --git a/apps/openmw/mwrender/renderingmanager.hpp b/apps/openmw/mwrender/renderingmanager.hpp index 7a4500ac9..2a48097bd 100644 --- a/apps/openmw/mwrender/renderingmanager.hpp +++ b/apps/openmw/mwrender/renderingmanager.hpp @@ -240,6 +240,8 @@ namespace MWRender void renderCameraToImage(osg::Camera *camera, osg::Image *image, int w, int h); + void updateNavMesh(); + osg::ref_ptr getIntersectionVisitor(osgUtil::Intersector* intersector, bool ignorePlayer, bool ignoreActors); osg::ref_ptr mIntersectionVisitor;