1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-04-30 16:17:46 +00:00
sapphire/src/world/Navi/NaviProvider.h

68 lines
1.9 KiB
C
Raw Normal View History

2019-01-20 16:10:48 +01:00
#ifndef _NAVIPROVIDER_H_
#define _NAVIPROVIDER_H_
#include <Common.h>
#include "ForwardsZone.h"
#include <recastnavigation/Detour/Include/DetourNavMesh.h>
#include <recastnavigation/Detour/Include/DetourNavMeshQuery.h>
namespace Sapphire
{
class NaviProvider
{
static const int NAVMESHSET_MAGIC = 'M' << 24 | 'S' << 16 | 'E' << 8 | 'T'; //'MSET';
static const int NAVMESHSET_VERSION = 1;
struct NavMeshSetHeader
{
int magic;
int version;
int numTiles;
dtNavMeshParams params;
};
struct NavMeshTileHeader
{
dtTileRef tileRef;
int dataSize;
};
2019-01-21 02:08:38 +01:00
static const int MAX_POLYS = 256;
static const int MAX_SMOOTH = 2048;
2019-01-20 16:10:48 +01:00
public:
2019-01-23 19:23:49 +01:00
NaviProvider( const std::string internalName );
2019-01-20 16:10:48 +01:00
2019-01-23 19:23:49 +01:00
bool init();
2019-01-21 14:02:47 +01:00
void loadMesh( std::string path );
void initQuery();
2019-01-20 16:10:48 +01:00
2019-01-21 14:02:47 +01:00
void toDetourPos(const Common::FFXIVARR_POSITION3 position, float* out);
2019-01-21 15:15:28 +01:00
Sapphire::Common::FFXIVARR_POSITION3 toGamePos( float* pos );
2019-01-21 02:08:38 +01:00
2019-01-21 14:02:47 +01:00
std::vector< Sapphire::Common::FFXIVARR_POSITION3 > findFollowPath(Common::FFXIVARR_POSITION3 startPos, Common::FFXIVARR_POSITION3 endPos);
bool hasNaviMesh() const;
2019-01-20 16:10:48 +01:00
protected:
2019-01-23 19:23:49 +01:00
std::string m_internalName;
2019-01-20 16:10:48 +01:00
dtNavMesh* m_naviMesh;
dtNavMeshQuery* m_naviMeshQuery;
2019-01-21 02:08:38 +01:00
float m_polyFindRange[3];
2019-01-23 21:10:53 +01:00
private:
2019-01-23 21:26:48 +01:00
static int fixupCorridor( dtPolyRef* path, const int npath, const int maxPath, const dtPolyRef* visited, const int nvisited );
2019-01-23 21:10:53 +01:00
static int fixupShortcuts( dtPolyRef* path, int npath, dtNavMeshQuery* navQuery );
inline static bool inRange( const float* v1, const float* v2, const float r, const float h );
2019-01-23 21:26:48 +01:00
static bool getSteerTarget( dtNavMeshQuery* navQuery, const float* startPos, const float* endPos, const float minTargetDist, const dtPolyRef* path, const int pathSize, float* steerPos, unsigned char& steerPosFlag, dtPolyRef& steerPosRef, float* outPoints = 0, int* outPointCount = 0 );
2019-01-23 21:10:53 +01:00
2019-01-20 16:10:48 +01:00
};
}
#endif