mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-03-29 22:06:45 +00:00
Update navmesh in a separate method
This commit is contained in:
parent
17cf2d5826
commit
3572edab72
2 changed files with 29 additions and 21 deletions
|
@ -599,28 +599,8 @@ namespace MWRender
|
||||||
mWater->update(dt);
|
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);
|
mCamera->update(dt, paused);
|
||||||
|
|
||||||
osg::Vec3f focal, cameraPos;
|
osg::Vec3f focal, cameraPos;
|
||||||
|
@ -1402,4 +1382,30 @@ namespace MWRender
|
||||||
{
|
{
|
||||||
mNavMeshNumber = value;
|
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -240,6 +240,8 @@ namespace MWRender
|
||||||
|
|
||||||
void renderCameraToImage(osg::Camera *camera, osg::Image *image, int w, int h);
|
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> getIntersectionVisitor(osgUtil::Intersector* intersector, bool ignorePlayer, bool ignoreActors);
|
||||||
|
|
||||||
osg::ref_ptr<osgUtil::IntersectionVisitor> mIntersectionVisitor;
|
osg::ref_ptr<osgUtil::IntersectionVisitor> mIntersectionVisitor;
|
||||||
|
|
Loading…
Reference in a new issue