1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-04-27 14:57:44 +00:00

Merge pull request #502 from goaaats/pathfinding

Add navi mesh folder to world config
This commit is contained in:
Mordred 2019-01-24 23:56:52 +01:00 committed by GitHub
commit 3e3f637be1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 15 additions and 9 deletions

View file

@ -15,6 +15,9 @@ DisconnectTimeout = 20
; Sent on login - each line must be shorter than 307 characters, split lines with ';'
MotD = Welcome to Sapphire!;This is a very good server;You can change these messages by editing General.MotD in config/config.ini
[Navigation]
MeshPath = navi
[Housing]
; Set the default estate name. {0} will be replaced with the plot number
DefaultEstateName = Estate ${0}

View file

@ -10,7 +10,7 @@ Sapphire::World::Manager::NaviMgr::NaviMgr( FrameworkPtr pFw ) :
bool Sapphire::World::Manager::NaviMgr::setupTerritory( const std::string& internalName )
{
auto provider = Navi::make_NaviProvider( internalName );
auto provider = Navi::make_NaviProvider( internalName, m_pFw );
if( provider->init() )
{

View file

@ -2,6 +2,8 @@
#include <Framework.h>
#include <Territory/Zone.h>
#include <Logging/Logger.h>
#include <Config/ConfigMgr.h>
#include "NaviProvider.h"
@ -11,21 +13,21 @@
#include <recastnavigation/Recast/Include/Recast.h>
#include <experimental/filesystem>
Sapphire::World::Navi::NaviProvider::NaviProvider( const std::string& internalName ) :
Sapphire::World::Navi::NaviProvider::NaviProvider( const std::string& internalName, FrameworkPtr pFw ) :
m_naviMesh( nullptr ),
m_naviMeshQuery( nullptr ),
m_internalName( internalName )
m_internalName( internalName ),
m_pFw( pFw )
{
// Set defaults
m_polyFindRange[0] = 10;
m_polyFindRange[1] = 20;
m_polyFindRange[2] = 10;
m_polyFindRange[ 0 ] = 10;
m_polyFindRange[ 1 ] = 20;
m_polyFindRange[ 2 ] = 10;
}
bool Sapphire::World::Navi::NaviProvider::init()
{
auto meshesFolder = std::experimental::filesystem::path( "navi" );
auto meshesFolder = std::experimental::filesystem::path( m_pFw->get< Sapphire::ConfigMgr >()->getValue< std::string >( "Navigation", "MeshPath", "navi" ) );
auto meshFolder = meshesFolder / std::experimental::filesystem::path( m_internalName );
if( std::experimental::filesystem::exists( meshFolder ) )

View file

@ -31,7 +31,7 @@ namespace Sapphire::World::Navi
};
public:
explicit NaviProvider( const std::string& internalName );
explicit NaviProvider( const std::string& internalName, FrameworkPtr pFw );
bool init();
void loadMesh( const std::string& path );
@ -60,6 +60,7 @@ namespace Sapphire::World::Navi
const dtPolyRef* path, const int32_t pathSize, float* steerPos, uint8_t& steerPosFlag,
dtPolyRef& steerPosRef, float* outPoints = 0, int32_t* outPointCount = 0 );
FrameworkPtr m_pFw;
};
}